Can I create a single egg for multiple versions of python?
Asked Answered
C

1

4

We have a local system which runs via a series of eggs. At the moment this means everyone must have a copy of Python 2.5 installed. Is it possible to create an egg which can be used by Python 2.5, 2.6, and 2.7 (ideally also any later versions)?

Obviously, the python code will have to run under all three versions. Equally obviously, this egg can't contain any C extensions. Slightly less obviously, the egg must contain the python source (.py) files, and not the .pyc files.

Also, I know we could create three eggs (or possibly copy the one egg with three names) - but that seems wrong.

Carping answered 26/5, 2011 at 10:13 Comment(5)
Your package contains Python-only code or also C extensions?Allina
"but that seems wrong" Why? It's much simpler to have Python version-specific eggs. It makes audit and confirmation of a correct environment so much easier.Guitarist
You don't need version specific eggs for Python-only packagesAllina
Our package is Python-only code.Carping
Why do multiple eggs make audit and confirmation of a correct environment easier?Carping
B
2

Distribute the source tarball only; easy-install (or pip or buildout, or whatever package dependency manager / installer you use) will create an egg for you for the python version used to install it.

You only ever need to create eggs for distribution only for packages with C-extensions, and then only for Windows because most Windows system lack the tools needed to build the egg themselves.

Take a look at PyPI to see many examples of this, like the zope.interface page. Note that there are only .egg distributions there for python versions 2.4, 2.5 and 2.6 for Windows. Everything else just uses the .tar.gz tarball download and builds the .egg locally as needed.

You build a source tarball using the setup.py sdist command. Personally, I use jarn.mkrelease; it automates much of the process for you (like uploading the source distribution to a distribution server).

Bailiff answered 3/6, 2011 at 10:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.