At 04:08 PM 1/9/2009 -0600, ray terrill wrote:
Is there a way to ask distutils what version of a package is
currently installed? I provided the version number when creating my
setup.py, but when this is deployed over 800+ clients, I'd like to
have a way to interrogate the system to determine which version is installed.
Distutils has no way to do this, but setuptools does. You can get
the version number of "SomePackage" using:
pkg_resources.require("SomePackage")[0].version
Note that "SomePackage" is the name of the *project* (i.e., what its
PyPI name and distribution filename are based on), not an individual
Python module or package or __version__ string within that package.
Also, for this API call to work, "SomePackage" must have been
installed by setuptools, or by Python 2.5's distutils (which installs
the metadata setuptools uses for version detection).
(You can consult the pkg_resources and setuptools documentation for
more details on these matters.)
_______________________________________________
Distutils-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/distutils-sig