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

查看:84
本文介绍了有关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来意识到它的不足,我希望有更好的东西.我并不特别喜欢egg格式及其部署方式.由于存在所有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?

这将如何改变我对setuptool提供的"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,但是由于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天全站免登陆