[Distutils] Why are egg-info and related pth files required for rpm packages?

Phillip J. Eby pje at telecommunity.com
Tue Sep 4 22:04:36 CEST 2007


At 12:39 PM 9/4/2007 -0400, Stanley A. Klein wrote:
>I recently installed Fedora 7 and looked at
>/usr/lib/python2.5/site-packages.  The directory has numerous Python
>packages installed but no egg-info and few .pth files.  Of the three .pth
>files in my installation, only one has a content different from the name
>of the package (pointing to a subdirectory of site-packages with a
>different name).
>
>Setuptools has the advantage of simplifying preparation of rpms because it
>has find_packages().  However, it produces egg-info and .pth files as part
>of the rpm's.
>
>I can understand the need for these files when packaging into eggs for
>installation in places other than python/site-packages or when packaging
>for non-Linux operating systems.  But why are they needed when installing
>as rpms on Linux systems into site-packages?
>
>I think this issue applies to most Linux packaging, which is usually
>either rpm or deb.

The .egg-info files or directories are required in order to contain 
project-level metadata.  Without them, the fact that the packages are 
installed can't be detected in a cross-platform way, and other 
projects *simply won't function without them*.  For example, Chandler 
i18n support is provided via the contents of .egg-info, as is plugin 
registration.  A wide range of plugin-supporting libraries and tools 
absolutely require .egg-info, including TurboGears, Buffet, Trac, 
Chandler and setuptools itself.  Setuptools can't even build itself 
unless its own .egg-info is present!

So .egg-info is absolutely indispensable, regardless of installation method.

As for .pth files, the only .pth files that should be generated by 
setuptools are the ones needed to support namespace packages.  When 
you have multiple projects spanning a namespace package, each of 
those projects would contain "somepackage/__init__.py" in its naive 
layout.  But this would cause conflicts between the RPMs, so 
setuptools uses uniquely-named .pth files to work around the absence 
of an __init__.py.  So, these "Project-version-nspkg.pth" files are 
also indispensable, as the packages involved won't be importable without them.

However, the .pth files you described don't sound like ones generated 
by setuptools.

Note, by the way, that as of Python 2.5, *all* distutils-generated 
packages include .egg-info; they just use a single file instead of a 
directory.  This makes it easy to detect what Python packages are 
installed on a system, as long as the platform maintainers don't 
remove this file.



More information about the Distutils-SIG mailing list