Python: Why do some packages get installed as eggs and some as "egg folders"?
A single egg file is in fact a zip archive with a particular directory structure inside. Per the zipimport documentation, only .py
, .pyc
, and .pyo
files can be imported from zip files. So, if the package needs to import other kinds of module resources (like compiled c code; .so
files, .pyd
files) it won't work as a zip file.
I don't know if this is the only reason that some eggs won't work as zip archives, but I think it is the main reason.
The Internal Structure of Python Eggs, Zip Support Metadata :
If
zip-safe
exists, it means that the project will work properly when installed as an.egg
zipfile, and conversely the existence ofnot-zip-safe
means the project should not be installed as an.egg
file [ie. as an.egg
directory]. Thezip_safe
option to setuptools'setup()
determines which file will be written. If the option isn't provided, setuptools attempts to make its own assessment of whether the package can work, based on code and content analysis.