-
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 show --json #5261
Comments
Why not utilize PyPI's APIs directly? See: https://pypi.org/pypi/pip/json and https://warehouse.pypa.io/api-reference/json/ If that resolves your concern, feel free to close this issue. :) |
pip show doesn't need internet access, and works with packages that only exist locally. |
IMO, parsing the output of >>> import subprocess
>>> from email.parser import BytesHeaderParser
>>> p = subprocess.run([sys.executable, '-m', 'pip', 'show', 'pip', '--files'], stdout=subprocess.PIPE)
>>> h = BytesHeaderParser().parsebytes(p.stdout)
>>> print(h['Name'])
pip But I don't see any reason why we would reject a PR that added a |
Indeed. Silly me. That said, I second everything @pfmoore said above. |
Fair enough. I don't think the format is document though (is it intended to be stable?). |
It's shown in the docs, but I take your point. |
Happy to accept a PR that adds this to the documentation. |
Hi! I was wondering, because solving this problem requires adding an option to show.py, how exactly does the dest work in self.cmd_opts.add_option()? Does it need to be an attribute pre-existing in options in order to get the value given to it by the action? |
Hi, it appears that the PR related to this issue has been merged already. Can we consider close this issue? |
@pradyunsg Please move to in progress |
@weakcamel Thanks for flagging this. FYI @MarckK opened a new PR at #5954, which is showing up in this issue. |
Since |
This pull request that we initially created adds --json to pip show, but it was deemed unnecessary. The code is already created for an older version of pip (summer 2018) https://github.com/kunalJa/pip |
Is this still considered? I don't see |
@achillesrasquinha Would you mind provide some examples? We’ll need to decide
|
One note
This has never been necessary - pip itself uses For example:
On my machine: Output
This has several upsides vs implementing
|
One scenario |
What does "compatibility layer" mean in this context? |
I was kind of speculating into the far future (probably too far). With PEP 517 gaining usage, I assume setuptools could be less required in an environment, and some people will start trying to remove it in the future (and just have pip). |
The example you're showing isn't doing what pip show would, it doesn't support all the options pip does. Sure, it can be extended to emulate what Why not have support the output format in
Are you saying that it's a cleaner interface to call Python interpreter from shell/Perl/C++ code and feed it with an inline script to execute? ;-) I beg to differ. |
See my comment above: #5261 (comment) The RFC non-compliant part is the separator between the packages. IMO the email header format is a bit unfortunate choice in case of >1 packages; to make it RFC compliant, pip would need to implement "multipart" Content-Type and what would it even mean in context of IMO the easiest way forward would be to leave the existing legacy format as-is and just provide a format flag to be automation-friendly. |
A case where |
Hi Folks, I have taken an initial stab at adding json format to Please feel free to take a look at the implementation and critique it :) |
A similar feature has been implemented as |
Description:
This is a feature request, related to #3568 and 4824, but made more necessary by the privatization of pip's internals: let
pip show
gain a--json
flag (or--format=(humanreadable|json)
) (also handlingpip show --files
) that outputs the result as json (or whatever other format you deem suitable, but pip list already has--format=json
(hence the suggestion of--format=json
instead of--json
above). Otherwise, it becomes necessary to either parse the output of pip show, or to just copy-paste pip's implementation, in order to access the same metadata.What I've run:
e.g.
The text was updated successfully, but these errors were encountered: