[Distutils] zip imports ftw

Daniel Holth dholth at gmail.com
Mon Sep 17 16:47:58 CEST 2012


On Mon, Sep 17, 2012 at 10:38 AM, Barry Warsaw <barry at python.org> wrote:
> On Sep 16, 2012, at 03:40 PM, Chris McDonough wrote:
>
>>On Sun, 2012-09-16 at 15:33 -0400, Daniel Holth wrote:
>>> It is because the file has a controversial coding style, with up to 25
>>> lines of whitespace between classes, and includes functionality for
>>> eggs and some other stuff that was unwanted on top of the resources
>>> stuff that partly made its way into pkgutil.
>>
>>I think maybe there's also a latent notion floating around that "a
>>resource (aka non-Python files) shouldn't be addressable within Python
>>packages" aka. "Python should only make it easy to address Python files
>>in Python packages, but no other kind of file".  I'm not sure I've ever
>>seen any of the core dev team express this opinion, but I've seen it
>>floating around elsewhere.
>
> Yeah.  Personally, I think that's just silly.  It's way, way, way too
> convenient to put some data files in your packages, and with pkg_resources,
> there's actually a principled way to do that consistently regardless of
> whether you're running from source or installed.  I'm not even sure *not*
> putting your data files in your packages has any kind of common systematic
> support in Python.
>
> OTOH, it's definitely true that data files that people have to edit
> (e.g. configuration files) shouldn't live in your packages.  That's just an
> invitation to violate all kinds of standards (he says, painfully aware of
> Mailman 2's mm_cfg.py file ;).
>
> -Barry

I don't think pkg_resources's much better version of pkgutil.get_data
is seriously under dispute.

What's really missing in action is a better api than
zipimport._zip_directory_cache to list everything on the importer
path, not just the modules.

distutils2 does try to add some support for 'data files not on sys.path'

Bento will write, on request only, a Python file with the root paths
used during installation. You get to choose the name. Something like:

yourpackage/__config.py:

SCRIPTS='/path/to/scripts'

I think this is a better idea than .dist-info/RESOURCES being a file
with original-path -> installed-path  for every file in the
distribution.


More information about the Distutils-SIG mailing list