pip: [24.1] name== hack for listing package versions no longer works

Description

Previously you could skip the version definition to get a list of version numbers that were compatible with your environment. This was really helpful for debugging or checking if a mirror had picked up an upstream package yet.

Pip 24.0:

(pip_test) $ pip install pip==
Looking in indexes: https://token:****@dl.cloudsmith.io/basic/___/pre-release/python/simple/
ERROR: Could not find a version that satisfies the requirement pip== (from versions: 0.2, 0.2.1, 0.3, 0.3.1, 0.4, 0.5, 0.5.1, 0.6, 0.6.1, 0.6.2, 0.6.3, 0.7, 0.7.1, 0.7.2, 0.8, 0.8.1, 0.8.2, 0.8.3, 1.0, 1.0.1, 1.0.2, 1.1, 1.2, 1.2.1,
 1.3, 1.3.1, 1.4, 1.4.1, 1.5, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 6.0, 6.0.1, 6.0.2, 6.0.3, 6.0.4, 6.0.5, 6.0.6, 6.0.7, 6.0.8, 6.1.0, 6.1.1, 7.0.0, 7.0.1, 7.0.2, 7.0.3, 7.1.0, 7.1.1, 7.1.2, 8.0.0, 8.0.1, 8.0.2, 8.0.3, 8.1.0, 8
.1.1, 8.1.2, 9.0.0, 9.0.1, 9.0.2, 9.0.3, 10.0.0b1, 10.0.0b2, 10.0.0, 10.0.1, 18.0, 18.1, 19.0, 19.0.1, 19.0.2, 19.0.3, 19.1, 19.1.1, 19.2, 19.2.1, 19.2.2, 19.2.3, 19.3, 19.3.1, 20.0, 20.0.1, 20.0.2, 20.1b1, 20.1, 20.1.1, 20.2b1, 20.
2, 20.2.1, 20.2.2, 20.2.3, 20.2.4, 20.3b1, 20.3, 20.3.1, 20.3.2, 20.3.3, 20.3.4, 21.0, 21.0.1, 21.1, 21.1.1, 21.1.2, 21.1.3, 21.2, 21.2.1, 21.2.2, 21.2.3, 21.2.4, 21.3, 21.3.1, 22.0, 22.0.1, 22.0.2, 22.0.3, 22.0.4, 22.1b1, 22.1, 22.1.1, 22.1.2, 22.2, 22.2.1, 22.2.2, 22.3, 22.3.1, 23.0, 23.0.1, 23.1, 23.1.1, 23.1.2, 23.2, 23.2.1, 23.3, 23.3.1, 23.3.2, 24.0, 24.1b1, 24.1b2, 24.1, 24.1.1, 24.1.2)
ERROR: No matching distribution found for pip==

Pip 24.1.2 (happens from 24.1b1 onwards)

(pip_test) $ pip install pip==
ERROR: Invalid requirement: 'pip==': Expected end or semicolon (after name and no valid version specifier)
    pip==
       ^

I assume this was a bit of an undocumented feature and is part of the Remove support for legacy versions and dependency specifiers. change but I can’t find an alternative way to get this information.

This is quite similar to https://github.com/pypa/pip/issues/12749 but focusing on the version numbers rather than the urls

Expected behavior

A list of potential package versions that are compatible with my system.

pip version

24.1.*

Python version

3.11.5

OS

Ubuntu 22.04

How to Reproduce

  • Install pip 24.0 (or below)
  • run pip install <package name>== eg pip install pip==
  • Install pip 24.1.*
  • run pip install <package name>== eg pip install pip==

Output

