pypa/pip

Pip fails on different compatible ~= version specifiers

Closed this issue · 1 comments

Description

The issue #9613 is marked as completed, but using the latest version of Python, and the latest version of pip, it seems like the issue is still present.

Expected behavior

No response

pip version

24.0

Python version

3.12.3

OS

Mac OS

How to Reproduce

Let's use tqdm for this test, as it is a popular pure python package.
Currently, the latest version on pypi is tqdm 4.66.4

For each test, start with a new Python env and try to run the following:
pip install tqdm~=4.65 tqdm~=4.65.0 - Fails

pip install tqdm~=4.66 tqdm~=4.66.0 - OK
pip install tqdm~=4.66 - OK
pip install tqdm~=4.66.0 - OK
pip install tqdm~=4.65 - OK
pip install tqdm~=4.65.0 - OK

Output

Python 3.12.3
ᐅ python -m pip --version
pip 24.0 from /Users/idan.miara/.pyenv/versions/tmp/lib/python3.12/site-packages/pip (python 3.12)
ᐅ python -m pip install pip install tqdm~=4.65 tqdm~=4.65.0
Requirement already satisfied: pip in /Users/idan.miara/.pyenv/versions/tmp/lib/python3.12/site-packages (24.0)
Collecting install
  Downloading install-1.3.5-py3-none-any.whl.metadata (925 bytes)
Collecting tqdm~=4.65
  Using cached tqdm-4.66.4-py3-none-any.whl.metadata (57 kB)
ERROR: Exception:
Traceback (most recent call last):
  File "/Users/idan.miara/.pyenv/versions/tmp/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper
    status = run_func(*args)
             ^^^^^^^^^^^^^^^
  File "/Users/idan.miara/.pyenv/versions/tmp/lib/python3.12/site-packages/pip/_internal/cli/req_command.py", line 245, in wrapper
    return func(self, options, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/idan.miara/.pyenv/versions/tmp/lib/python3.12/site-packages/pip/_internal/commands/install.py", line 377, in run
    requirement_set = resolver.resolve(
                      ^^^^^^^^^^^^^^^^^
  File "/Users/idan.miara/.pyenv/versions/tmp/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 95, in resolve
    result = self._result = resolver.resolve(
                            ^^^^^^^^^^^^^^^^^
  File "/Users/idan.miara/.pyenv/versions/tmp/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/idan.miara/.pyenv/versions/tmp/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers.py", line 427, in resolve
    failure_causes = self._attempt_to_pin_criterion(name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/idan.miara/.pyenv/versions/tmp/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers.py", line 254, in _attempt_to_pin_criterion
    raise InconsistentCandidate(candidate, criterion)
pip._vendor.resolvelib.resolvers.InconsistentCandidate: Provided candidate LinkCandidate('https://files.pythonhosted.org/packages/18/eb/fdb7eb9e48b7b02554e1664afd3bd3f117f6b6d6c5881438a0b055554f9b/tqdm-4.66.4-py3-none-any.whl (from https://pypi.org/simple/tqdm/) (requires-python:>=3.7)') does not satisfy SpecifierRequirement('tqdm~=4.65'), SpecifierRequirement('tqdm~=4.65.0')
ᐅ 

Code of Conduct

Pip hasn't had a final release since #9613 was marked as completed.

You can either test this on pip main, the beta (24.1b1), or wait for pip 24.1 to release (should be very soon, once CI issues are fixed).