Zip imports on python 2.2?

Alex Martelli aleax at aleax.it
Thu Jun 12 05:13:10 EDT 2003


<posted & mailed>

Beni Cherniavsky wrote:

> I have a university shell account with 10MB quota (most of it filled
> by mail).  At last they've installed python 2.2 (they forgot curses,
> sockets and some other nice modules but never mind ;).  Now I'm
> installing some modules, notably docutils, under my home directory and
> it takes even more of my quota...
> 
> Is there some pure-python way to use zip imports in Python 2.2 so I
> can save space by compressing the installed modules?

You might kludge something up by using your site.py (or the like) to
substitute a customized __import__ wrapping the normal built-in one --
your customized __import__ might look into the relevant zipfiles'
directories, extract the needed modules into some /tmp subdirectory
suitably created and inserted in your sys.path, then delegate to the
real-builtin __import__.  There are cleaner ways but you may not need
generality enough -- perhaps this kludge, perfected experimentally
for your specific and rather peculiar needs, might suffice.


Alex
 





More information about the Python-list mailing list