[Distutils] distlib updated with resources API
Daniel Holth
dholth at gmail.com
Thu Sep 27 14:39:01 CEST 2012
What you can do with pkgutil is call
pkgutil.iter_importer_modules.register(importer, function) so that
your new importer works with iter_modules. Unfortunately even though
it implements most of what you would need to listdir() a zip file,
using zipimport._zip_directory_cache[], it does not expose the
functionality.
https://bitbucket.org/dholth/cpython/src/b534ce119c3c/Lib/pkgutil.py#cl-357
For this particular resources feature you could probably rename Egg to
Dist as far as the pkg_resources code goes, there is barely anything
in the EggProvider class.
Make sure you have a test where the package is not in the root of the .zip file
foo.zip/site-packages/bar.py
Speaking of old code, does anyone feel like replacing
# @decorator
def fn(): ...
fn = decorator(fn)
with the probably-ok-to-use-by-now decorator syntax?
Daniel
More information about the Distutils-SIG
mailing list