The Python Oracle

What is a Python egg?

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------


Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT


Music by Eric Matyas
https://www.soundimage.org
Track title: Over a Mysterious Island Looping

--

Chapters
00:00 What Is A Python Egg?
00:19 Accepted Answer Score 620
01:24 Answer 2 Score 146
02:38 Answer 3 Score 6
02:59 Answer 4 Score 42
04:14 Thank you

--

Full question
https://stackoverflow.com/questions/2051...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #package #egg

#avk47



ACCEPTED ANSWER

Score 620


Note: Egg packaging has been superseded by Wheel packaging.

Same concept as a .jar file in Java, it is a .zip file with some metadata files renamed .egg, for distributing code as bundles.

Specifically: The Internal Structure of Python Eggs

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. However, a key principle of Python eggs is that they should be discoverable and importable. That is, it should be possible for a Python application to easily and efficiently find out what eggs are present on a system, and to ensure that the desired eggs' contents are importable.

The .egg format is well-suited to distribution and the easy uninstallation or upgrades of code, since the project is essentially self-contained within a single directory or file, unmingled with any other projects' code or resources. It also makes it possible to have multiple versions of a project simultaneously installed, such that individual programs can select the versions they wish to use.




ANSWER 2

Score 146


The .egg file is a distribution format for Python packages. It’s just an alternative to a source code distribution or Windows exe. But note that for pure Python, the .egg file is completely cross-platform.

The .egg file itself is essentially a .zip file. If you change the extension to “zip”, you can see that it will have folders inside the archive.

Also, if you have an .egg file, you can install it as a package using easy_install

Example: To create an .egg file for a directory say mymath which itself may have several python scripts, do the following step:

# setup.py
from setuptools import setup, find_packages
setup(
    name = "mymath",
    version = "0.1",
    packages = find_packages()
    )

Then, from the terminal do:

 $ python setup.py bdist_egg

This will generate lot of outputs, but when it’s completed you’ll see that you have three new folders: build, dist, and mymath.egg-info. The only folder that we care about is the dist folder where you'll find your .egg file, mymath-0.1-py3.5.egg with your default python (installation) version number(mine here: 3.5)

Source: Python library blog




ANSWER 3

Score 42


Disclaimer: egg is an abandoned format of python package, the tools to use eggs no longer exist.

An egg is a python package. It's a zip archive containing python source files and/or compiled libraries.

The format is not well specified about what it must contain or how to make packages for different versions of python and different operating systems, that's one of the reasons it was replaced.

The format appeared around 2004 and was in-use until the mid 2010s, it's been completely replaced by wheels and pip install.

Eggs were installed by the command easy_install. The command was removed in setuptools v58.3 (year 2021). You can no longer use eggs.

If you see anything that mentions easy_install or egg, be it any stack overflow answers or tutorials, it is seriously obsolete.

Recommend this longer answer https://stackoverflow.com/a/68897551/5994461 for an in-depth history of python packaging. It's going over pip and wheels and eggs and much more.

Update: As of July 2023 the official python package repository pypi.org no longer accepts upload of .egg packages.




ANSWER 4

Score 6


"Egg" is a single-file importable distribution format for Python-related projects.

"The Quick Guide to Python Eggs" notes that "Eggs are to Pythons as Jars are to Java..."

Eggs actually are richer than jars; they hold interesting metadata such as licensing details, release dependencies, etc.