[Distutils] pkg_resources get_distribution - zipfile support?

PJ Eby pje at telecommunity.com
Tue Oct 1 22:32:26 CEST 2013


On Tue, Oct 1, 2013 at 1:51 PM, Daniel Holth <dholth at gmail.com> wrote:
> pkg_resources only finds distributions inside .egg and inside sys.path
> entries that are filesystem directories.

Actually it looks in zipfiles (or subdirectory paths thereof) or
filesystem directories, and can spot zipfile subdirectories named
'.egg' inside zipfiles (or subdirectories thereof).

It will also look in any other sort of sys.path entry, if you register
a handler for the importer type.

> You might be able to manually
> add a new Distribution instance to working_set or start looking for a
> place to add the feature here:
>
> https://bitbucket.org/pypa/setuptools/src/27df3c725f9696ba730456f3f444cc2fb5271d4b/pkg_resources.py?at=default#cl-2560
>
> _distributionImpl = {
>     '.egg': Distribution,
>     '.egg-info': Distribution,
>     '.dist-info': DistInfoDistribution,
>     }
>
> https://bitbucket.org/pypa/setuptools/src/27df3c725f9696ba730456f3f444cc2fb5271d4b/pkg_resources.py?at=default#cl-2219
>
> (Distribution.from_location())

Actually, you would add the feature *here*:

https://bitbucket.org/pypa/setuptools/src/27df3c725f9696ba730456f3f444cc2fb5271d4b/pkg_resources.py?at=default#cl-1810

That is, in the find_in_zip() function, which is used to identify
distributions contained in zip files (or subdirectories thereof) on
sys.path.

(This feature needs to get added at some point anyway, for
pkg_resources to support mountable wheels.)


More information about the Distutils-SIG mailing list