import a module from an archive ?

Christian Tismer tismer at stackless.com
Mon Mar 29 09:19:24 EST 2004


vincent Salaun wrote:

> hi all,
> 
> i'd like to know if it's possible to import a module from an archive 
> (zip, rar, tar, jar, ...)
> I've tried using different formats but it still doesn't work .....
> 
> i make:
>    >>>sys.path.append('d:/myModules.zip')
>    >>>import aModuleFromTheArchive
> 
> is there a way to do that ?
> the problem is that i've embed a python interpreter in our java app and 
> our scripts need some standard modules from python and jython but the 2 
> 'Lib' directories of python and jython are a bit heavy : 8Mb ....

This has started with PEP 273, and was implemented after PEP 302,
see http://www.python.org/peps/pep-0302.html

See also the module zipfile.

And here is how to do it:

http://www.python.org/doc/current/whatsnew/node5.html

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer at stackless.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  mobile +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/





More information about the Python-list mailing list