$ pip install pip== Looking in indexes: https://token:****@dl.cloudsmith.io/basic/___/pre-release/python/simple/ ERROR: Could not find a version that satisfies the requirement pip== (from versions: 0.2, 0.2.1, 0.3, 0.3.1, 0.4, 0.5, 0.5.1, 0.6, 0.6.1, 0.6.2, 0.6.3, 0.7, 0.7.1, 0.7.2, 0.8, 0.8.1, 0.8.2, 0.8.3, 1.0, 1.0.1, 1.0.2, 1.1, 1.2, 1.2.1, 1.3, 1.3.1, 1.4, 1.4.1, 1.5, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 6.0, 6.0.1, 6.0.2, 6.0.3, 6.0.4, 6.0.5, 6.0.6, 6.0.7, 6.0.8, 6.1.0, 6.1.1, 7.0.0, 7.0.1, 7.0.2, 7.0.3, 7.1.0, 7.1.1, 7.1.2, 8.0.0, 8.0.1, 8.0.2, 8.0.3, 8.1.0, 8 .1.1, 8.1.2, 9.0.0, 9.0.1, 9.0.2, 9.0.3, 10.0.0b1, 10.0.0b2, 10.0.0, 10.0.1, 18.0, 18.1, 19.0, 19.0.1, 19.0.2, 19.0.3, 19.1, 19.1.1, 19.2, 19.2.1, 19.2.2, 19.2.3, 19.3, 19.3.1, 20.0, 20.0.1, 20.0.2, 20.1b1, 20.1, 20.1.1, 20.2b1, 20. 2, 20.2.1, 20.2.2, 20.2.3, 20.2.4, 20.3b1, 20.3, 20.3.1, 20.3.2, 20.3.3, 20.3.4, 21.0, 21.0.1, 21.1, 21.1.1, 21.1.2, 21.1.3, 21.2, 21.2.1, 21.2.2, 21.2.3, 21.2.4, 21.3, 21.3.1, 22.0, 22.0.1, 22.0.2, 22.0.3, 22.0.4, 22.1b1, 22.1, 22.1.1, 22.1.2, 22.2, 22.2.1, 22.2.2, 22.3, 22.3.1, 23.0, 23.0.1, 23.1, 23.1.1, 23.1.2, 23.2, 23.2.1, 23.3, 23.3.1, 23.3.2, 24.0, 24.1b1, 24.1b2, 24.1, 24.1.1, 24.1.2) ERROR: No matching distribution found for pip== $ pip install pip== ERROR: Invalid requirement: ‘pip==’: Expected end or semicolon (after name and no valid version specifier) pip== ^

Code of Conduct

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 20 (11 by maintainers)

Commits related to this issue

Most upvoted comments

pip index versions <project> should be a suitable replacement for this trick, although it was definitely unintentional to break this.

Hi All,

I recently updated pip to 24.1. I also saw the removal of informative error message (with package versions) for pip install abc==.

Would it be possible to have it back?

In my opinion it is not a hack it is a very useful feature that people use. It has been in pip for years.

See also, some discussions when it was removed in the past: https://github.com/pypa/pip/issues/9139

Thank you very much for looking into this.

Name: pip Version: 24.2

pip index versions pip 
WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning.
pip (24.2)
Available versions: 24.2, 24.1.2, 24.1.1

I really don’t know why you keep changing this most basic command. Now using index versions will prompt a warning.

WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning.
pip install pip==      
ERROR: Invalid requirement: 'pip==': Expected end or semicolon (after name and no valid version specifier)
    pip==
       ^

This most basic command has been used for many years, why was it suddenly changed?

I’ve never really liked this hack and I strongly prefer stabilizing pip index versions <name> over re-enabling this hack again.

I’d pushed back on this when we added this back into the new resolver (which also “broke” this hack) and my position now is basically the same as it was then: The error we’re presenting here is absolutely the right thing to be doing here, since it’s specific and provides guidance on what went wrong.

We had no reasonable means to get this information earlier but we do now, and I’d really like to stop having people rely on a hack that is non-discoverable via any sensible means, that is exceedingly easy for us to break, that forces us to not be able to improve how the “distribution not found” error is presented and will require some sort of bodge throughout the various pieces to enable.

I think this command has enough milage in order to be considered “official”. Let me know what you think 😄

I think the main thing there is whether the output format is correct and whether we should do something like provide JSON or something by default there.

You “unintentionally” broke the command that was working fine for years. Why not just bring it back?

