Skip to content

Commit b847cdf

Browse files
authored
#527: Use correct Python version in actions/python-environment (#528)
fixes #527
1 parent 997be54 commit b847cdf

File tree

4 files changed

+65
-14
lines changed

4 files changed

+65
-14
lines changed

.github/actions/python-environment/action.yml

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ inputs:
1111
poetry-version:
1212
description: 'Poetry version to use'
1313
required: true
14-
default: "2.1.2"
14+
default: "2.1.4"
1515

1616
working-directory:
1717
description: 'Working directory to use'
@@ -32,29 +32,61 @@ runs:
3232
using: "composite"
3333
steps:
3434

35-
- name: Set up pipx if not present
35+
36+
- name: Set up Python (${{ inputs.python-version}})
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: ${{ inputs.python-version }}
40+
41+
- name: Ensure wget
42+
shell: bash
43+
run: sudo apt update && sudo apt install -y wget
44+
45+
- name: Set up Poetry (${{ inputs.poetry-version }})
3646
shell: bash
3747
run: |
38-
sudo apt update && sudo apt install -y pipx
39-
python3 -m pipx ensurepath
48+
wget --tries=10 --waitretry 10 --retry-connrefused --https-only -O - https://install.python-poetry.org | POETRY_VERSION="${{ inputs.poetry-version }}" "$PYTHON_BINARY" -
4049
echo "$HOME/.local/bin" >> $GITHUB_PATH
50+
env:
51+
PYTHON_BINARY: "python${{ inputs.python-version }}"
4152

42-
- name: Set up Poetry (${{ inputs.poetry-version }})
53+
- name: Setup cache variables
54+
id: setup-cache-variables
4355
shell: bash
44-
run: pipx install poetry==${{ inputs.poetry-version }}
56+
run: |
57+
echo "ImageOS=$ImageOS"
58+
echo "ImageVersion=$ImageVersion"
59+
POETRY_ENV_PATH=$(poetry config virtualenvs.path)
60+
POETRY_SHA=$(sha256sum poetry.lock | awk '{print $1}') #Remove trailing filename
61+
echo "POETRY_ENV_PATH=$POETRY_ENV_PATH" >> $GITHUB_OUTPUT
62+
echo "IMAGE_OS=$ImageOS" >> $GITHUB_OUTPUT
63+
echo "IMAGE_VERSION=$ImageVersion" >> $GITHUB_OUTPUT
64+
echo "POETRY_SHA=$POETRY_SHA" >> $GITHUB_OUTPUT
65+
4566
46-
- name: Set up Python (${{ inputs.python-version}})
47-
uses: actions/setup-python@v5
67+
- name: Cache Poetry environment
68+
if: inputs.use-cache == 'true'
69+
id: cache-poetry-env
70+
uses: actions/cache@v4
4871
with:
49-
python-version: ${{ inputs.python-version }}
50-
cache: ${{ inputs.use-cache == 'true' && 'poetry' || '' }}
72+
path: ${{ steps.setup-cache-variables.outputs.POETRY_ENV_PATH }}
73+
key: poetry-env-${{ steps.setup-cache-variables.outputs.POETRY_SHA }}-${{ steps.setup-cache-variables.outputs.IMAGE_OS }}-${{ steps.setup-cache-variables.outputs.IMAGE_VERSION }}-${{ runner.arch }}-${{ inputs.poetry-version }}-${{ inputs.python-version }}-${{ inputs.extras }}
5174

5275
- name: Poetry install with extras
76+
if: inputs.use-cache != 'true' || steps.cache-poetry-env.outputs.cache-hit != 'true'
5377
working-directory: ${{ inputs.working-directory }}
5478
shell: bash
5579
run: |
80+
EXTRAS=$(echo "${{ inputs.extras }}" | tr -d ' ')
5681
if [[ -n "$EXTRAS" ]]; then
5782
poetry install --extras "$EXTRAS"
5883
else
5984
poetry install
6085
fi
86+
87+
- name: Validate Poetry environment
88+
working-directory: ${{ inputs.working-directory }}
89+
shell: bash
90+
run: |
91+
poetry run python --version
92+
poetry run python --version | grep "${{ inputs.python-version }}"

.github/workflows/slow-checks.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,30 @@ jobs:
5959
- int-linux-x64-4core-gpu-t4-ubuntu24.04-1
6060
- int-linux-x64-4core-ubuntu24.04-1
6161
- int-linux-x64-2core-ubuntu24.04-1
62-
name: Install Pipx on ${{ matrix.runner }}
62+
python-version:
63+
- "3.10"
64+
- "3.11"
65+
- "3.12"
66+
- "3.13"
67+
name: Install Pipx on ${{ matrix.runner }} with Python "${{ matrix.python-version }}"
6368
runs-on:
6469
labels: ${{ matrix.runner }}
6570

6671
steps:
6772
- name: SCM Checkout
6873
uses: actions/checkout@v4
6974

70-
- name: Setup Python & Poetry Environment
75+
- name: Set up Python & Poetry Environment
7176
uses: ./.github/actions/python-environment
77+
with:
78+
python-version: "${{ matrix.python-version }}"
7279

7380
- name: Poetry version
7481
run: poetry --version
82+
83+
- name: Validate Python version
84+
run: |
85+
poetry run which python
86+
poetry run python --version
87+
poetry env list
88+
poetry run python --version | grep "${{ matrix.python-version }}"

doc/changes/changes_1.7.3.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@
22
## Bugfixes
33

44
* #523: Fixed `pipx` installation for older versions of `pip`
5+
6+
## Refactorings
7+
8+
* #525: Added tests for installing `pipx` on different GitHub runners
9+

doc/changes/unreleased.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Unreleased
22

3-
## Refactorings
3+
## Bugfixes
44

5-
* #525: Added tests for installing `pipx` on different GitHub runners
5+
* #527: Use correct Python version in actions/python-environment

0 commit comments

Comments
 (0)