在带有setup.py的简单目录上使用Python打包* .egg格式有什么好处和坏处? [英] What are the benefits and downsides of using the Python packaging *.egg format over a simple directory with setup.py?
问题描述
发布程序时,通常只创建一个setup.py并将其放在pypi上.它可以通过pip安装,我可以随时与他人轻松共享.它适用于我,显然适用于很多人.
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.
我看到了使exe,deb或rmp简化系统管理员的好处.
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.
推荐答案
鸡蛋绑定到特定的体系结构和python版本,直到Python 3.3,如果egg包含C扩展名,甚至是内部Unicode表示大小(UCS2与. UCS4).
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).
不幸的是,后者的差异未在鸡蛋元数据中捕获; egg文件名包含体系结构和python版本(major.minor,因此为2.4或3.1),但省略了unicode字节大小.
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.
因此,鸡蛋不是很容易携带.另一方面,.tgz
或.zip
发行版与平台无关(希望如此).您的安装工具(无论是easy_install
,pip
,buildout
还是其他工具)都知道如何为您将python软件包分发编译为鸡蛋,因此通常避免分发.egg
文件.
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.
唯一的例外是Windows,大多数人将缺少编译C扩展的工具链.由于Python的Windows发行版默认为UCS2,因此通常可以安全地分发带有C扩展名的Windows .egg
内置软件包,以方便通过自动化工具进行安装.
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.
如果使用setup.py
脚本创建发行版,则创建仅源程序包以上传到PyPI并不容易.我可以推荐 Python打包用户指南以获取更多信息.
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.
这篇关于在带有setup.py的简单目录上使用Python打包* .egg格式有什么好处和坏处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!