What are the benefits and downsides of using the Python packaging *.egg format over a simple directory with setup.py?

StackOverflow https://stackoverflow.com/questions/12278091

  •  30-06-2021
  •  | 
  •  

Question

When I release a program, I usually just create a setup.py and put it on pypi. It's installable with pip, I can always share it easily with others. It works for me, and apparently for a lot of people.

I see the benefit of making an exe, a deb or a rmp to easy sysadmin.

But I really don't see the point of using eggs. Can you tell me what can I gain from it ?

I also once read that eggs had downsides, but I can't find the article anymore. Could you describe to me what problems using this packaging format can cause ?

Please note that I did saw this question, but the answer is also applicable to a simple directory with setup.py. It doesn't tell me the benefits of eggs over the simpler format.

Était-ce utile?

La solution

Eggs are tied to a specific architecture and python version, and until Python 3.3, if the egg contains C extensions, even the internal Unicode representation size (UCS2 vs. UCS4).

Unfortunately, the latter difference is not captured in the egg metadata; an egg filename contains the architecture and the python version (major.minor, so 2.4 or 3.1) but the unicode byte size is omitted.

Because of this, eggs are not very portable. A .tgz or .zip distribution on the other hand, is (hopefully) platform agnostic. Your installation tool, be it easy_install, pip, buildout or whatever, knows how to compile a python package distribution into an egg for you, so you generally avoid distributing the .egg files altogether.

The only exception is Windows, where most people will be lacking the toolchain to compile C extensions. As Windows distributions of Python default to UCS2, you are usually safe to distribute Windows .egg builds of packages with C extensions, to facilitate installation by automated tools.

If you use the setup.py script to create the distribution, it's trivial to create a source-only package for upload to PyPI. I can recommend the Python Packaging User Guide for more information.

Autres conseils

*.egg is a pure deployment format that is used after having a package installed through easy_install or pip.

Is does not make sense uploading files as .egg to PyPI. People doing this have no idea what they are doing.

A proper PyPI release is either a .tar.gz archive, or a .zip archive or .exe file (for Windows binaries e.g.) but NEVER EVER a *.egg file.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top