[Distutils] Namespace packages and egg-info confusion when using bdist_rpm

Stanley A. Klein sklein at cpcug.org
Wed Jul 25 22:42:25 CEST 2007


I've been trying to build rpms of enthought system components.  Some of
them use namespace packages.  Those packages have the required __init__.py
files containing
"__import__('pkg_resources').declare_namespace(__name__)".

According to the Setuptools Guide, these __init__.py files are not to be
packaged when using "system" packaging (such as bdist_rpm) and when I run
bdist_rpm they are not included in the rpms.  However, there are egg-info
directories and nspkg.pth files produced, included in the rpms, and
installed in site-packages.  When I tried to run the enthought example
applications, I had various kinds of import failures.  I found that fixing
them required putting the unpackaged __init__.py files into the relevant
directories in the namespace packages.

The various rpms were being placed in the proper locations where they
should have been found for importing.  There were some strange errors,
such as in one case when I tried to test the imports interactively an
"import a.b.c" worked, but an "import a.b.c as c" failed.

Before putting in the __init__.py files, I tried removing the egg-info and
nspkg.pth files from site_packages.  That did not improve things.  I also
noticed that some other packages had pth files in site-packages, so that
may be what is needed if the egg-info and nspkg.pth are removed, although
I don't know why or what the pth files are supposed to contain.

I think setuptools is somehow not properly processing bdist_rpm if there
are namespace packages involved.  Also, the setuptools don't seem to have
an option to not create the egg info and nspkg.pth files and/or to not
package them if bdist_rpm is being used.


Stan Klein



More information about the Distutils-SIG mailing list