[Cython] Intra-package reference not working with cimport
Stefan Behnel
stefan_ml at behnel.de
Wed Nov 5 07:28:54 CET 2008
Hi,
Greg Ewing wrote:
> 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.
It does, I use this in lxml (although only for legacy reasons).
Stefan
More information about the Cython-dev
mailing list