Skip to content

pip fails in GitHub action with Invalid version (image name!) #12825

Description

@MAKOMO

Description

Not an expert on anything, but my GitHub actions stop failing with pip 24.1 and 24.1.1

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Set up Python 3.12
      uses: actions/setup-python@v5
      with:
        python-version: '3.12'
        cache: 'pip' # caching pip dependencies
    - name: Install dependencies
      run: |
        pip install -v -r src/requirements-dev.txt
        pip install -v -r src/requirements.txt

the error is reported like this:

[cut]
Using pip 24.0 from /opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/pip (python 3.12)
Ignoring python-snap7: markers 'python_version < "3.10"' don't match your environment
Ignoring typing-extensions: markers 'python_version < "3.8"' don't match your environment
Ignoring numpy: markers 'python_version < "3.9"' don't match your environment
Ignoring scipy: markers 'python_version < "3.9"' don't match your environment
Ignoring matplotlib: markers 'python_version < "3.9"' don't match your environment
ERROR: Exception:
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 179, in exc_logging_wrapper
    status = run_func(*args)
             ^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/pip/_internal/cli/req_command.py", line 67, in wrapper
    return func(self, options, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/pip/_internal/commands/install.py", line 377, in run
    requirement_set = resolver.resolve(
                      ^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/pip/_internal/resolution/legacy/resolver.py", line [171](https://github.com/artisan-roaster-scope/artisan/actions/runs/9804461097/job/27072280543#step:4:172), in resolve
    self._add_requirement_to_set(requirement_set, req)
  File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/pip/_internal/resolution/legacy/resolver.py", line 213, in _add_requirement_to_set
    if not install_req.match_markers(extras_requested):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/pip/_internal/req/req_install.py", line 285, in match_markers
    return any(
           ^^^^
  File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/pip/_internal/req/req_install.py", line 286, in <genexpr>
    self.markers.evaluate({"extra": extra}) for extra in extras_requested
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/pip/_vendor/packaging/markers.py", line 325, in evaluate
    return _evaluate_markers(self._markers, current_environment)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/pip/_vendor/packaging/markers.py", line 225, in _evaluate_markers
    groups[-1].append(_eval_op(lhs_value, op, rhs_value))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/pip/_vendor/packaging/markers.py", line [183](https://github.com/artisan-roaster-scope/artisan/actions/runs/9804461097/job/27072280543#step:4:184), in _eval_op
    return spec.contains(lhs, prereleases=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/pip/_vendor/packaging/specifiers.py", line 552, in contains
    normalized_item = _coerce_version(item)
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/pip/_vendor/packaging/specifiers.py", line 28, in _coerce_version
    version = Version(version)
              ^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/pip/_vendor/packaging/version.py", line 202, in __init__
    raise InvalidVersion(f"Invalid version: '{version}'")
pip._vendor.packaging.version.InvalidVersion: Invalid version: '6.5.0-1022-azure'
Error: Process completed with exit code 2.

It remains unclear which version and of which package is wrong here (not sticking to the semantic versioning rules?), so I was searching for the string '6.5.0-1022-azure' and could find that one as the image name of the VirtualMachine.

pining pip version to 24.0 before the installs resolves this:

        pip install --upgrade pip==24.0

Now it states:

Run pip install --upgrade pip==24.0 # downgrade pip as pip v24.1 fails with pip._vendor.packaging.version.InvalidVersion: Invalid version: '6.5.0-1022-azure' (image name!)
  pip install --upgrade pip==[2](https://github.com/artisan-roaster-scope/artisan/actions/runs/9804689913/job/27072913658#step:4:2)4.0 # downgrade pip as pip v24.1 fails with pip._vendor.packaging.version.InvalidVersion: Invalid version: '6.5.0-1022-azure' (image name!)
  pip install -v -r src/requirements-dev.txt
  pip install -v -r src/requirements.txt
  shell: /usr/bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/[3](https://github.com/artisan-roaster-scope/artisan/actions/runs/9804689913/job/27072913658#step:4:3).12.4/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.12.[4](https://github.com/artisan-roaster-scope/artisan/actions/runs/9804689913/job/27072913658#step:4:4)/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.4/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.4/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.4/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.4/x64/lib
Collecting pip==24.0
  Downloading pip-24.0-py3-none-any.whl.metadata (3.6 kB)
Downloading pip-24.0-py3-none-any.whl (2.1 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 9[5](https://github.com/artisan-roaster-scope/artisan/actions/runs/9804689913/job/27072913658#step:4:5).5 MB/s eta 0:00:00
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 24.1.1
    Uninstalling pip-24.1.1:
      Successfully uninstalled pip-24.1.1
Successfully installed pip-24.0

Notice:  A new release of pip is available: 24.0 -> 24.1.1
Notice:  To update, run: pip install --upgrade pip
Using pip 24.0 from /opt/hostedtoolcache/Python/3.12.4/x[6](https://github.com/artisan-roaster-scope/artisan/actions/runs/9804689913/job/27072913658#step:4:6)4/lib/python3.12/site-packages/pip (python 3.12)

reporting the issue is indeed in the "(image name!)" and those pip installs work.

Does the GitHub action image needs to stick to the Python/pip semantic versioning rules as well?

Expected behavior

ignore the image version and just sucessfuly complete

pip version

24.1.0 and 24.1.1

Python version

Python 3.12 and 3.11 (maybe independent of the Python version)

OS

Ubuntu

How to Reproduce

  1. Setup a GitHub actions along the lines above
  2. Run the action

Output

No response

Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions