setuptools、distribution 和 pip 之间如何相互关联?

发布于 2024-12-21 15:59:38 字数 267 浏览 6 评论 0原文

我一直在通过《Learn Python The Hard Way》(第二版)一书自学 Python。在练习 46 中,它告诉我阅读 Pip、Distribute 和其他一些软件包。

pip 的文档足够清楚了。它允许我安装/卸载和升级软件包。阅读 Distribution 的文档,它基本上似乎做了同样的事情:

轻松下载、构建、安装、升级和卸载 Python 包

pip 和 Distribution 之间有什么区别,它们之间有何关系?

I've been teaching myself Python through the book "Learn Python The Hard Way" (2nd Edition). In exercise 46 it told me to read up on Pip, Distribute, and a few other packages.

The documentation for pip was clear enough. It allows me to install/uninstall, and upgrade packages. Reading the documentation for distribute, it basically seems to do the same thing:

Easily download, build, install, upgrade, and uninstall Python packages

What's the difference between pip and distribute, and how do they relate to one another?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

他是夢罘是命 2024-12-28 15:59:38

[2014-10 TL;DR:
distribute 已死,请使用 pip、新的 setuptools,对于二进制发行版,请使用 wheels。更多内容如下。]


[原始答案]

分发 是< /del> 是旧版 setuptools 的一个分支,因此几乎所有后续评论都同样适用于 Distribute 和设置工具。 setuptools 试图填补更旧的 Python 标准库包 Distutils 中的许多漏洞。 Setuptools 添加了一些功能,例如通过命令行界面自动下载软件包、easy_install 以及某种程度的依赖管理。然而,Python 社区的一部分人认为 setuptools 的侵入性太大,并且其某些功能有太多的幕后魔力。

pip 是 setuptools 或 Distribute 之上的更高级别接口。它使用它们来执行许多功能,但避免了一些更有争议的功能,例如拉链鸡蛋。 pip 还提供了 setuptools 中不可用的功能,例如卸载命令以及定义固定要求集和可靠地重现一组包的能力。 此处有更完整的功能比较。

为什么有这么多组件(还有更多,例如 buildout)?原因有很多:解决方案必须适用于支持 Python 的所有主要平台(即 Unix-y、Windows、Mac OS X),因此构建和安装会带来一系列复杂问题;与许多开源项目一样,Python 本质上是全志愿者的,许多开发人员只是对打包和安装问题不太感兴趣;在向标准库添加未经证实的主要新功能方面存在着天然的保守主义; 。

目前,有一个项目正在进行中,旨在提供 Distutils 的替代品,并可能为一些更高级别的附加组件提供替代品 计划在 Python 3.3 标准库中作为 packaging 包并作为旧版本 Python 的附加组件 Distutils2

总而言之,当前的关系是:

pip -> [ setuptools | Distribute ] -> Distutils -> Python core
                                    |
    3rd party packages              |      included in Python
                                    |

更新(2012-07):在 Python 3.3 的功能代码截止之前,确定打包尚未准备好发布在标准库中,因此它已从 3.3 版本中删除。我们将继续开发通过 PyPI 提供的 Distutils2 以及将包含在 Python 3.4 标准库中的内容。


更新(2014-10):自上次更新此答案以来,Python 打包领域发生了进一步的变化。

  • 最重要的是,自 2013 年中期以来,setuptools
    distribute 已修复,开发活动 已合并
    进入新的 setuptools 项目
    分发 现在
    已弃用且不再维护;使用新的 setuptools 代替
    但不要使用其 easy_install 作为安装程序。

  • pip 已成为事实上的、受祝福的安装工具(对于 Python
    您平台的包管理器未另外提供的包)
    虚拟环境内部或外部(virtualenvpyvenv)。

  • 代替旧的setuptools bdist eggs轮子
    成为 Python 包的受祝福的二进制分发格式。

  • 从 Python 3.4 开始支持 wheelpip 版本
    现在随官方 python.org 二进制安装程序一起提供,并且
    源码包,预计 pip 也将
    包含在 Python 2.7 的下一个维护版本 (2.7.9) 中。< /p>

  • Distutils2packaging 现在处于休眠状态。

更多详细信息,请参阅 Python 3 文档的新分发 Python 模块 部分和新版本Python 打包用户指南

[2014-10 TL;DR:
distribute is dead, use pip, the new setuptools, and, for binary distributions, wheels. More below.]


[Original answer]

Distribute is was a fork of the older setuptools so nearly all comments that follow apply equally to Distribute and setuptools. Setuptools was an attempt to fill in a number of holes in the even older Python standard library package, Distutils. Setuptools added functions like automatic downloads of packages via a command-line interface, easy_install, and some level of dependency management. However, a segment of the Python community is of the opinion that setuptools is too intrusive and has too much behind-the-scenes magic for some of its features.

pip is a higher-level interface on top of setuptools or Distribute. It uses them to perform many of its functions but avoids some of their more controversial features, like zipped eggs. pip also provides features not available in setuptools, like an uninstall command and the ability to define fixed sets of requirements and reliably reproduce a set of packages. There is a more complete feature comparison here.

Why are there so many components (and there are more, like buildout)? Lots of reasons: solutions must work across all of the major platforms on which Python is supported (i.e. Unix-y, Windows, Mac OS X), so building and installation present a complex set of problems; like many open-source projects, Python is essentially all-volunteer and many developers just aren't all that interested in packaging and installation issues; there is a natural conservatism about adding major new unproven features to the standard library; differences in opinions, etc etc.

At the moment, there is a project underway to provide a replacement for Distutils and possibly for some of the higher-level add-ons. It is planned to be released in the Python 3.3 standard library as the packaging package and as an add-on for older versions of Python as Distutils2.

To summarize, the current relationship is:

pip -> [ setuptools | Distribute ] -> Distutils -> Python core
                                    |
    3rd party packages              |      included in Python
                                    |

UPDATE (2012-07): Prior to feature code cutoff for Python 3.3, it was decided that packaging was not quite ready yet for release in the standard library so it has been removed from the 3.3 release. Work will continue on Distutils2 which is available via PyPI and on what will be included in the standard library for Python 3.4.


UPDATE (2014-10): There have been further changes in the world of Python packaging since this answer was last updated.

  • Most importantly, since mid-2013, the rift between setuptools and
    distribute has been healed and development activity has been merged
    into a new setuptools project
    . distribute is now
    deprecated and no longer maintained; use the new setuptools instead
    but don't use its easy_install as an installer.

  • pip has become the de-facto and blessed installer tool (for Python
    packages not otherwise provided by your platform's package manager)
    either in- or outside of virtual environments (virtualenv or pyvenv).

  • Instead of the old setuptools bdist eggs, wheels have
    become the blessed binary distribution format for Python packages.

  • As of Python 3.4, a version of pip with wheel support
    is now shipped with the official python.org binary installers and
    source packages and it is anticipated that pip will also be
    included in the next maintenance release of Python 2.7 (2.7.9).

  • Distutils2 and packaging are now dormant.

More details in the new Distributing Python Modules section of the Python 3 docs and the new Python Packaging User Guide.

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