Skip to content
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 does not work with development versions of CPython due to parse error on version string #12691

Open
1 task done
tacaswell opened this issue May 10, 2024 · 6 comments
Open
1 task done
Labels
type: bug A confirmed bug or unintended behavior
Milestone

Comments

@tacaswell
Copy link

tacaswell commented May 10, 2024

Description

The version string of development versions of CPython end with +, e.g. 3.12.3+ which causes errors in pip.

caused by #12300

Expected behavior

pip accepts the version string on the development versions of CPython.

pip version

approximately current main branch

Python version

3.12.3+ (the 3.12 branch)

OS

arch

How to Reproduce

  1. install development version of CPython from 3.12 branch (but I suspect any of the 3.X branches will show this)
  2. install a from a branch of pip that contains 47a8480
  3. try to install anything that specifies python versions (in my case it was build)

Output

(bleeding) ~/s/p/p/build main|✓
✘ 13:41:38 [belanna] @ pip install . --no-build-isolation
Processing /home/tcaswell/source/p/pypa/build
  Preparing metadata (pyproject.toml) ... done
ERROR: Exception:
Traceback (most recent call last):
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper
    status = run_func(*args)
             ^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_internal/cli/req_command.py", line 247, in wrapper
    return func(self, options, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_internal/commands/install.py", line 377, in run
    requirement_set = resolver.resolve(
                      ^^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 95, in resolve
    result = self._result = resolver.resolve(
                            ^^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers.py", line 427, in resolve
    failure_causes = self._attempt_to_pin_criterion(name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers.py", line 239, in _attempt_to_pin_criterion
    criteria = self._get_updated_criteria(candidate)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers.py", line 229, in _get_updated_criteria
    for requirement in self._p.get_dependencies(candidate=candidate):
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/provider.py", line 247, in get_dependencies
    return [r for r in candidate.iter_dependencies(with_requires) if r is not None]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 243, in iter_dependencies
    for r in requires:
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_dists.py", line 222, in iter_dependencies
    elif not extras and req.marker.evaluate({"extra": ""}):
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_vendor/packaging/markers.py", line 252, in evaluate
    return _evaluate_markers(self._markers, current_environment)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_vendor/packaging/markers.py", line 158, in _evaluate_markers
    groups[-1].append(_eval_op(lhs_value, op, rhs_value))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_vendor/packaging/markers.py", line 116, in _eval_op
    return spec.contains(lhs, prereleases=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_vendor/packaging/specifiers.py", line 568, in contains
    normalized_item = _coerce_version(item)
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_vendor/packaging/specifiers.py", line 36, in _coerce_version
    version = Version(version)
              ^^^^^^^^^^^^^^^^
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.12/site-packages/pip/_vendor/packaging/version.py", line 200, in __init__
    raise InvalidVersion(f"Invalid version: '{version}'")
pip._vendor.packaging.version.InvalidVersion: Invalid version: '3.12.3+'

Code of Conduct

@tacaswell tacaswell added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels May 10, 2024
@pradyunsg pradyunsg removed the S: needs triage Issues/PRs that need to be triaged label May 10, 2024
@sbidoul sbidoul added this to the 24.1 milestone May 11, 2024
@sbidoul
Copy link
Member

sbidoul commented May 11, 2024

@tacaswell do you have a dependency with a python_full_version environment marker ?

@pradyunsg
Copy link
Member

@notatallshaw
Copy link
Contributor

notatallshaw commented May 18, 2024

Is this considered a blocker for pip 24.1?

uv has taken the approach of fixing up versions that are not PEP 440 compliant, in particular this is how they handle python_full_version: https://github.com/astral-sh/uv/pull/1771/files

Might it be worth applying the same on pip side for python_full_version specifically?

@sbidoul
Copy link
Member

sbidoul commented May 19, 2024

I have proposed pypa/packaging#802 to fix this.

@stonebig
Copy link
Contributor

stonebig commented May 20, 2024

hello, I'm apparently maybe by this also in a constraint file:

ERROR: Invalid requirement: 'python-hdf4>=0.10.0+dummy' (from line 436 of ...\constraints.txt)

is this the same bug ? and solution ?

@sbidoul
Copy link
Member

sbidoul commented May 20, 2024

@stonebig this is another issue:

InvalidRequirement: Local version label can only be used with `==` or `!=` operators
    python-hdf4>=0.10.0+dummy
               ~~~~~~~~^

Pip should show the detailed error, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

5 participants