As already discussed, because packaging no longer parses it, please read through the previous comments so you can have informed comments.

Commment from a side.

You “unintentionally” broke the command that was working fine for years. Why not just bring it back?

Your request @cederom is quite similar to this XKCD comic:

image

Another variant of talking about it is Hyrum’s law https://www.hyrumslaw.com/ - which I very much agree with - which explains that with sufficient complexity “any change is breaking”.

While pip does not use semver, even SemVer is very clear that backwards-compatibility promises are about intentional used and not unintentional side-effects. See https://semver.org/#why-use-semantic-versioning

So I’d say you (and maybe few others) “unintentionally” used something that was never documented.

There are TONS of scripts out there that used pip install package== syntax for years.

I would be very interested to see some stats, do you know how many people do it and why you think a “TON” of usages are there? (note that with pip user base - even reports from few 100s of users would not mean a TON. This feature seems like a hack (and even the title mentions it’s a hack).

Also I think it’s good if you exercise some empathy towards pip maintainers - they attempt to keep their codebase clean - because it makes it easier to develop future versions. Removing a “hack” like that rather than keeping it running will make the more productive and do “more with less” - and their work enables millions of people out there. So any “saving” they do and allow them release pip faster will be multiplied by that for the whole ecosystem.

Converseley - you and few other people changing your scripts to be “proper” - for example use simple API to Pypi in json to retrieve the versions you need (which is about one line of curl + jq or single-liner in Python) is likely something that will take eveyyone a few minutes (but it won’t be multiplied by millions) - so this is a “win-win” situation - you get cleaner, future-proof code, and pipmaintainers are not slowed down.

I think you should try to see that from this perspective.

I don’t think this issue serves any further constructive discussion.

Pip can no longer parse arbitrary strings, such as an empty string, like they are real package versions. This comes from packaging which no longer supports parsing versions that don’t comply with the spec (PEP 440 and onwards).

The primary command to use this now is pip index versions <project>, if there are requests or bugs with that command they should be opened as a new issue and not lost in this issue.

As a workaround, you can specify a valid version, but highly unlikely to ever actual exist, e.g. pip install <package>==3+3 (version 3, local segment version string “3”). Again though, this is not guaranteed to remain that exact same error message for the rest of time.

This most basic command has been used for many years, why was it suddenly changed?

It was an error message not a command, relying on the specific output of user facing error messages between tool versions is a recipie for disaster: https://xkcd.com/1172/. The command still works and still gives you an error.

If you want the same error message workarounds have been given: https://github.com/pypa/pip/issues/12852#issuecomment-2284984035

This command now prompts that it will be deleted.

No, it prompts that the command is experimental, I think a PR to mark it as stable would be accepted at this point.

pip index versions <project>should be a suitable replacement for this trick, although it was definitely unintentional to break this.

WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning.

This command now prompts that it will be deleted.

If we won’t publish the current output people are going to complain that the hack is broken and we will have to re-instate it.

Hi I’m the lead maintainer for puppet and we’ve started getting support requests because puppet can no longer retrieve the list of available packages using pip install abc==versionplease. Having a non-experimental command like pip index versions abc that output JSON would be ideal, but AFAIK the current command is experimental and doesn’t output JSON.

We’ve been using this hack since 2016 (see puppetlabs/puppet@152299cc859fc74343c697841848086d4e41b6f8) so it would be great if this hack could be re-enabled, though I understand why you might not want to do that.

I think the main output looks good to me, however a parameter for some for of machine readable version like JSON seems like a good addition as suggested in these two tickets: https://github.com/pypa/pip/issues/10983 https://github.com/pypa/pip/issues/12749 The other minor upgrade I would like to see, is using pip.conf by default to feed in some of the params. Without this I have to supply my pip index with token and ssh path every time. Thanks

@uranusjr @pradyunsg @ichard26 although this breakage probably was not intentional- lets stabilize pip index! (#12342) I think this command has enough milage in order to be considered “official”. Let me know what you think 😄