问题:在requirements.txt中,代字号(〜=)是什么意思?

requirements.txt我正在使用的Python库中,其中一项要求指定为:

mock-django~=0.6.10

什么~=意思

In the requirements.txt for a Python library I am using, one of the requirements is specified like:

mock-django~=0.6.10

What does ~= mean?


回答 0

这意味着它将选择软件包的最新版本,大于或等于0.6.10,但仍为0.6。*版本,因此不会下载0.7.0。如果程序包维护者遵循语义版本控制(这表明重大更改应仅在主要版本中进行),则它可以确保获得安全修复程序,但保持向后兼容性。

或者,如PEP 440所述:

对于给定的发布标识符VN,兼容的发布子句近似等于一对比较子句:

>= V.N, == V.*

It means it will select the latest version of the package, greater than or equal to 0.6.10, but still in the 0.6.* version, so it won’t download 0.7.0 for example. It ensures you will get security fixes but keep backward-compatibility, if the package maintainer respects the semantic versioning (which states that breaking changes should occur only in major versions).

Or, as said by PEP 440:

For a given release identifier V.N , the compatible release clause is approximately equivalent to the pair of comparison clauses:

>= V.N, == V.*


回答 1

那就是“兼容版本”版本说明符

它等效于:mock-django >= 0.6.10, == 0.6.*,并且是一种匹配预期兼容版本的简洁方法。用简单的英语来说,这有点像说:“我需要一个模拟Django的版本,该版本至少是0.6.10的新版本,但又不是太新以至于与它不兼容。”

如果您不确定所有这些版本号,请快速查看PEP440版本方案吧!

That’s the ‘compatible release’ version specifier.

It’s equivalent to: mock-django >= 0.6.10, == 0.6.*, and is a tidy way of matching a version which is expected to be compatible. In plain English, it’s a bit like saying: “I need a version of mock-django which is at least as new as 0.6.10, but not so new that it isn’t compatible with it.”

If you’re not sure about all this version number stuff, a quick look at the PEP440 version scheme should sort you out!


回答 2

〜=表示兼容版本。不小于0.6.10和更高(0.6。*)。

~= means a compatible version. Not less than 0.6.10 and higher (0.6.*).


回答 3

兼容的发布子句由兼容的发布操作符〜=和版本标识符组成。它与预期与指定版本兼容的任何候选版本匹配。

您可以在这里阅读更多信息:https : //www.python.org/dev/peps/pep-0440/#compatible-release

A compatible release clause consists of the compatible release operator ~= and a version identifier. It matches any candidate version that is expected to be compatible with the specified version.

You can read more here: https://www.python.org/dev/peps/pep-0440/#compatible-release


声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。