将 python 库/应用程序打包为 .egg 文件有哪些优点?

发布于 2024-07-04 01:47:26 字数 66 浏览 10 评论 0原文

我读过一些关于 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

云归处 2024-07-11 01:47:27

对于简单的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.

殊姿 2024-07-11 01:47:27

无论您做什么,都不要停止以 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.

忱杏 2024-07-11 01:47:27

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

椵侞 2024-07-11 01:47:27

一颗鸡蛋本身并不比适当的源释放更好。 好的部分是依赖性处理。 与 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.

只为一人 2024-07-11 01:47:27

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.

柒夜笙歌凉 2024-07-11 01:47:26

来自 Python 企业应用程序工具包社区

“鸡蛋之于 Python 就像罐子之于 Java...”

Python 蛋是一种捆绑方式
Python 的附加信息
项目,这使得该项目的
要检查的依赖关系和
运行时满意,以及
允许项目提供插件
对于其他项目。 有几个
包含鸡蛋的二进制格式,但是
最常见的是“.egg”zip 文件
格式,因为它很方便
用于分发项目。 全部
格式支持包括
特定于包的数据,整个项目
元数据、C 扩展和 Python
代码。

Python Eggs 的主要好处
是:

  • 它们支持“轻松安装”Python 包管理器等工具

  • .egg 文件是 Python 的“零安装”格式
    包裹; 没有构建或安装步骤
    必需的,只需将它们放在 PYTHONPATH 中
    或 sys.path 并使用它们(可能需要
    如果 C 扩展则安装运行时
    或使用数据文件)

  • 它们可以包含包元数据,例如它们依赖的其他鸡蛋

  • 它们允许“命名空间包”(只包含其他包的包)
    包)被分成单独的
    分布(例如 zope.、twisted.
    Peak.* 包可以分发为
    与普通包装不同,单独的鸡蛋
    必须始终放在
    相同的父目录。 这允许
    现在有什么巨大的整体包
    作为单独分发
    组件。)

  • 它们允许应用程序或库指定所需的
    库的版本,以便您可以
    例如 require("Twisted-Internet>=2.0")
    在进行导入之前
    扭曲的互联网。

  • 它们是分发扩展或插件的绝佳格式
    可扩展的应用程序和框架
    (例如 Trac,它使用鸡蛋
    从 0.9b1) 开始的插件,因为 Egg
    Runtime提供了简单的API来定位
    鸡蛋并找到其广告条目
    点(类似于 Eclipse 的
    “扩展点”概念)。

  • 标准化还可能带来其他好处
    格式,类似的好处
    Java 的“jar”格式。

-亚当

From the Python Enterprise Application Kit community:

"Eggs are to Pythons as Jars are to Java..."

Python eggs are a way of bundling
additional information with a Python
project, that allows the project's
dependencies to be checked and
satisfied at runtime, as well as
allowing projects to provide plugins
for other projects. There are several
binary formats that embody eggs, but
the most common is '.egg' zipfile
format, because it's a convenient one
for distributing projects. All of the
formats support including
package-specific data, project-wide
metadata, C extensions, and Python
code.

The primary benefits of Python Eggs
are:

  • They enable tools like the "Easy Install" Python package manager

  • .egg files are a "zero installation" format for a Python
    package; no build or install step is
    required, just put them on PYTHONPATH
    or sys.path and use them (may require
    the runtime installed if C extensions
    or data files are used)

  • They can include package metadata, such as the other eggs they depend on

  • They allow "namespace packages" (packages that just contain other
    packages) to be split into separate
    distributions (e.g. zope., twisted.,
    peak.* packages can be distributed as
    separate eggs, unlike normal packages
    which must always be placed under the
    same parent directory. This allows
    what are now huge monolithic packages
    to be distributed as separate
    components.)

  • They allow applications or libraries to specify the needed
    version of a library, so that you can
    e.g. require("Twisted-Internet>=2.0")
    before doing an import
    twisted.internet.

  • They're a great format for distributing extensions or plugins to
    extensible applications and frameworks
    (such as Trac, which uses eggs for
    plugins as of 0.9b1), because the egg
    runtime provides simple APIs to locate
    eggs and find their advertised entry
    points (similar to Eclipse's
    "extension point" concept).

  • There are also other benefits that may come from having a standardized
    format, similar to the benefits of
    Java's "jar" format.

-Adam

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文