关于 Setuptools 和替代品的问题 [英] Questions about Setuptools and alternatives

查看:36
本文介绍了关于 Setuptools 和替代品的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在互联网上看到了大量的 setuptools.最近,我阅读了 James Bennett 的关于包装关于原因的帖子没有人应该使用 setuptools.从我在 Freenode 上#python 的那段时间开始,我就知道那里有一些人非常讨厌它.我会把自己算在其中,但我确实在使用它.

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.

我已经在足够多的项目中使用了 setuptools 来意识到它的不足,我更喜欢更好的东西.我不是特别喜欢鸡蛋格式及其部署方式.由于 setuptools 的所有问题,我还没有找到更好的替代方案.

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.

我对 pip 之类的工具的理解是,它旨在替代 easy_install(而不是 setuptools).其实pip使用了一些setuptools组件吧?

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?

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

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.

如果我想切换到使用 pip,我需要做哪些更改才能摆脱对 easy_install 的依赖?依赖项在哪里声明?我猜我需要避免使用 egg 格式,而只提供源代码分发.如果是这样,我如何生成 egg-info 目录?或者我什至需要吗?

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?

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

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

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

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.

在任何人提出建议之前,我并不是在寻找依赖于操作系统的解决方案.我主要关注 debian linux,但 deb 包不是一个选项,因为 Ian Bicking 概述了 此处.

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.

推荐答案

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

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

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

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.

此外您还可以使用需求文件添加其他应批量安装的软件包,并使版本要求更加准确(无需将这些确切要求放在您的 setup 中).py 文件).但是,如果您不制作需求文件,那么您就可以像使用 easy_install 一样使用它.

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.

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

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.

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

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.

如果您详细地运行 pip(如 pip install -vv),您会看到许多正在运行的命令,并且您可能会认出其中的大部分.

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.

这篇关于关于 Setuptools 和替代品的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