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", i.e. folders with an extension of "egg".
What is the difference between them that causes this different behavior?
A “Python egg” is a logical structure embodying the release of a specific version of a Python project, comprising its code, resources, and metadata. There are multiple formats that can be used to physically encode a Python egg, and others can be developed.
Wheel and Egg are both packaging formats that aim to support the use case of needing an install artifact that doesn't require building or compilation, which can be costly in testing and production workflows. The Egg format was introduced by setuptools in 2004, whereas the Wheel format was introduced by PEP 427 in 2012.
A python egg is a "a single-file importable distribution format". Which is typically a python package. You can import the package in the egg as long as you know it's name and it's in your path. You can execute a package using the "-m" option and the package name.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With