Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between an 'sdist' .tar.gz distribution and an python egg?

Tags:

python

egg

sdist

I am a bit confused. There seem to be two different kind of Python packages, source distributions (setup.py sdist) and egg distributions (setup.py bdist_egg).

Both seem to be just archives with the same data, the python source files. One difference is that pip, the most recommended package manager, is not able to install eggs.

What is the difference between the two and what is 'the' way to do distribute my packages?

(Note, I am not wanting to distribute my packages through PyPI, but I want to use a package manager that fetches my dependencies from PyPI)

like image 221
Peter Smit Avatar asked Jun 09 '11 12:06

Peter Smit


People also ask

What is Sdist python?

Python Source Distributions A source distribution, or more commonly sdist, is a distribution that contains all of the python source code (i.e. . py files), any data files that the library requires, and a setup.py file which describes to the setuptools module how your python code should be packaged.

What is the python egg?

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.

What is a Bdist?

bdist is a "binary distribution". For a pure Python project, those things are pretty close. If your project includes any extension modules, though, the sdist includes the source for those extension modules and use of the sdist will require a compiler.

How do I make a python egg file?

Egg files are just zip files so you might be able to add __main__.py to your egg with a zip tool and make it executable in python 2.6 and run it like python myapp. egg instead of the above incantation where the PYTHONPATH environment variable is set.


1 Answers

setup.py sdist creates a source distribution: it contains setup.py, the source files of your module/script (.py files or .c/.cpp for binary modules), your data files, etc. The result is an archive that can then be used to recompile everything on any platform.

setup.py bdist (and bdist_*) creates a built distribution: it includes .pyc files, .so/.dll/.dylib for binary modules, .exe if using py2exe on Windows, your data files... but no setup.py. The result is an archive that is specific to a platform (for example linux-x86_64) and to a version of Python, and that can be installed simply by extracting it into the root of your filesystem (executables are in /usr/bin (or equivalent), data files in /usr/share, modules in /usr/lib/pythonX.X/site-packages/...). You can even build rpm archives that can be directly installed using your package manager.

like image 125
Schnouki Avatar answered Sep 17 '22 04:09

Schnouki