对python源文件打包有哪些优缺点_在带有setup.py的简单目录上使用Python打包* .egg格式有什么好处和坏处?...

1586010002-jmsa.png

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.

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.

解决方案

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

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.

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.

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.

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值