Do you anchor all versions in requirements.txt
to a spesific number? Is it the right way? Is there any way to get latest version that does not break my app? To not missing security updates etc.
Asked
Active
Viewed 143 times
1

mcan
- 1,914
- 3
- 32
- 53
-
It is better to add ```requirements.txt```. There are times when developers deprecate some functions and you might not be able to access them in future versions hence breaking the app. – Yash Oct 01 '20 at 08:21
1 Answers
0
Installing latest dependency may break your app if the new code syntax is not backwards compatible. Here's how I approach to maintain the requirements.txt
file.
- Create a new virtual environment every time I develop for a new project
- Install all the dependencies in the virtual env
- Run
pip freeze > requirements.txt
from that virtual env to generate the file - Add Python version in a
Readme
file
This way I can always know for sure the Python version and version of the dependencies with which the app was built. This of course does not solve other issues related to OS type/version compatibility that might occur.
Tools like Docker are created to solve all such dependency and cross-platform compatibility problems so that is worth exploring.
EDIT
If you still want to always have the latest version of the package, simply remove the version numbers and keep the package name.
E.g. Instead of mysql-connector==2.2.9
use mysql-connector

Chandral
- 448
- 1
- 3
- 19