Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if requirements are up to date

I'm using pip requirements files for keeping my dependency list.

I also try to follow best practices for managing dependencies and provide precise package versions inside the requirements file. For example:

Django==1.5.1 lxml==3.0 

The question is: Is there a way to tell that there are any newer package versions available in the Python Package Index for packages listed inside requirements.txt?

For this particular example, currently latest available versions are 1.6.2 and 3.3.4 for Django and lxml respectively.

I've tried pip install --upgrade -r requirements.txt, but it says that all is up-to-date:

$ pip install --upgrade -r requirements.txt  Requirement already up-to-date: Django==1.5.1 ... 

Note that at this point I don't want to run an actual upgrade - I just want to see if there are any updates available.

like image 635
alecxe Avatar asked Apr 08 '14 18:04

alecxe


People also ask

How do I check if my pip is up to date?

The pip-review shows you what updates are available, but does not install them. If you want to automatically install as well, the tool can handle that too: $ pip-review --auto . There is also an --interactive switch that you can use to selectively update packages.

How do you check Python requirements?

If you are using flake8 for style-checking, you can add flake8-requirements plugin for flake8. It will automatically check whether imported modules are available in setup.py , requirements. txt or pyproject. toml file.

Can I upgrade pip in requirements txt?

txt file? As Andy mentioned in his answer packages are pinned to a specific version, hence it is not possible to upgrade packages through pip command.


1 Answers

Pip has this functionality built-in. Assuming that you're inside your virtualenv type:

$ pip list --outdated psycopg2 (Current: 2.5.1 Latest: 2.5.2) requests (Current: 2.2.0 Latest: 2.2.1)  $ pip install -U psycopg2 requests 

After that new versions of psycopg2 and requests will be downloaded and installed. Then:

$ pip freeze > requirements.txt 

And you are done. This is not one command but the advantage is that you don't need any external dependencies.

like image 170
Max Tepkeev Avatar answered Nov 08 '22 14:11

Max Tepkeev