Retrieval of python PKG-INFO data for installed packages

Hello, is it possible to retrieve the same info which is stored in PKG-INFO for an installed package? I've seen this project: http://pypi.python.org/pypi/pkginfo doesn't anything built in setuptools/distribute/pkg_resources achieve a similar result? e.g., while in a lib, I'd like to do something like: import mymodule get_pkg_info(mymodule).project_name ? -- Alan Franzoni -- contact me at public@[mysurname].eu

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 11/17/2010 12:18 PM, Alan Franzoni wrote:
Hello, is it possible to retrieve the same info which is stored in PKG-INFO for an installed package?
I've seen this project: http://pypi.python.org/pypi/pkginfo
doesn't anything built in setuptools/distribute/pkg_resources achieve a similar result?
pkginfo is aimed at parsing the PKG-INFO file for *any* kind of package: - - Source distribution (created via 'setup.py sdist') - - BInary distributions (created via 'setup.py bdist_egg', maybe others) - - Installed packages (works only if the 'PKG-INFO' file is created in the "right place" under / next to the package, e.g., via setuptools, distribute, or Python >= 2.6). - - "Develop" packages (installed via 'setup.py develop', therefore only with setuptools / distribute support), You query it via either the path to a distribution, the name of a package, or the installed package itself:
from pkginfo import get_metadata get_metadata('path/to/tarball.gz') <pkginfo.sdist.SDist object at 0x97f072c> import wsgiref get_metadata(wsgiref) <pkginfo.installed.Installed object at 0x97c75cc> _.name u'wsgiref'
The package provides a same-named shell script for doing those queries at the command line: $ ../../bin/pkginfo docs/examples/mypackage-0.1.tar.gz metadata_version: 1.0 name: mypackage version: 0.1 platforms: [u'UNKNOWN'] home_page: http://pypi.python.org/pypi/pkginfo author: Tres Seaver author_email: tseaver@palladion.comginfo] $ ../../bin/pkginfo wsgiref metadata_version: 1.0 name: wsgiref version: 0.1.2 platforms: [u'UNKNOWN'] summary: WSGI (PEP 333) Reference Library author: Phillip J. Eby author_email: web-sig@python.org license: PSF or ZPL Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkzkSYcACgkQ+gerLs4ltQ66RQCgrRMTO4gFvitIqd3nm6TUZXTx d5UAn1q7l7keTrs6+yYSe3BTG87cvxY3 =IuFu -----END PGP SIGNATURE-----
participants (2)
-
Alan Franzoni
-
Tres Seaver