See this: I install mpi4py C-API headers, SWIG typemaps, and of course
Cython pxd's here:

$ tree $HOME/lib/python/mpi4py/include/
/u/dalcinl/lib/python/mpi4py/include/
`-- mpi4py
    |-- MPI.pxd
    |-- __init__.pyx
    |-- mpi.pxi
    |-- mpi4py.MPI.h
    |-- mpi4py.MPI_api.h
    |-- mpi4py.h
    |-- mpi4py.i
    `-- mpi_c.pxd

As you can see, I have a (empty) __init__.pyx alonside MPI.pxd


Now suppose I have Cython code wanting to cimport MPI.pxd like this:

$ cat tmp.pyx
from mpi4py cimport MPI


Now I try to cythonize the source, passing -I (AFAIK) appropriately :

$ cython -I$HOME/lib/python/mpi4py/include tmp.pyx
Error converting Pyrex file to C:
------------------------------------------------------------
...
from mpi4py cimport MPI
^
------------------------------------------------------------
/u/dalcinl/Devel/mpi4py-dev/demo/wrap-cython/tmp.pyx:1:0: 'mpi4py.pxd' not found


Now if I add an empty mpi4py.pxd

$ touch $HOME/lib/python/mpi4py/include/mpi4py.pxd

And try to cythonize again... SUCCESS!!.

Why should I add a "mpi4py.pxd" alongside the "mpi4py/" directory to
make Cython understand that "mpi4py" is a package, provided that
"mpi4py/__init__.pyx" file is there? Am I missing something? Is this a
bug or a feature? Please note that if I code the cimport like this:

cimport mpi4py.MPI as MPI

... then I DO NOT need to add the mpi4py.pxd stub file... This makes
me think that the behaviour I'm describing is actually a bug...


-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to