[Distutils] zip imports ftw

Barry Warsaw barry at python.org
Sun Sep 16 21:12:26 CEST 2012


On Sep 16, 2012, at 1:23 PM, Chris McDonough wrote:

> On Sun, 2012-09-16 at 08:07 -0400, Daniel Holth wrote:
>> Of course the major potentially non obvious caveats are that a lot of python code doesn't use the API to load data from the importer path, instead using __file__ and assuming everything is one, and that sometimes (shared libraries) the system can't load it unless its a real file.
> 
> This is easy to work around in brand new code using pkg_resources, so
> it's generally only a problem with older code, or code which can depend
> only on the stdlib.  Unfortunately, the stdlib doesn't have much to help
> here.  There's pkgutil.get_data but it doesn't really work well if you
> need to get a filelike handle to a resource, or you need to list the
> contents of a directory, and other things which pkg_resources does very
> nicely, so it seems like Python isn't really serious about allowing code
> in zipfiles to be a viable alternative to file-and-directory-based code.

Remind me again why pkg_resources (or an API exactly like it) isn't in the stdlib already?

-Barry



More information about the Distutils-SIG mailing list