如何点子安装最小和最大版本范围的软件包? [英] How to pip install a package with min and max version range?

查看:118
本文介绍了如何点子安装最小和最大版本范围的软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有任何方法可以告诉pip,特别是在需求文件中,安装一个最低版本(pip install package>=0.2)和最高版本都不应安装的软件包(理论api:).

我问,因为我使用的是正在积极开发中的第三方库.我希望我的pip要求文件指定它应该始终安装0.5.x分支的最新次要版本,但是我不希望pip尝试安装任何较新的主要版本(例如0.6.x),因为API是不同的.这很重要,因为即使0.6.x分支可用,开发人员仍在向0.5.x分支发布补丁和错误修正,所以我不想在需求文件中使用静态的package==0.5.9行.

有什么办法吗?

解决方案

您可以这样做:

$ pip install "package>=0.2,<0.3"

pip会寻找最佳匹配,假定版本至少为0.2,且小于0.3.

这也适用于pip 需求文件 .请参见 PEP 440 中有关版本说明符的完整详细信息. /p>

I'm wondering if there's any way to tell pip, specifically in a requirements file, to install a package with both a minimum version (pip install package>=0.2) and a maximum version which should never be installed (theoretical api: pip install package<0.3).

I ask because I am using a third party library that's in active development. I'd like my pip requirements file to specify that it should always install the most recent minor release of the 0.5.x branch, but I don't want pip to ever try to install any newer major versions (like 0.6.x) since the API is different. This is important because even though the 0.6.x branch is available, the devs are still releasing patches and bugfixes to the 0.5.x branch, so I don't want to use a static package==0.5.9 line in my requirements file.

Is there any way to do that?

解决方案

You can do:

$ pip install "package>=0.2,<0.3"

And pip will look for the best match, assuming the version is at least 0.2, and less than 0.3.

This also applies to pip requirements files. See the full details on version specifiers in PEP 440.

这篇关于如何点子安装最小和最大版本范围的软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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