are numpy headers being included in the Extensions?
mattjj opened this issue · comments
I'm on a pretty clean Ubuntu environment and I installed the dependencies for the native extensions listed in the README. My pip install lycon
command failed like this:
[... snip ...]
[ 82%] Building CXX object CMakeFiles/lycon.dir/src/lycon/util/string.cc.o
[ 85%] Building CXX object CMakeFiles/lycon.dir/src/lycon/util/tls.cc.o
[ 89%] Linking CXX static library liblycon.a
[ 89%] Built target lycon
Scanning dependencies of target pycon
[ 96%] Building CXX object CMakeFiles/pycon.dir/src/lycon/python/interop.cc.o
[ 96%] Building CXX object CMakeFiles/pycon.dir/src/lycon/python/module.cc.o
In file included from /tmp/pip-build-vbh9Vg/lycon/src/lycon/python/interop.cc:5:0:
/tmp/pip-build-vbh9Vg/lycon/src/lycon/python/numpy.h:9:33: fatal error: numpy/ndarrayobject.h: No such file or directory
compilation terminated.
In file included from /tmp/pip-build-vbh9Vg/lycon/src/lycon/python/module.cc:9:0:
/tmp/pip-build-vbh9Vg/lycon/src/lycon/python/numpy.h:9:33: fatal error: numpy/ndarrayobject.h: No such file or directory
compilation terminated.
CMakeFiles/pycon.dir/build.make:62: recipe for target 'CMakeFiles/pycon.dir/src/lycon/python/interop.cc.o' failed
make[2]: *** [CMakeFiles/pycon.dir/src/lycon/python/interop.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/pycon.dir/build.make:86: recipe for target 'CMakeFiles/pycon.dir/src/lycon/python/module.cc.o' failed
make[2]: *** [CMakeFiles/pycon.dir/src/lycon/python/module.cc.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/pycon.dir/all' failed
make[1]: *** [CMakeFiles/pycon.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
* Failed to build the Lycon native extension.
* [Error] Failed to exceute: /usr/bin/make -j 4
----------------------------------------
Command "/home/ubuntu/miniconda2/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-vbh9Vg/lycon/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-XFjuk5-record/install-record.txt --single-version-externally-managed --compile" failed with error code 255 in /tmp/pip-build-vbh9Vg/lycon/
I think I fixed it by setting CPATH to the output of python -c "import numpy as np; print np.get_include()"
. Since I'm using the Anaconda python distribution, for me those are in /home/ubuntu/miniconda2/lib/python2.7/site-packages/numpy/core/include
.
You might be able to fix this by calling np.get_include()
somewhere in your setup.py and forwarding it to your build process, but I haven't looked in detail. I'm sure you have a better idea of how to fix it!
Thanks for reporting this. Indeed, the old build script didn't handle non-standard numpy include paths (the default numpy installation places a symlink in the Python include directory).
I've updated CMakeLists.txt
to auto-detect it (similar to how you've described it). Let me know if you run into any issues.