-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pip list --outdated should have a way to take requirements into account #9725
Comments
This has been raised numerous times. pip is a tool for interacting with a Python environment, and if you go through its commands, almost all of them involve something to manipulate an environment, or get information out of an environment. It is definitely possible for pip to implement this, but the way it does this will be exactly to create an environment, install into it, and then run |
Stepping back from the implementation a little, it seems like you’re quite convinced that pip “should” have this functionality. May I ask why? A tool should provide users a coherent workflow, instead of putting a bunch commands together “because it can”. What is your pip workflow that makes this a required functionality? |
I am not understanding your comments at all I'm afraid. My suggestion is precisely a command to "get information out of an environment" (at least as much as I also don't understand why you doubt a command to ask "what packages could/should be updated" is not universally applicable. My workflow is unlikely to be different from anyone else's here. Why would anyone not need this command? Every time I use |
IMO, the difficulty here is that The proposed functionality needs extra context, in the form of a set of requirements that you want to upgrade. That's a very different request (at least if you look "under the hood"). You're asking pip to look at what it would need to install to do the requested upgrade, and report that. That's not a variation on a It's important to remember that pip is not intended as a "project management" tool, which knows what top-level dependencies you need, and manages them and tracks the installed versions that fulfil those dependencies. That functionality is provided by "higher level" projects like If you were to propose that pip hand a |
https://xkcd.com/1425/ comes to mind. :) |
Is it not just a case then of doing what |
@pradyunsg ok, ye of little faith, here is a proof-of-concept implementation in a 9-line shell script: VENV=$(python -c 'import sys; print(sys.prefix.rstrip("/"))')
TDIR=$(mktemp -d -p"$(dirname "$VENV")")
cp -pr "$VENV/" "$TDIR/"
TPY="$TDIR/"$(basename "$VENV")"/bin/python"
python -mpip list | tail +3 >"$TDIR/old-packages"
"$TPY" -mpip install -U "$@"
"$TPY" -mpip list | tail +3 >"$TDIR/new-packages"
diff -u0 "$TDIR/old-packages" "$TDIR/new-packages"
rm -r -- "$TDIR" |
Looks like you have a good plan for things already, maybe more than we do. Care to organise them into a pull request to save everyone time? |
Probably best if you just give me direct commit access. Many thanks in advance. |
I assume that's intended as sarcasm. But just to be clear, a PR should be fine - even people with commit access work via PRs. If you don't intend to work on it yourself, I suspect the request is mostly just a duplicate of #53, at least in the sense that I've explained why I'd see Either way, if we can keep the discussion constructive that would be appreciated. @jribbens I assume you didn't need to be told that your shell implementation is a bit simplistic, but if you do have an interest in expanding it into a "proper" implementation/PR, it would be very welcome. If not, it'll happen when someone does have the interest in taking it further, but I can't say when that will be. |
It seemed appropriate in reply to the rather misguided and rude comment I was responding to.
Of course, it was just a response to the XKCD 1425 implication that what I was suggesting was inherently not something a computer can do. Also it's a useful working demonstration of the information I am suggesting that pip should be able to output. Is an |
Disclaimer - although I am pretty familiar with pip's internals, they are a complex mess of backward compatibility and technical debt, so most of the time, I'm just guessing until I look at the details myself 🙂
Probably not. For a start, I don't want to paralyze everything with speculation, though. Ultimately, someone will look at the code, and may come up with an easy way forward, or may find it's a lot of work. Which they can then choose to do or give up. There's no real pressure either way. My gut feel is that it'll be messier that you initially expect, but it's not going to be impossible. And it'll probably take longer (elapsed time) that you'd hope, because people will come up with a bunch of edge cases you hadn't thought of. But there's people who can help with that stuff, once you have an initial working implementation to talk about. |
FWIW, this should not be that tricky any more. All the recent technical debt paydown we've done, over the course of introducing the new resolver (I'm including the work from before the grant funded work too) should mean that's it's a relatively small patch. The bigger concern with this is converting whatever we get after the whole dependency resolution process, into something that's consumable by our end users. I don't think that's usable as is though (like, those object don't really have an easily serializable form), and we're basically discussing #53 at this point. I'd suggest moving the rest of the discussion over there. |
With #10771, you can do this to know what needs to be upgraded (as well as new dependencies to be installed), assuming your top level requirements are declared in a python project (
|
In the OP:
Since this is now supported with Don't hesitate to say so if there is something else that I missed. |
Sounds good, I'll take a look when it's released to see how it compares to my imagined version ;-) |
What's the problem this feature will solve?
pip list --outdated
is very useful, however there seems to be no way to take into account what versions your project actually needs. There is a difference between "a new minor version of this package has been released, that matches your requirements.txt and you should probably upgrade to immediately" and "a new major version of this package has been released, which you might want to refactor your code to use someday".Basically I want a command that answers the question "what would
pip install -U -r requirements.txt
do, if anything, if I ran it?"Describe the solution you'd like
e.g.
Alternative Solutions
There is no way to work around this problem that I am aware of, short of creating another virtual environment, doing
pip install -r requirements.txt
from scratch in that new environment, doingpip list
in both old and new environments, and diffing the output...Another way of achieving the same end in a slightly less user-friendly manner would be a
pip install --fetch-only
orpip install -n
type option, i.e. to go through the install process doing everything except the actual installation of the packages.The text was updated successfully, but these errors were encountered: