-
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
Add metadata field to pip list json output #11097
Conversation
05f0eab
to
8df7dcf
Compare
This one is ready but should be merged after #11095 on which it depends. |
I'm wondering if we should instead add a On the other hand, |
I think if we want |
8df7dcf
to
fa67025
Compare
So they are resilient to new fields added to the json output.
fa67025
to
530b5e0
Compare
To be honest, I'm not too keen on this. I can see how this is functionally useful, but we're no longer merely "listing the installed packages" but instead providing a lot of the information that pip has about it as well. I'd rather we make this sort of information available via an opt-in mechanism (eg: |
Yeah, this feels very similar to the discussion in #11223. I'm against the idea of evolving pip in the direction of being a tool for querying information about an environment. I don't think that fits pip's core purpose, and I think the logic that we do it in pip because pip is present in all environments is misguided. A script (or zipapp) that's run using the environment's Python is just as usable, and doesn't fail if people have environments without pip. Even if we do want to see this as something pip should provide, I agree with @pradyunsg that it's veering away from the idea behind To be honest, though, I don't think it would be that hard to write this functionality as a standalone script. I'd even be willing to create an implementation, so can we at least hold off on this for a few days while I find some time to write a prototype? |
I have one already, don't bother :) But it's not completely trivial [to make correct and portable] either especially if you want to run it from outside the environment, and with pip being ubiquitous in environments (either installed in the env, or via the zipapp or ...), it seems natural to me to provide it as it is a so essential, basic and far reaching feature.
With the (or is it mine only?) vision that pip is a CLI for managing the database of installed distribution, it sounds reasonable to have a query command that outputs rich information about what is installed. It can be very simple (all the logic exists) and low maintenance cost. And since we regularly receive requests to add various filters / query options to pip list, with such a command, we can orient users to BTW, this also relates to pip show (see the work in #8008). Personally I'd be fine to have one command that outputs everything and let the user filter details about one single installed distribution, so it would encompass a broad scope of feature requests.
It's true that So I'm perfectly fine with a new subcommand. How would it be named: pip info (suggested recently by @pfmoore ), pip inspect (once suggested by @pradyunsg IIRC ?), or something else ? |
lol, the level of déjà vu I'm getting at the moment is pretty high...
That's a reasonable view of pip's scope. It's not one I'd really thought in terms of previously, and I'm not 100% sure I'm comfortable with it, but if that is how we want to see pip, then I guess I can see how this fits (although until now we've done very little around queries, so it would still be a scope increase in some sense). But if that's how we want to view pip, then I'm unsure how well
Fair enough. High-level philosophy aside, I don't really have a strong opinion here so while I remain probably -0.5 on this, if we're going with it, I'm OK with whatever it gets named, and let's just put whatever seems useful based on the use cases we know about into it. |
Actually, Paul, the zipapp approach comforts me in thinking that pip can be seen as ubiquitous in python environments. Basically all an higher level tool needs to be configured with is the pip command (
If the core is resolve (install --dry-run --report), build wheel, install, uninstall, inspect, then maybe download and wheel are second-order / convenience features of pip ? It should be pretty easy to write pip download on top of the installation/resolution report (and maybe the number of pip download feature requests will go down thanks to it). And pip wheel is "just" download + build, which should be easy to compose too (the pip wheel cache being the highest value component here). |
Hmm, that's not how I see it, but I guess I get your point. I tend to think of this as more that any zipapp can be considered ubiquitous, and so we can distribute functionality how we see fit. But yes, having a zipapp that does everything you want in one place is useful. Thinking further, you could use the runpy approach to have a zipapp that bundles pip and redirects |
An more elaborate alternative is now in #11245 |
Such a metadata field in pip list json output is useful for tools that need to explore the content of a python environment without being installed in it (or are written in other languages than python).
This also helps answering feature requests about extending pip list query options. With a rich output we can ask users to use
jq
or a similar tool to process their queries.This PR sits on top of #11095