P.J. Eby wrote:
I'm trying to write a scanner than looks for SQLAlchemy table objects
and it would be great to be able to pass a distribution name rather
than a set of dotted package names...
get_distribution('projectname').get_metadata('top_level.txt').splitlines()
will return you a list of top-level package or module names provided by
the package.
Ah, okay. I assume this will only work for packages that use setuptools?
Subpackages you'll have to find yourself; the pkgutil module in 2.5+ has
a walk_packages() that might be helpful.
(Note that if there are packages installed in "flat" form (e.g.
pip-installed or system-installed), you may see overlapping packages in
the same directory, so simply walking packages in a distribution
object's base directory may include packages and modules from another
project.)
I assume this is only a problem for namespace packages?
(ie: if so packages each supply part of a namespace, they will both have
the namespace listed in top_level.txt, right?)
How do static resources returned with pkg_resources.resource_filename
and friends fare when packages are installed in a "flat" form?
Chris
--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
_______________________________________________
Distutils-SIG maillist - Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig