'Use >= or ~= for compatibilty across systems?
My goal is a simple and proper way to export my venv. In the optimal case, the resulting requirements.txt works on all compatible systems.
At the moment I use pip freeze > requirements.txt.
This uses the == "Version matching clause". On an other system the file might not work due to conflicting versions, although it was compatible.
In PEP 440 there is also a ~= "Compatible clause". However, I cannot find an option for that in pip freeze docs. Using "find and replace" or a tool like awk to replace == with ~= works okay.
My naive conclusion is that ~= would be the ideal clause to use in requirements.txt. However, when I look at popular packages they often use >= to specify a version. E.g. at urllib3.
Is there a drawback to ~=, which I do not see?
If that is not the case:
Why is >= used in so many packages?
Edit:
Pigar has an option to use >= natively and there is a comparison to freeze here. Apparently, they also do not use ~=.
Yet, I am still not sure which one to use, as >= could break when there is a major version change. Also packages which are a lower minor version would be marked incompatible, although they should be compatible.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
