-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
What's the problem this feature will solve?
Since the pip install pip== "hack" stopped working, I do not believe there is a "stable" pip-centric way to list all the versions of a package. It is possible to query the HTTP API, but this may not be desirable for all users.
I myself have been asking colleagues to use the command when helping them debug the versions they have available to them and in their environments. I have found it stable and easy to use, and would love to be able to use it more widely without worry that it could be unexpectedly removed.
pip index versions was introduced over 4 years ago in #8978, and viewing the commit history, it does not appear to have changed very much since then.
In relevant issues such as #12852, it was mentioned that a PR to remove the experimental status may well be considered and possibly merged, so I am proposing it here.
Describe the solution you'd like
- remove the warning about
pip index versionsbeing experimental - add documentation on the command
- add a
--jsonflag
The code for the --json flag could be something like:
if options.json:
env = get_default_environment()
dist = env.get_distribution(query)
structured_output = {
"name": query,
"versions": formatted_versions,
"latest": latest,
}
if dist is not None:
structured_output["installed_version"] = dist.version
write_output(structured_output)
returnresulting in an output like:
{
"name": "package-name",
"versions": ["1.0.0", "1.0.1", ...],
"latest": "2.0.0",
"installed_version": "1.0.0" // if installed
}Alternative Solutions
Not making any change to pip
Additional context
This would be an entirely backwards-compatible change.
I'm happy to bring this PR!
Code of Conduct
- I agree to follow the PSF Code of Conduct.