Pythonista, how are you upgrading the package written in requirements.txt
?
Do you regularly copy the package name into the search window of PyPI to find out the version number?
pip-tools makes it easier to manage!
You can install it with pip (> = 6.1) as follows.
pip install pip-tools
Write the name of the package you want to install in the file requirements.in
. The writing method is the same as requirements.txt
.
requirements.in
Django
easy-thumbnails
Fabric
Then, the following command will generate requirements.txt
with the latest run-time version number.
pip-compile requirements.in
It also looks up and writes out dependent packages.
Also, if you want to specify "latest than this version" or "latest in the range of this version", you can write as follows.
(This is also the same as writing requirements.txt
)
requirements.in
Django>=1.8.0,<1.9.0
easy-thumbnails>=2.2
Fabric>=1.8.0,<2.0.0
A command that can be used in place of pip install -r requirements.txt
.
Install the package written in requirements.txt
with the following command.
pip-sync
Unlike normal pip install
, it uninstalls packages that you have previously installed but no longer use.
pip-compile
has a --dry-run
option so you can compare the differences with previously generated content like this before updating requirements.txt
.
pip-compile --dry-run requirements.in | diff requirements.txt -
You may be happy if you do this in a CI or cron job so that you are automatically notified when you need to upgrade the package.
Recommended Posts