Lisandro Dalcin <dalc...@...> writes:

> On Thu, Jun 4, 2009 at 7:34 PM, Jon Olav Vik <jono...@...> wrote:
> > Jon Olav Vik <jono...@...> writes:
> >
> > I did try "cdef N_Vector arr2nv(np.ndarray[np.int_t] x):", based on
> > http://wiki.cython.org/tutorials/numpy#Efficientindexing
> > but I couldn't "cimport numpy as np" as required to get at np.int_t. Any 
ideas
> > why I'd get "error: numpy/arrayobject.h: No such file or directory"? [2]
> >
> 
> Because the C compiler requires the include path to numpy headers. The
> function numpy.get_include() returns it, however I do not remember if
> pyximport has the fixes to let you pass such include path. Could you
> try to do in your shell
> 
> $ export CFLAGS=-I`python -c 'import numpy; print numpy.get_include()'`
> 
> and next try to run your code?

The cimport statement now passes, though I'm not sure what to make of the "type-
punned" warnings [1]. "Defined but not used" doesn't sound too scary, though.

I remember now that we used numpy.get_include() in Dag Sverre's workshop. 
Adding "import numpy as np" and "include_dirs=['/site/VERSIONS/sundials-2.3.0/
include', np.get_include ()]," worked for my setup.py too (the "hello.pyx" 
example mentioned previously).

Thank you very much for your help. Later I'll have a go at actually running 
CVODE.

Best regards,
Jon Olav Vik


[1]
bash-3.2$ cat cimp.pyx
cimport numpy
print "cimported numpy"
bash-3.2$ python -c "import pyximport; pyximport.install(build_dir='.'); import 
cimp"
./temp.linux-x86_64-2.5/pyrex/cimp.c: In function '__Pyx_PyObject_IsTrue':
./temp.linux-x86_64-2.5/pyrex/cimp.c:3131: warning: dereferencing type-punned 
pointer will break strict-aliasing rules
./temp.linux-x86_64-2.5/pyrex/cimp.c:3132: warning: dereferencing type-punned 
pointer will break strict-aliasing rules
./temp.linux-x86_64-2.5/pyrex/cimp.c: At top level:
/site/VERSIONS/compython-2.5/Linux/lib/python2.5/site-packages/numpy/core/
include/numpy/__multiarray_api.h:959: warning: '_import_array' defined but not 
used
./temp.linux-x86_64-2.5/pyrex/cimp.c:687: warning: '__pyx_k_3' defined but not 
used
./temp.linux-x86_64-2.5/pyrex/cimp.c:688: warning: '__pyx_k_4' defined but not 
used
./temp.linux-x86_64-2.5/pyrex/cimp.c:708: warning: '__pyx_k_24' defined but not 
used
./temp.linux-x86_64-2.5/pyrex/cimp.c:714: warning: '__pyx_k_26' defined but not 
used
./temp.linux-x86_64-2.5/pyrex/cimp.c:715: warning: '__pyx_k_27' defined but not 
used
./temp.linux-x86_64-2.5/pyrex/cimp.c:729: warning: 
'__pyx_pf_5numpy_7ndarray___getbuffer__' defined but not used
./temp.linux-x86_64-2.5/pyrex/cimp.c:1487: warning: 
'__pyx_pf_5numpy_7ndarray___releasebuffer__' defined but not used
cimported numpy


_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to