Suppose I have a binary string containing a Python egg, all archived. Is there any way to execute and "import" this egg from memory without writing it to disk?
Some time ago I looked at pypiserver and could be something similar to what you need: http://pypi.python.org/pypi/pypiserver/0.5.0
Standalone version https://raw.github.com/schmir/pypiserver/standalone/pypi-server-standalone.py
does interesting magic with DictImporter and the zlib library, maybe you can do something like this.
- zip , zipimport.zipimporter, ( ) , C.
zipimport.zipimporter
, :
file
, , .
imp: http://docs.python.org/library/imp.html
imp
, - .
( , ):
http://code.activestate.com/recipes/82234-importing-a-dynamically-generated-module/
, .
The question is similar to the one asked a while ago: Python imports a line of Python code as a module
I am not familiar with Python eggs, but try using a StringIO object . Since Python uses duck typing , you can treat it the same way as a file if you do not invoke any specific file methods on it.