I maintain a few Python packages. I have a very similar setup.py file for each of them. However, when doing setup.py install, one of my packages gets installed as an egg, while the others get installed as "egg folders开发者_如何学JAVA", i.e. folders with an extension of "egg".
What is the difference between them that causes this different behavior?
The Internal Structure of Python Eggs, Zip Support Metadata :
If
zip-safeexists, it means that the project will work properly when installed as an.eggzipfile, and conversely the existence ofnot-zip-safemeans the project should not be installed as an.eggfile [ie. as an.eggdirectory]. Thezip_safeoption 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.
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.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论