[Pyrex] C-API implementation in Pyrex 0.9.6

Stefan Behnel stefan_ml at behnel.de
Mon Oct 15 10:10:30 CEST 2007


Stefan Behnel wrote:
> Greg Ewing wrote:
>> However, the
>> generated code should at least compile and work correctly
>> the way things are, if you declare things in the right places
>> and cimport them where they're needed.
> 
> It compiles now, but it fails on the initial import. I have two modules,
> "lxml.etree" and "lxml.objectify". The objectify module cimports (and imports)
> the etree module. Given that the stacktrace mentions line 1 in objectify.pyx,
> I would say it's the cimport that fails here. One more thing to fix...
> 
> Traceback (most recent call last):
>     from lxml import objectify
>   File "objectify.pyx", line 1, in objectify
> ImportError: No module named etree

I forgot to mention that this uses a package local import, so the first lines
of lxml/objectify.pyx look like this:

    from etree cimport _Document, _Element, ElementBase
    from etree cimport _ElementIterator, ElementClassLookup
    from etree cimport elementFactory, textOf
    cimport etree as cetree

I also tried

    from lxml.etree cimport _Document, _Element, ElementBase

but that fails as Pyrex is then looking for "lxml.etree.pxd".

BTW, Cython sets the correct module name based on what you tell distutils, so
there should be no need to give modules a complete package name.

Stefan



More information about the Pyrex mailing list