On Tue, Jun 30, 2009 at 5:37 PM, Elliott
Slaughter<[email protected]> wrote:
> Hi,
>
> The manual states that "the Cython compiler searches for a file called
> modulename.pxd along the search path for include files, as specified by -I
> command line options" [1].
>

A good thing about open source projects is that the best
docummentation are the actual sources :-)
http://hg.cython.org/cython-devel/file/tip/Cython/Distutils/extension.py

Try this:

from Cython.Distutils.extension import Extension
...
Extension('foo', ['foo.pyx'], pyrex_include_dirs=['dir1', 'dir2', 'dir3'])


Other way (not recommended, not portable for POSIX/Windows):
add a setup.cfg file alongside your setup.py file, and write inside it
(use ";" to separate on Windows):

[build_ext]
pyrex_include_dirs = dir1:dir2:dir3



> I'm wondering if there is any way to get this behavior with distutils (i.e.
> from inside a setup.py script). The build_ext command doens't seem to
> support using the -I option in the same way that Cython does.
>
> $ cython -Idir foo.pyx
>
> $ python setup_foo.py build_ext -c mingw32 -i
> running build_ext
> error: file 'bar.pxd' does not exist
>
> $ mv dir/bar.pxd .
>
> $ python setup_foo.py build_ext -c mingw32 -i
> running build_ext
> building 'foo' extension
> ... compiles successfully ...
>
> $ cat foo.pyx
> cimport bar
>
> $ cat bar.pxd
>
> $ cat setup_foo.py
> from distutils.core import setup
> from distutils.extension import Extension
> from Cython.Distutils import build_ext
>
> setup(
>     cmdclass = {'build_ext': build_ext},
>     ext_modules = [Extension('foo', ['foo.pyx'])]
> )
>
> This is with Python 2.5.4, Cython 0.11.2, and MinGW from Cygwin on Windows.
>
> Thanks.
>
> [1]
> http://docs.cython.org/docs/sharing_declarations.html#search-paths-for-definition-files
>
> --
> Elliott Slaughter
>
> "Don't worry about what anybody else is going to do. The best way to predict
> the future is to invent it." - Alan Kay
>
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev
>
>



-- 
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