[Distutils] zip imports ftw

Daniel Holth dholth at gmail.com
Sun Sep 16 19:41:07 CEST 2012


> 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.

I got the impression that killing zip imports is an explicit goal of
packaging. This is sure to be a contentious issue.

To all the haters, let me say that no one is going to make you import
code from a zip if you don't want to. That easy_install mistake will
not be repeated. However, those of us who like importing from places
other than the filesystem should be able to enjoy continually
improving support for doing so. Also, remember that thing about the
debugger not showing the source code for zipped code? Fixed.


More information about the Distutils-SIG mailing list