有关安装工具和替代方案的问题

发布于 2024-07-10 12:59:41 字数 1148 浏览 8 评论 0原文

我最近在互联网上看到了很多对 setuptools 的攻击。 最近,我阅读了 James Bennett 的关于包装的文章,了解了原因没有人应该使用 setuptools。 从我在 Freenode 上使用 #python 的那段时间起,我就知道那里有一些人绝对讨厌它。 我会把自己算在其中,但我确实在使用它。

我已经在足够多的项目中使用了 setuptools,以意识到它的缺陷,并且我更喜欢更好的东西。 我不太喜欢鸡蛋的形式及其部署方式。 对于安装工具的所有问题,我还没有找到更好的替代方案。

我对 pip 这样的工具的理解是,它是一个 easy_install 的替代品(而不是 setuptools)。 事实上,pip 使用了一些 setuptools 组件,对吗?

我的大多数包都使用 setuptools-aware setup.py,它声明了所有依赖项。 当它们准备好后,我将构建 sdist、bdist 和 bdist_egg,并将它们上传到 pypi。

如果我想改用 pip,我需要进行哪些更改才能摆脱 easy_install 依赖项? 依赖项在哪里声明? 我猜我需要摆脱使用 Egg 格式,而只提供源代码发行版。 如果是这样,我如何生成 Egg-info 目录? 或者我是否需要这样做?

这将如何改变我对 virtualenv 的使用? virtualenv 不是使用 easy_install 来管理环境吗?

这将如何改变我对 setuptools 提供的“develop”命令的使用? 我不应该使用它吗? 还有什么选择呢?

我基本上是想了解我的开发工作流程是什么样子的。

在有人提出建议之前,我并不是在寻找依赖于操作系统的解决方案。 我主要关心 debian linux,但 deb 软件包不是一个选择,原因 Ian Bicking 概述了 此处

I've seen a good bit of setuptools bashing on the internets lately. Most recently, I read James Bennett's On packaging post on why no one should be using setuptools. From my time in #python on Freenode, I know that there are a few souls there who absolutely detest it. I would count myself among them, but I do actually use it.

I've used setuptools for enough projects to be aware of its deficiencies, and I would prefer something better. I don't particularly like the egg format and how it's deployed. With all of setuptools' problems, I haven't found a better alternative.

My understanding of tools like pip is that it's meant to be an easy_install replacement (not setuptools). In fact, pip uses some setuptools components, right?

Most of my packages make use of a setuptools-aware setup.py, which declares all of the dependencies. When they're ready, I'll build an sdist, bdist, and bdist_egg, and upload them to pypi.

If I wanted to switch to using pip, what kind of changes would I need to make to rid myself of easy_install dependencies? Where are the dependencies declared? I'm guessing that I would need to get away from using the egg format, and provide just source distributions. If so, how do i generate the egg-info directories? or do I even need to?

How would this change my usage of virtualenv? Doesn't virtualenv use easy_install to manage the environments?

How would this change my usage of the setuptools provided "develop" command? Should I not use that? What's the alternative?

I'm basically trying to get a picture of what my development workflow will look like.

Before anyone suggests it, I'm not looking for an OS-dependent solution. I'm mainly concerned with debian linux, but deb packages are not an option, for the reasons Ian Bicking outlines here.

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

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

发布评论

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

