FS#22326 - [python2-numpy] cannot find numpy header files
Attached to Project:
Community Packages
Opened by Gergely (imrehg) - Wednesday, 05 January 2011, 15:51 GMT
Last edited by Jan de Groot (JGC) - Thursday, 22 March 2012, 21:40 GMT
Opened by Gergely (imrehg) - Wednesday, 05 January 2011, 15:51 GMT
Last edited by Jan de Groot (JGC) - Thursday, 22 March 2012, 21:40 GMT
|
Details
Description:
When trying to use cython (within python2) to create a module from a numpy scrip, the compilation fails because python/gcc cannot find the required header files that came with numpy. Additional info: * package versions: python2 2.7.1-3 python2-numpy 1.5.1-1 * config and/or log files etc. attached a test script, the build file and the error log. Steps to reproduce: Try to build the attached test module the standard way, that is "python2 setup.py build_ext" Process fails with: "fatal error: numpy/arrayobject.h: No such file or directory compilation terminated." |
This task depends upon
Closed by Jan de Groot (JGC)
Thursday, 22 March 2012, 21:40 GMT
Reason for closing: Won't fix
Additional comments about closing: I don't think anything can be done in the python2-numpy package. Fixing it there means probably adding default things to the python include path or moving files to the default pythin include path. Both solutions are not what we or upstream would want.
Looking at python2-mlpy, they add the include path for numpy in setup.py, though their method is a bit more creative than what sergej proposed. As numpy provides a way to lookup this include path, just like you would use pkg-config or *-config scripts for normal C libraries to get such a path, I don't think this is something we should try to fix.
Thursday, 22 March 2012, 21:40 GMT
Reason for closing: Won't fix
Additional comments about closing: I don't think anything can be done in the python2-numpy package. Fixing it there means probably adding default things to the python include path or moving files to the default pythin include path. Both solutions are not what we or upstream would want.
Looking at python2-mlpy, they add the include path for numpy in setup.py, though their method is a bit more creative than what sergej proposed. As numpy provides a way to lookup this include path, just like you would use pkg-config or *-config scripts for normal C libraries to get such a path, I don't think this is something we should try to fix.
python2 setup.py build_ext
works ok both in numpy and cython.
It's still wrong for me... From the error log I attached it's clear that cython on its own includes /usr/include/python2.7 but to make the script work I have manually set in the setup to include "/usr/lib/python2.7/site-packages/numpy/core/include"
As I've seen from checking other packages, back at python2.6 the /usr/include/python2.6 was used but on the net there are quite a few places mentioning /usr/lib/python2.x/site-packages/ place to use with cython. So not sure if these directories are according to a packaging convention or some other thing....
cythoning numpytest.pyx to numpytest.c
building 'numpytest' extension
creating build
creating build/temp.linux-i686-2.7
gcc -pthread -DNDEBUG -march=i686 -mtune=generic -O2 -pipe -I/usr/lib/python2.7/site-packages/numpy/core/include/ -fPIC -I/usr/include/python2.7 -c numpytest.c -o build/temp.linux-i686-2.7/numpytest.o
creating build/lib.linux-i686-2.7
gcc -pthread -shared -Wl,--hash-style=gnu -Wl,--as-needed -I/usr/lib/python2.7/site-packages/numpy/core/include/ build/temp.linux-i686-2.7/numpytest.o -L/usr/lib -lpython2.7 -o build/lib.linux-i686-2.7/numpytest.so
I think it is because I did
export CFLAGS=-I/usr/lib/python2.7/site-packages/numpy/core/include/
before.
Also test can be modified as in attachment.
The attached setup.py works, I guess I just have to start adding that line to my setups. I'm just puzzled then why Python2.6 worked without such gimmicks and 2.7 does not?
Of course a better, solution would be nice.
python-mlpy - http://aur.archlinux.org/packages.php?ID=25862
edit:
the package is now called python2-mlpy