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

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

Open
2 of 5 tasks
juftin opened this issue Oct 23, 2024 · 9 comments
Open
2 of 5 tasks

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

juftin opened this issue Oct 23, 2024 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@juftin
Copy link

juftin commented Oct 23, 2024

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:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

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 juftin added bug Something isn't working needs triage labels Oct 23, 2024
@juftin
Copy link
Author

juftin commented Oct 23, 2024

@juftin
Copy link
Author

juftin commented Oct 23, 2024

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 }}

@priyagupta108
Copy link
Contributor

Hi @juftin 👋,
Thank you for your report. We'll investigate the issue and get back to you with the details!

@zariiii9003
Copy link

Same problem here.

@priya-kinthali
Copy link
Contributor

Hello @juftin 👋,
The pipx utility is provided by the runner image. It appears that the change in behaviour you observed is due to the ubuntu-latest label reverting from Ubuntu-24 (Default python 3.12.3) to Ubuntu-22 (Default python 3.10.12) on Oct 16 as per this comment. It seems like the pipx is using the runner's default Python version unless explicitly configured otherwise.
As you correctly mentioned, using the PIPX_DEFAULT_PYTHON environment variable allows specifying the Python version that pipx should use.
Additionally, You might also consider using the following workaround to ensure pipx uses the specified Python version:

- name: Setup Python
  id: python
  uses: actions/setup-python@v5
  with:
    python-version: "3.12"
- name: Install pipx
  run: python -m pip install --user pipx
- name: Ensure pipx uses the correct Python
  run: python -m pipx ensurepath
- name: Install Python Package
  run: pipx install .

This setup explicitly installs pipx, which then installs the desired Python package using the specified Python version. Please find the successful run here.
Hope this helps!
Since this is related to the runner rather than the setup-python action, we recommend raising a ticket in the runner-images repository for any further concerns.
Thankyou!

@zariiii9003
Copy link

@priya-kinthali Would it be possible for actions/setup-python to configure pipx to use the selected python version? Maybe you could set PIPX_DEFAULT_PYTHON so the user doesn't have to?

@priya-kinthali
Copy link
Contributor

Hello @zariiii9003 👋,
The setup-python action does not manage or configure tools like pipx. The configuration of pipx is handled by the runner environment itself. Managing pipx within the action could lead to conflicts or unexpected behaviour in different environments.
Therefore, we kindly recommend setting the PIPX_DEFAULT_PYTHON environment variable in your workflow or manually installing pipx using python -m pip install --user pipx.
Thank you for your understanding.

@priya-kinthali
Copy link
Contributor

Hello @juftin 👋,
Just a gentle reminder!

@priya-kinthali
Copy link
Contributor

Hello @juftin 👋,
Just following up to see if you have any other concerns or need any assistance. Please let us know if there's anything else we can help with.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants