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

眉间皱痕 提交于 2019-12-10 16:59:17

问题


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.


回答1:


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).



来源:https://stackoverflow.com/questions/6136930/can-i-create-a-single-egg-for-multiple-versions-of-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!