actions / setup-python

Set up your GitHub Actions workflow with a specific version of Python
MIT License
1.7k stars 542 forks source link

pipx doesn't respect actions/setup-python version #967

Open juftin opened 3 hours ago

juftin commented 3 hours ago

Description:

I'm not sure if this is an issue with actions/setup-python, pipx, or the runners themselves - but the behavior for this changed for me between 2024-10-15 and 2024-10-16 (if you think this should be reported elsewhere please let me know)

In the below workflow, the setup-python-example Python package requires Python >= 3.11

name: test
on:
  push:
    branches:
      - main
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Get Python version
        run: python --version
      - name: Get pipx version
        run: pipx --version
      - name: Install Python Package
        run: pipx install .

Before 2024-10-16 the example package was installed using Python 3.12, but after it uses Python 3.10 and the workflow fails.

creating virtual environment...
determining package name from '/home/runner/work/setup-python-example/setup-python-example'...
ERROR: Package 'setup-python-example' requires a different Python: 3.10.[12](https://github.com/juftin/setup-python-example/actions/runs/11471145881/job/31921582259#step:6:13) not in '>=3.11'
Cannot determine package name from spec
'/home/runner/work/setup-python-example/setup-python-example'. Check package
spec for errors.

Action version:

v5

Platform:

Runner type:

Tools version: 3.12

Repro steps:

1) Use ubuntu-latest runner 2) Run actions/setup-python@v5 with version 3.12 3) Install a package the requires Python >= 3.11

The action will fail because pipx is trying to use Python 3.10.

Expected behavior:

I expect pipx to use whatever version is setup with actions/setup-python

Actual behavior:

I believe pipx is using the runner's default Python version

juftin commented 3 hours ago

Here is an example repo to reproduce this: https://github.com/juftin/setup-python-example

and the failing workflow: https://github.com/juftin/setup-python-example/actions/runs/11471145881/job/31921582259

juftin commented 3 hours ago

I was able to confirm that the following resolved the issue - but I'm still not clear why the behavior changed ~ a week ago

name: test
on:
  push:
    branches:
      - main
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Setup Python
        id: python
        uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Install Python Package
        run: pipx install .
        env:
          PIPX_DEFAULT_PYTHON: ${{ steps.python.outputs.python-path }}