[Pyrex] Getting full package paths in extension __module__ attributes?

Alex Coventry throwaway at MIT.EDU
Tue May 1 16:01:19 UTC 2007


Hi.  I have a file in evolution/hmmer/rind/_F81.pyx, corresponding to an
extension module with package path evolution.hmmer.rind._F81.  It
contains an extension type called F81.  The __module__ attribute of the
F81 type is set to "_F81" rather than the full package path.  I think
this is causing problems with my attempts to pickle instances of the
type: The pickling machinery is looking for "_F81" in sys.modules, when
it should be looking for evolution.hmmer.rind._F81.  I can hack around
this by creating an empty pure-python extension to F81, which then has
the correct value in the __module__ attribute, but I was wondering
whether there might be a cleaner way around this problem.

I am not sure where to fix this, even in the C code.  The _F81.c file
generated by pyrecx contains a call

Py_InitModule4("_F81", __pyx_methods, __pyx_mdoc,0, PYTHON_API_VERSION);

But changing the "_F81" value to the full package name doesn't seem to
change the value of the __module__ attribute.

Alex



More information about the Pyrex mailing list