[Python-Dev] how to find the file path to an extension module at init time?

"Martin v. Löwis" martin at v.loewis.de
Sun Nov 13 21:46:31 CET 2011


> I'm asking specifically because I'd like to properly implement __file__
> in Cython modules at module init time.

Why do you need to implement __file__? Python will set it eventually to
its correct value, no?

> Another problem is that package local imports from __init__.py no longer
> work when it's compiled

Does it actually work to have __init__ be an extension module?

> Any ideas how this could currently be achieved? 

Currently, for Cython? I don't think that can work.

> Or could this become a new feature in the future?

Certainly. An approach similar to _Py_PackageContext should be possible.

Regards,
Martin


More information about the Python-Dev mailing list