tmbdev / clstm

A small C++ implementation of LSTM networks, focused on OCR.
Apache License 2.0
821 stars 224 forks source link

error: use of undeclared identifier 'environ' #143

Closed loranger closed 6 years ago

loranger commented 6 years ago

Hello,

As I tried to install Kraken, I found a bug with the clstm dependency installation.

I tried with Python 3 and Python 2, but the result remains the same. I use homebrewed python on macOS 10.13.3

Here is the output I get while running pip install clstm

Output ``` Collecting clstm Using cached clstm-0.0.5.tar.gz Requirement already satisfied: numpy>=1.9.0 in /usr/local/lib/python3.6/site-packages (from clstm) Building wheels for collected packages: clstm Running setup.py bdist_wheel for clstm: started Running setup.py bdist_wheel for clstm: finished with status 'error' Complete output from command /usr/local/opt/python3/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/35/8h9cj97x2sg8pxmk6l73fn8w0000gn/T/pip-build-rncsaq3b/clstm/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/35/8h9cj97x2sg8pxmk6l73fn8w0000gn/T/tmpi5jp5zoypip-wheel- --python-tag cp36: making proto file clstm.proto: No such file or directory running bdist_wheel running build_ext building '_clstm' extension swigging clstm.i to clstm_wrap.cpp swig -python -c++ -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -I/usr/local/lib/python3.6/site-packages/numpy/core/include -o clstm_wrap.cpp clstm.i clstm.i:35: Warning 451: Setting a const char * variable may leak memory. creating build creating build/temp.macosx-10.13-x86_64-3.6 clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/eigen3 -I/usr/local/include/eigen3 -I/usr/local/include -I/usr/include/hdf5/serial -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -I/usr/local/lib/python3.6/site-packages/numpy/core/include -c clstm_wrap.cpp -o build/temp.macosx-10.13-x86_64-3.6/clstm_wrap.o -std=c++11 -w -Dadd_raw=add -DNODISPLAY=1 -DTHROW=throw -DHGVERSION="\"unknown\"" clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/eigen3 -I/usr/local/include/eigen3 -I/usr/local/include -I/usr/include/hdf5/serial -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -I/usr/local/lib/python3.6/site-packages/numpy/core/include -c clstm.cc -o build/temp.macosx-10.13-x86_64-3.6/clstm.o -std=c++11 -w -Dadd_raw=add -DNODISPLAY=1 -DTHROW=throw -DHGVERSION="\"unknown\"" clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/eigen3 -I/usr/local/include/eigen3 -I/usr/local/include -I/usr/include/hdf5/serial -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -I/usr/local/lib/python3.6/site-packages/numpy/core/include -c clstm_prefab.cc -o build/temp.macosx-10.13-x86_64-3.6/clstm_prefab.o -std=c++11 -w -Dadd_raw=add -DNODISPLAY=1 -DTHROW=throw -DHGVERSION="\"unknown\"" clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/eigen3 -I/usr/local/include/eigen3 -I/usr/local/include -I/usr/include/hdf5/serial -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -I/usr/local/lib/python3.6/site-packages/numpy/core/include -c extras.cc -o build/temp.macosx-10.13-x86_64-3.6/extras.o -std=c++11 -w -Dadd_raw=add -DNODISPLAY=1 -DTHROW=throw -DHGVERSION="\"unknown\"" extras.cc:679:17: error: use of undeclared identifier 'environ' char **ep = environ; ^ 1 error generated. error: command 'clang' failed with exit status 1 ---------------------------------------- Running setup.py clean for clstm Failed to build clstm Installing collected packages: clstm Running setup.py install for clstm: started Running setup.py install for clstm: finished with status 'error' Complete output from command /usr/local/opt/python3/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/35/8h9cj97x2sg8pxmk6l73fn8w0000gn/T/pip-build-rncsaq3b/clstm/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/35/8h9cj97x2sg8pxmk6l73fn8w0000gn/T/pip-noa4v0f4-record/install-record.txt --single-version-externally-managed --compile: making proto file clstm.proto: No such file or directory running install running build running build_ext building '_clstm' extension swigging clstm.i to clstm_wrap.cpp swig -python -c++ -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -I/usr/local/lib/python3.6/site-packages/numpy/core/include -o clstm_wrap.cpp clstm.i clstm.i:35: Warning 451: Setting a const char * variable may leak memory. creating build creating build/temp.macosx-10.13-x86_64-3.6 clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/eigen3 -I/usr/local/include/eigen3 -I/usr/local/include -I/usr/include/hdf5/serial -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -I/usr/local/lib/python3.6/site-packages/numpy/core/include -c clstm_wrap.cpp -o build/temp.macosx-10.13-x86_64-3.6/clstm_wrap.o -std=c++11 -w -Dadd_raw=add -DNODISPLAY=1 -DTHROW=throw -DHGVERSION="\"unknown\"" clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/eigen3 -I/usr/local/include/eigen3 -I/usr/local/include -I/usr/include/hdf5/serial -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -I/usr/local/lib/python3.6/site-packages/numpy/core/include -c clstm.cc -o build/temp.macosx-10.13-x86_64-3.6/clstm.o -std=c++11 -w -Dadd_raw=add -DNODISPLAY=1 -DTHROW=throw -DHGVERSION="\"unknown\"" clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/eigen3 -I/usr/local/include/eigen3 -I/usr/local/include -I/usr/include/hdf5/serial -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -I/usr/local/lib/python3.6/site-packages/numpy/core/include -c clstm_prefab.cc -o build/temp.macosx-10.13-x86_64-3.6/clstm_prefab.o -std=c++11 -w -Dadd_raw=add -DNODISPLAY=1 -DTHROW=throw -DHGVERSION="\"unknown\"" clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/eigen3 -I/usr/local/include/eigen3 -I/usr/local/include -I/usr/include/hdf5/serial -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -I/usr/local/lib/python3.6/site-packages/numpy/core/include -c extras.cc -o build/temp.macosx-10.13-x86_64-3.6/extras.o -std=c++11 -w -Dadd_raw=add -DNODISPLAY=1 -DTHROW=throw -DHGVERSION="\"unknown\"" extras.cc:679:17: error: use of undeclared identifier 'environ' char **ep = environ; ^ 1 error generated. error: command 'clang' failed with exit status 1 ---------------------------------------- ```
mittagessen commented 6 years ago

Apologies to the maintainers, I've packaged the separate-derivs branch with the working python bindings to pypi a while ago.

I don't know if clstm works on OSX but I'll look into the error right now and adjust the travis packaging if I get it working somehow

amitdo commented 6 years ago

See #34

mittagessen commented 6 years ago

I've got travis to produce osx builds. Either I'm getting better at the whole CI packaging shebang or the goat sacrifice the last time actually helped. @loranger, give it half an hour or so to build and push the tag to pypi and give it another try.

amitdo commented 6 years ago

What patch(es) did you apply to make it work? Just the one in #34? @ryanfb patch? @tmbdev suggestion? Something else?

loranger commented 6 years ago

I've got no more issue regarding the clstm install. Thanks @mittagessen !

mittagessen commented 6 years ago

I just applied @ryanfb's patch and forced clang to use libc++ instead of libstdc++. As I don't have a OSX machine to test on and debugging changes through travis is not my idea of a fun evening I kept it at that. Have a look at the main branch of mittagessen/clstm; it has some other stop gap changes to make it auto-deploy to pypi through travis and actually built in a single pass with setuptools. Caveat emptor, all of it is rather ugly as it is only intended to keep people off my back with kraken installation related questions until I've finished the pytorch port.