Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does easy_install extract some python eggs and not others?

Tags:

python

egg

Looking in my /usr/local/lib/python.../dist-package directory, I have .egg directories and .egg files.

Why does the installer choose to extra packages to the .egg directory, yet leave other files with .egg extensions?

like image 984
cmcginty Avatar asked Apr 09 '10 01:04

cmcginty


People also ask

How do you install a python egg?

In order to be able to install eggs you simply need to install easy_install which is easily done by downloading ez_install.py (you can download it here) and calling it (you need to have rights to install components in your python installation of course). and it will download and install the most recent version.

What is egg and wheel in python?

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.

How do python eggs work?

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.


2 Answers

If the package contains only pure-Python code, it can stay as just an egg file. The Python interpreter can load the Python modules directly from the egg. If the package contains modules written in C or other data, then egg needs to be extracted so the C modules and/or data can be accessed. That's the default behavior of packages, I believe. Newer versions of Python might be able to load C modules from egg files; I'm not sure about that part.

The creator of the package can also specifically instruct the installer to unzip the package, by passing zip_safe = False to setup() in their setup.py.

Finally, the person doing the installing can tell easy_install explicitly to unpack eggs by passing it the -Z option or by setting zip_ok = False in the pydistutils.cfg.

like image 87
Daniel Stutzbach Avatar answered Oct 23 '22 00:10

Daniel Stutzbach


I can't explain why some eggs are zipped (the files) and some are directories, but I can offer this: if you hate zipped eggs (like I do) put this in the [easy_install] section of your ~/.pydistutils.cfg:

zip_ok = false
like image 31
jemfinch Avatar answered Oct 23 '22 00:10

jemfinch