A Python Egg is a distribution format for Python projects. It is essentially a zip-compressed archive that contains all the necessary files for a Python package, making it easier to distribute and install. Python Eggs were popularized by the setuptools library and were used prior to the advent of wheels (.whl files), which are now the more common format.
Key Features of Python Eggs:
Components: An egg file contains:
The Python code for the package.
Metadata about the package, such as its name, version, dependencies, etc.
Additional resources like data files and compiled extensions.
File Extension: Egg files typically have the .egg extension.
Compatibility: Eggs can be used with various Python versions and platforms, but they are less flexible than wheels.
Installation: Eggs can be installed using easy_install (from setuptools) or directly used without installation by placing them in the PYTHONPATH.
Example Egg Structure:
A Python Egg might look like this when unzipped:
markdown
Copy code
mypackage.egg/
├── EGG-INFO/
│ ├── PKG-INFO
│ ├── dependency_links.txt
│ ├── entry_points.txt
│ └── top_level.txt
├── mypackage/
│ ├── __init__.py
│ ├── module1.py
│ └── module2.py
Example of Creating an Egg:
Write your Python project and include a setup.py file.
Use setuptools to create an egg:
bash
Copy code
python setup.py bdist_egg
Current Usage:
While Python Eggs were widely used in the past, they have largely been replaced by wheels (.whl), which offer better compatibility and are the standard format used by tools like pip. However, some older projects may still use Eggs.