评论(3

静赏你的温柔 2024-07-17 12:59:41

pip 使用Setuptools,并且不需要对包进行任何更改。 它实际上使用Setuptools安装软件包,使用:

python -c 'import setuptools; __file__="setup.py"; execfile(__file__)' \
    install \
    --single-version-externally-managed

因为它使用该选项(--single-version-externally-management),所以它不会将eggs安装为zip文件,不支持同时安装多个eggs软件的版本,并且软件包是平面安装的(例如,如果您仅使用 distutils,则 python setup.py install 可以工作)。 Egg 元数据仍然安装。 pip 还像 easy_install 一样,下载并安装包的所有要求。

此外您还可以使用需求文件来添加应批量安装的其他软件包,并使版本要求更加准确(无需将这些确切的要求放入您的 setup.py< /代码> 文件)。 但如果您不创建需求文件,那么您将像 easy_install 一样使用它。

对于您的 install_requires,我不建议您进行任何更改,除非您一直在尝试创建已知良好的非常精确的要求。 我认为在 setup.py 文件中关于版本的准确程度是有限的,因为您无法真正知道新库的未来兼容性会是什么样子,而且我也不知道建议您尝试预测这一点。 需求文件是放置保守版本需求的替代位置。

您仍然可以使用python setup.pydevelop,事实上,如果您执行pip install -e svn+http://mysite/svn/Project/trunk#egg=Project > 它将检查它(进入src/project)并在其上运行setup.pydevelop。 所以这个工作流程实际上并没有什么不同。

如果您详细地运行 pip(例如 pip install -vv),您将看到许多正在运行的命令,并且您可能会识别其中的大多数命令。

pip uses Setuptools, and doesn't require any changes to packages. It actually installs packages with Setuptools, using:

python -c 'import setuptools; __file__="setup.py"; execfile(__file__)' \
    install \
    --single-version-externally-managed

Because it uses that option (--single-version-externally-managed) it doesn't ever install eggs as zip files, doesn't support multiple simultaneously installed versions of software, and the packages are installed flat (like python setup.py install works if you use only distutils). Egg metadata is still installed. pip also, like easy_install, downloads and installs all the requirements of a package.

In addition you can also use a requirements file to add other packages that should be installed in a batch, and to make version requirements more exact (without putting those exact requirements in your setup.py files). But if you don't make requirements files then you'd use it just like easy_install.

For your install_requires I don't recommend any changes, unless you have been trying to create very exact requirements there that are known to be good. I think there's a limit to how exact you can usefully be in setup.py files about versions, because you can't really know what the future compatibility of new libraries will be like, and I don't recommend you try to predict this. Requirement files are an alternate place to lay out conservative version requirements.

You can still use python setup.py develop, and in fact if you do pip install -e svn+http://mysite/svn/Project/trunk#egg=Project it will check that out (into src/project) and run setup.py develop on it. So that workflow isn't any different really.

If you run pip verbosely (like pip install -vv) you'll see a lot of the commands that are run, and you'll probably recognize most of them.

南风起 2024-07-17 12:59:41

对于初学者来说,pip 确实很新。 新的、不完整的并且基本上未经现实世界的测试。

它显示出巨大的前景,但直到它可以完成 easy_install/setuptools 可以做的所有事情之前,它不太可能大范围流行,尤其是在公司中。

Easy_install/setuptools 又大又复杂——这冒犯了很多人。 不幸的是,这种复杂性有一个很好的理由,那就是它可以满足大量不同的用例。 我自己的支持大量(> 300)桌面用户,以及一个类似大小的网格和经常更新的应用程序。 我们可以通过允许每个用户从源代码安装来做到这一点的想法是可笑的——鸡蛋已经证明自己是分发我的项目的可靠方式。

我的建议:学习使用 setuptools - 这真的是一件很棒的事情。 大多数讨厌它的人并不理解它,或者根本不具备作为全功能分发系统的用例。

:-)

For starters, pip is really new. New, incomplete and largely un-tested in the real world.

It shows great promise but until such time as it can do everything that easy_install/setuptools can do it's not likely to catch on in a big way, certainly not in the corporation.

Easy_install/setuptools is big and complex - and that offends a lot of people. Unfortunately there's a really good reason for that complexity which is that it caters for a huge number of different use-cases. My own is supporting a large ( > 300 ) pool of desktop users, plus a similar sized grid with a frequently updated application. The notion that we could do this by allowing every user to install from source is ludicrous - eggs have proved themselves a reliable way to distribute my project.

My advice: Learn to use setuptools - it's really a wonderful thing. Most of the people who hate it do not understand it, or simply do not have the use-case for as full-featured distribution system.

:-)

ま昔日黯然 2024-07-17 12:59:41

我是在 2014 年 4 月写这篇文章的。请注意有关 Python 打包、分发或安装的任何文章的日期。 看起来,在过去三年里,派系之争有所减少,实施有所改善,PEP 标准化和战线统一。

例如,Python 打包权威是“一个维护Python打包中许多相关项目的工作组”。

python.org Python 打包用户指南工具推荐Python 打包的未来 部分。

distributesetuptools 的一个分支,于 2013 年 6 月重新合并。该指南称,“使用 setuptools 定义项目并创建源代码发行版。”

从 PEP 453 和 Python 3.4 开始,该指南建议“使用 pip 从 PyPI 安装 Python 包”,并且 pip 包含在 Python 3.4 中,并由 pip 安装在 virtualenvs 中code>pyvenv,也包含在内。 您可能会发现 PEP 453“基本原理”部分很有趣。

指南中还提到了一些新的工具,包括 wheelbuildout

我很高兴阅读了以下两本技术/半政治历史。

作者:Martijn Faassen,2009 年:Python 打包的历史。

Armin Ronacher 在 2013 年 6 月发表的文章(标题并不严肃): Python 封装:仇恨、仇恨、仇恨无处不在

I'm writing this in April 2014. Be conscious of the date on anything written about Python packaging, distribution or installation. It looks like there's been some lessening of factiousness, improvement in implementations, PEP-standardizing and unifying of fronts in the last, say, three years.

For instance, the Python Packaging Authority is "a working group that maintains many of the relevant projects in Python packaging."

The python.org Python Packaging User Guide has Tool Recommendations and The Future of Python Packaging sections.

distribute was a branch of setuptools that was remerged in June 2013. The guide says, "Use setuptools to define projects and create Source Distributions."

As of PEP 453 and Python 3.4, the guide recommends, "Use pip to install Python packages from PyPI," and pip is included with Python 3.4 and installed in virtualenvs by pyvenv, which is also included. You might find the PEP 453 "rationale" section interesting.

There are also new and newish tools mentioned in the guide, including wheel and buildout.

I'm glad I read both of the following technical/semi-political histories.

By Martijn Faassen in 2009: A History of Python Packaging.

And by Armin Ronacher in June 2013 (the title is not serious): Python Packaging: Hate, hate, hate everywhere.

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