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
Task Type Bug Report
Category Packages
Status Closed
Assigned To Jan de Groot (JGC)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

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.
Comment by Sergej Pupykin (sergej) - Tuesday, 11 January 2011, 10:21 GMT
Can not reproduce now:
python2 setup.py build_ext
works ok both in numpy and cython.
Comment by Gergely (imrehg) - Tuesday, 11 January 2011, 16:36 GMT
How does the gcc line look in your output?

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....
Comment by Sergej Pupykin (sergej) - Wednesday, 12 January 2011, 14:49 GMT
running build_ext
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.
   setup.py (0.3 KiB)
Comment by Gergely (imrehg) - Wednesday, 12 January 2011, 15:25 GMT
Well, of course, if you add that manually, it will work, but manual setting is what I would like to avoid.

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?
Comment by Thomas Dziedzic (tomd123) - Tuesday, 01 February 2011, 06:24 GMT
fwiw, one of my packages also suffered from this problem, and I fixed it with "export CFLAGS=-I/usr/lib/python2.7/site-packages/numpy/core/include/"
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
Comment by Alexander F. Rødseth (xyproto) - Thursday, 22 March 2012, 21:14 GMT
Able to reproduce. Assigned to python2-numpy maintainer as this is one of our oldest bugs and perhaps something can be done in the python2-numpy package?

Loading...