[Cython] Intra-package reference not working with cimport

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Nov 5 02:08:04 CET 2008


Stephane DROUARD wrote:

> it might also be nice to support a syntax like:
>   cimport foo "pkg.foo"
> That would load foo.pxd from the path list (-I) but would generate the
> equivalent import of pkg.foo at runtime.

If this is purely a matter of source code layout, then
there's an alternative availalable in Pyrex: if you
name your source files

   pkg.foo.pxd

and

   pkg.foo.pyx

then they can be anywhere in the source tree (as long as
the .pxd can be found on the -I path) and the module will
be assumed to be named pkg.foo at run time.

I don't know whether Cython still supports this, though.

-- 
Greg


More information about the Cython-dev mailing list