Skip to content

Allow pip list --outdated to take a requirements file #3314

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
ggreer opened this issue Dec 22, 2015 · 10 comments
Open

Allow pip list --outdated to take a requirements file #3314

ggreer opened this issue Dec 22, 2015 · 10 comments
Labels
C: list/show 'pip list' or 'pip show' type: enhancement Improvements to functionality

Comments

@ggreer
Copy link

ggreer commented Dec 22, 2015

Sometimes, I'm not on the latest release of a Python package. For example, I haven't upgraded to Django 1.9 yet. But is there a bug fix or security release for 1.8? With pip, I can't tell:

% pip list --outdated
Django (Current: 1.8.6 Latest: 1.9 [wheel])
requests (Current: 2.8.0 Latest: 2.9.1 [wheel])

To fix this, it would be nice if I could pass my normal requirements.txt to pip list --outdated. In other words, given a requirements.txt like this...

Django>=1.8,<1.9
requests>=2.8,<2.9

...I'd like to do this:

% pip list --outdated -r requirements.txt 
Django (Current: 1.8.6 Wanted: 1.8.7 Latest: 1.9 [wheel])
requests (Current: 2.8.0 Wanted: 2.8.1 Latest: 2.9.1 [wheel])

(I'm not dead-set on that output format, just giving it as an example.)

I searched around for similar issues, but the closest I could find was #2982. That's not so much a functional change as a stylistic one.

@xavfernandez xavfernandez added the type: enhancement Improvements to functionality label Jan 2, 2016
@jacobsvante
Copy link

Sounds like a great idea. Sign me up!

@Herst
Copy link

Herst commented Feb 19, 2017

With this you could also tell whether there is an update for your packages directly listed in your requirements file and not packages that are just dependencies and which you might not be able to update without possibly breaking something.

@pradyunsg pradyunsg added the C: list/show 'pip list' or 'pip show' label Feb 5, 2020
@pradyunsg pradyunsg self-assigned this Feb 5, 2020
@pradyunsg
Copy link
Member

I think I can pick this up at some point in the near future. Self-assigning this on that assumption. I'd still be working on this in volunteered time, so, no promises on that.

@juanjsebgarcia
Copy link

Anyone finding this through search:
https://pypi.org/project/pip-upgrade
I've been using the above package to help manage the situation.

Having it native would be super

@pradyunsg
Copy link
Member

@juanjsebgarcia I think you're asking for #4551?

@juanjsebgarcia
Copy link

I think it applies to both :)

The above package lists all the expired requirements in a given requirements.txt so I think it helps alleviate this issue too.

I still think having it natively in pip would be great though, something less interactive...

@cristianoccazinsp
Copy link

Would love it, would bring pip closer to "npm" somehow. It's pointless to list ALL outdated packages (even the ones not in your requirements file) since most of them are dependencies you don't even control or can't update directly.

@bhrutledge
Copy link

bhrutledge commented Dec 9, 2020

FWIW, I wrote up a way to do this if you're using pip-tools, by leveraging one of several other tools that operate on requirements files: https://github.com/bhrutledge/pip-tools-outdated.

See also jazzband/pip-tools#1167.

@Shivansh-007
Copy link
Contributor

I would like to work on this issue 👍🏻. Do I get assigned or I can just come up with PR directly?

@PhrozenByte
Copy link

Just a quick note for other people searching for a solution to this: The following will list outdated packages from a requirements.txt:

pip install --upgrade -r requirements.txt --dry-run --quiet --report - 2> /dev/null \
    | jq -r '.install[] | "\(.metadata.name)  \(.metadata.version)"'

Since pip install --report is printing a JSON report, you'll also need jq. There's no formatted output and we don't include the currently installed versions, but it might be good enough to learn which packages can be upgraded with a requirements.txt in mind.

Please note that this won't edit requirements.txt (like many proposed solutions elsewhere), i.e. if you freeze all versions in your requirements.txt you won't ever see outdated packages, simply because no other version will ever meet the version constraint.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C: list/show 'pip list' or 'pip show' type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants