我可以为多个版本的Python创建一个egg吗?
我们有一个通过一系列鸡蛋运行的本地系统。目前,这意味着每个人都必须安装 Python 2.5 的副本。是否可以创建一个可由 Python 2.5、2.6 和 2.7(最好也可以是任何更高版本)使用的 Egg?
显然,Python 代码必须在所有三个版本下运行。同样明显的是,这个鸡蛋不能包含任何 C 扩展。不太明显的是,egg 必须包含 python 源 (.py) 文件,而不是 .pyc 文件。
另外,我知道我们可以创建三个鸡蛋(或者可能复制一个具有三个名称的鸡蛋) - 但这似乎是错误的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅分发源 tarball; easy-install(或 pip 或 buildout,或您使用的任何包依赖管理器/安装程序)将为您创建一个用于安装它的 python 版本的 Egg。
您只需要创建 Egg 来分发带有 C 扩展名的软件包,然后只针对 Windows,因为大多数 Windows 系统缺乏构建 Egg 本身所需的工具。
查看 PyPI 可以看到许多这样的示例,例如 zope.interface 页面。请注意,Windows 下的 python 版本 2.4、2.5 和 2.6 仅有 .egg 发行版。其他一切都只是使用
.tar.gz
tarball 下载并根据需要在本地构建.egg
。您可以使用 setup.py sdist 命令构建源 tarball。就我个人而言,我使用 jarn.mkrelease;它会为您自动执行大部分过程(例如将源分发版上传到分发服务器)。
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).