In requirements.txt, what does tilde equals (~=) mean?

本秂侑毒 提交于 2019-12-17 18:12:48

问题


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?


回答1:


It means it will select the latest version of the package, greater 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.*

  • Definition in PEP 440
  • Complete example here in the documentation



回答2:


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!




回答3:


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




回答4:


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



来源:https://stackoverflow.com/questions/39590187/in-requirements-txt-what-does-tilde-equals-mean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!