[Distutils] Problem importing pylirc egg

Phillip J. Eby pje at telecommunity.com
Mon Apr 24 21:34:17 CEST 2006


At 09:22 PM 4/24/2006 +0200, Philippe Normand wrote:

>Le 24/4/2006, "Ian Bicking" <ianb at colorstudy.com> a écrit:
> >
> >What's in /home/phil/lib/python2.4/pylirc-0.0.5-py2.4-linux-i686.egg ?
> >What does your sys.path look like after you do the require()?  That path
> >should be on your sys.path after require(), and it should contain
> >pylirc/__init__.py (or be a zip file that includes pylirc/__init__.py).
> >
>
>sys.path contains full path to the egg, even without requiring pylirc.
>
>The .egg is a zip file containing:
>
>Archive:  pylirc-0.0.5-py2.4-linux-i686.egg
>   inflating: pylircmodule.so
>   inflating: pylircmodule.py
>   inflating: pylircmodule.pyc
>   inflating: EGG-INFO/PKG-INFO
>   inflating: EGG-INFO/top_level.txt
>   inflating: EGG-INFO/SOURCES.txt
>   inflating: EGG-INFO/native_libs.txt
>   inflating: EGG-INFO/zip-safe
>
>pylircmodule.py isn't part of the "official" pylirc distribution.
>Seems like it was generated by setuptools. But if there's a .so with
>the same name, it will confuse things, no ?

No.  Python doesn't import .so files in a zipfile (such as a .egg file), 
and when the file is extracted, .so files take precedence over .py files, 
so the .py is ignored in that case.

The problem here is that Python's import machinery ignores the word 
'module' in the .so file name, but not in the .py file name.  It looks like 
I need to change bdist_egg to handle this, and possibly some other code in 
setuptools as well.

In the meantime, you should be able to 'import pylircmodule' and have it 
work, or re-install it using -Z (--always-unzip) so that it is installed as 
a directory instead of a zipfile.



More information about the Distutils-SIG mailing list