In requirements.txt, what does tilde equals (~=) mean?
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Quirky Dreamscape Looping
--
Chapters
00:00 Question
00:26 Accepted answer (Score 340)
01:20 Answer 2 (Score 39)
02:05 Answer 3 (Score 36)
02:18 Answer 4 (Score 12)
02:35 Thank you
--
Full question
https://stackoverflow.com/questions/3959...
Accepted answer links:
[Definition in PEP 440]: https://www.python.org/dev/peps/pep-0440...
[Complete example here in the documentation]: https://pip.pypa.io/en/stable/cli/pip_in...
Answer 2 links:
[version specifier]: https://www.python.org/dev/peps/pep-0440...
[version scheme]: https://www.python.org/dev/peps/pep-0440...
Answer 3 links:
[PEP documentation]: https://www.python.org/dev/peps/pep-0440...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #requirementstxt
#avk47
ACCEPTED ANSWER
Score 417
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.*
ANSWER 2
Score 72
Adding to the existing answers, I think it's very important to also mention that while
~=0.6.10 means >=0.6.10, ==0.6.*
Following is also true
~=0.6 means >=0.6, ==0.*
It's mentioned in the PEP documentation.
ANSWER 3
Score 45
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!
ANSWER 4
Score 14
~= means a compatible version. Not less than 0.6.10 and higher (0.6.*).