In python, it is common practice to write all the application dependencies that are installed via pip into a separate text file called requirements.txt.
It’s good practice to fully specify package versions in your requirements file. And in our case, everything will be there — both direct dependencies of our application and dependency dependencies, etc.
But sometimes, especially on a long-lived project, it’s hard to understand what dependencies were original. It is necessary to update them on time, not depend on packages that are outdated or no longer needed for some reason.
For example, which of the following dependencies are the original ones?
Yes, it’s just pandas.
One of the mechanisms for separating dependencies is implemented using another text file called constants.txt.
It looks exactly like requirements.txt:
Constraints files differ from requirements files in one key way: putting a package in the constraints file does not cause the package to be installed, whereas a requirements file will install all packages listed. Constraints files are simply requirements files that control which version of a package will be installed but provide no control over the actual installation.
To use this file, you can do it via the requirements.txt file:
pip install -c constraints.txt
will install all packages from requirements.txt and using constraints.txt files for version constraint.
Thank you for reading!
Any questions? Leave your comment below to start fantastic discussions!