[Distutils] Determining system packages
Phillip J. Eby
pje at telecommunity.com
Fri Apr 13 20:32:44 CEST 2007
At 10:24 AM 4/13/2007 -0700, Rob wrote:
>Hi,
>
>I'm trying to determine which packages are "system" packages as
>opposed to development or regular packages for yolk[1].
>
>An example of what I mean would be wsgiref which comes included with
>Python 2.5.
>
>The closest thing I can find that would help in a pkg_resources
>Distribution object is the precedence attribute, but system and
>development seem to be the same and the precedence would only help if
>there were more than one in the environment.
>
>If I use get_python_lib from distutils.sysconfig and remove the
>trailing "site-packages" from the reult
You mean 'get_python_lib(standard_lib=1)'?
> and check a distribution'slocation attribute to see if its installed
> there, will it be reliable
>or might system packages be in other locations?
System packages are just develop eggs installed in "system"
locations. System locations may be Python-defined or OS-defined. For
example, some distros have non-standard directory layouts, such that there
is both a "/usr/lib/python2.x/site-packages" and a
"/usr/local/lib/python2.x/site-packages", and *either* could contain system
packages.
There is a trick you could use to identify "develop" distributions,
though... if there is a "SOURCES.txt" metadata file associated with an
egg, you can look for a setup.py in a parent directory whose directory
layout corresponds to that described by the contents of SOURCES.txt. This
could *potentially* produce a false positive, though, if the package in
question puts all its modules in the project root and doesn't have any
other files besides setup.py listed in the project root.
(The long-term plan for 0.7 is that packages that are actually "installed"
will have some kind of installation manifest ala PEP 262.)
By the way, under Python 2.5, packages installed by the distutils include
an .egg-info *file*, so that is a giveaway that a package was installed
using distutils (and maybe a system packaging tool), and is definitely
*not* a "develop" package.
More information about the Distutils-SIG
mailing list