Python:Constraints
lastmod 2024-07-29created 2024-07-292 edits
Categories
- pip
- Python:Requirements - About the requirements.txt file used when installing with Python's pip
- Python:Constraints - About the constraints.txt file used when installing with Python's pip
Version specifiers
How to specify versions, such as ~=. See PEP 440#Version specifiers for details.
requirements.txt vs constraints.txt
- [Recommended] python - PIP Constraints Files - Stack Overflow
If the install conditions differ for each Python version:
Django==1.8.12
django-allauth==0.25.2
oauthlib==1.0.3
python-openid==2.2.5 ; python_version < '3.0'
python3-openid==3.0.10 ; python_version >= '3.0'
defusedxml==0.4.1 ; python_version >= '3.0'
requests==2.9.1
requests-oauthlib==0.6.1
It gets a bit messy.
requirements.txt lists items that must be installed. constraints.txt, on the other hand, only applies constraints.
For example:
In this case Django==1.8.12 and django-allauth==0.25.2 are always installed, and constraints.txt is checked only for the conditions on packages installed as dependencies in the process.
As versions go up later, some packages may become unnecessary; anything that counts as such a "constraint (Constraints)" should go into constraints.txt.