[Distutils] pkg_resources.find_distributions("./")
Phillip J. Eby
pje at telecommunity.com
Fri Feb 10 21:33:54 CET 2006
At 09:20 PM 2/10/2006 +0100, Elvelind Grandin wrote:
>I'm using pkg_resources.find_distributions("./") to find out the name
>off the distrubution in the current dir. Is there any reason this
>shouldn't work?
Yes, several. :) find_distributions() by default finds *all*
distributions in the directory, and there is no guaranteed order to the
results.
Even if you pass the 'only' flag to tell it to just find distributions
whose 'location' would be the same directory, you can *still* have more
than one result in the case of system-packaged
(--single-version-externally-managed) eggs, as they all end up in the same
directory.
> It works for me but apperently some others have
>problems with it.
There is no reliable way to tell what distribution you are in, if all you
have is the directory name. If you have a *module* name, however, you can
use get_provider(modulename).get_metadata('PKG-INFO') to retrieve the
package's PKG-INFO text, which you can then use to find the distribution
name and version.
More information about the Distutils-SIG
mailing list