将 python 库/应用程序打包为 .egg 文件有哪些优点?
我读过一些关于 .egg 文件的内容,并且在我的 lib 目录中注意到它们,但是作为开发人员使用它们有什么优点/缺点?
I've read some about .egg files and I've noticed them in my lib directory but what are the advantages/disadvantages of using then as a developer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
对于简单的Python程序,你可能不需要使用eggs。 分发原始 .py 文件就足够了; 这就像分发 GNU/Linux 的源文件一样。 您还可以使用各种操作系统“打包程序”(如 py2exe 或 py2app)为不同操作系统创建 .exe、.dmg 或其他文件。
更复杂的程序,例如 Django,由于需要各种模块和依赖项,因此几乎需要 Egg。
For simple Python programs, you probably don't need to use eggs. Distributing the raw .py files should suffice; it's like distributing source files for GNU/Linux. You can also use the various OS "packagers" (like py2exe or py2app) to create .exe, .dmg, or other files for different operating systems.
More complex programs, e.g. Django, pretty much require eggs due to the various modules and dependencies required.
无论您做什么,都不要停止以 tarball 的形式分发您的应用程序,因为对于具有软件包系统的操作系统来说,这是最简单的可打包格式。
Whatever you do, do not stop distributing your application, also, as a tarball, as that is the easiest packagable format for operating systems with a package sysetem.
.egg 文件基本上是部署 Python 应用程序的好方法。 您可以将其视为 Java 的 .jar 文件。
更多信息请参见此处。
.egg files are basically a nice way to deploy your python application. You can think of it as something like .jar files for Java.
More info here.
一颗鸡蛋本身并不比适当的源释放更好。 好的部分是依赖性处理。 与 debian 或 rpm 软件包一样,您可以说您依赖于其他 Egg,它们将自动安装(通过 pypi.python.org< /a>)。
第二条评论:egg格式本身就是一种二进制打包格式。 仅包含 python 代码的普通 python 包最好作为“源版本”分发,因此“python setup.py sdist”会生成 .tar.gz。 当上传到 pypi 时,这些通常也称为“鸡蛋”。
需要二进制 Egg 的地方:当您捆绑一些 C 代码扩展时。 然后,您将需要几个二进制 Egg(一个 32 位 Unix 的、一个 Windows 的等等)。
One egg by itself is not better than a proper source release. The good part is the dependency handling. Like debian or rpm packages, you can say you depend on other eggs and they'll be installed automatically (through pypi.python.org).
A second comment: the egg format itself is a binary packaged format. Normal python packages that consist of just python code are best distributed as "source releases", so "python setup.py sdist" which result in a .tar.gz. These are also commonly called "eggs" when uploaded to pypi.
Where you need binary eggs: when you're bundling some C code extension. You'll need several binary eggs (a 32bit unix one, a windows one, etc.) then.
Eggs 是分发 Python 应用程序的一个非常好的方法。 将其视为独立于平台的 .deb 文件,它将安装所有依赖项等。 优点是最终用户易于使用。 缺点是将应用程序打包为 .egg 文件可能很麻烦。
除了 .eggs 之外,您还应该提供替代安装方式。 有些人不喜欢使用 Egg,因为他们不喜欢软件程序安装它想要的任何软件的想法。 这些通常是系统管理员类型。
Eggs are a pretty good way to distribute python apps. Think of it as a platform independent .deb file that will install all dependencies and whatnot. The advantage is that it's easy to use for the end user. The disadvantage are that it can be cumbersome to package your app up as a .egg file.
You should also offer an alternative means of installation in addition to .eggs. There are some people who don't like using eggs because they don't like the idea of a software program installing whatever software it wants. These usually tend to be sysadmin types.
来自 Python 企业应用程序工具包社区:
-亚当
From the Python Enterprise Application Kit community:
-Adam