Skip to content

Commit 11d3a5e

Browse files
committed
ci: set up Python with uv on self-hosted Linux and macOS runners
actions/setup-python only has interpreters for GitHub's runner images, so it failed on the self-hosted Ubuntu 26.04 runners ("The version '3.12.8' with architecture 'x64' was not found for Ubuntu 26.04"). Install the requested version with uv (python-build-standalone) into a virtualenv with pip and put it first on the PATH; Windows keeps setup-python.
1 parent 27e7c31 commit 11d3a5e

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

‎.github/workflows/ci-matrix-gen.yml‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,25 @@ jobs:
126126
127127
128128
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
129-
if: ${{ matrix.python_version }}
129+
if: ${{ runner.os == 'Windows' && matrix.python_version }}
130130
with:
131131
python-version: ${{ matrix.python_version }}
132+
# actions/setup-python only has interpreters for GitHub's own runner images, so on
133+
# the self-hosted Linux and macOS runners the version comes from uv (python-build-standalone),
134+
# in a virtualenv with pip that is put first on the PATH.
135+
- name: Set up Python with uv
136+
if: ${{ runner.os != 'Windows' && matrix.python_version }}
137+
shell: bash
138+
env:
139+
UV_VERSION: 0.12.20
140+
PYTHON_VERSION: ${{ matrix.python_version }}
141+
run: |
142+
export UV_INSTALL_DIR="$RUNNER_TEMP/uv/bin" UV_PYTHON_INSTALL_DIR="$RUNNER_TEMP/uv/python" UV_NO_MODIFY_PATH=1
143+
curl -LsSf "https://astral.sh/uv/${UV_VERSION}/install.sh" | sh
144+
rm -rf "$RUNNER_TEMP/python-venv"
145+
"$UV_INSTALL_DIR/uv" venv --seed --python "$PYTHON_VERSION" "$RUNNER_TEMP/python-venv"
146+
echo "$RUNNER_TEMP/python-venv/bin" >> "$GITHUB_PATH"
147+
"$RUNNER_TEMP/python-venv/bin/python" --version
132148
- name: Install python packages on Unix
133149
if: ${{ runner.os != 'Windows' && matrix.python_packages }}
134150
run: |

0 commit comments

Comments
 (0)