Skip to content

Commit 1d82903

Browse files
committed
fix for python install on self-hosted runners
1 parent b3bbdd4 commit 1d82903

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

.github/workflows/reusable_basic.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,28 @@ jobs:
255255
with:
256256
fetch-depth: 0
257257

258+
- name: Check for Python >= 3.10
259+
id: check_python
260+
run: |
261+
echo "python_exists=false" >> $GITHUB_OUTPUT
262+
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
263+
echo $pythonCommand
264+
$pythonCommand3 = Get-Command python3 -ErrorAction SilentlyContinue
265+
echo $pythonCommand3
266+
if ($pythonCommand) {
267+
$pythonVersion = python --version 2>&1
268+
$versionPattern = 'Python (\d+)\.(\d+)\.(\d+)'
269+
echo $pythonVersion
270+
if ($pythonVersion -match $versionPattern) {
271+
$major = [int]$matches[1]
272+
$minor = [int]$matches[2]
273+
if ($major -gt 3 -or ($major -eq 3 -and $minor -ge 10)) {
274+
echo "python_exists=true" >> $GITHUB_OUTPUT
275+
}
276+
}
277+
}
278+
shell: pwsh
279+
258280
- name: Initialize vcpkg
259281
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
260282
with:

.github/workflows/reusable_codeql.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,27 @@ jobs:
3434
with:
3535
fetch-depth: 0
3636

37-
- name: Setup newer Python
37+
- name: Check for Python >= 3.10
38+
id: check_python
39+
run: |
40+
echo "python_exists=false" >> $GITHUB_OUTPUT
41+
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
42+
if ($pythonCommand) {
43+
$pythonVersion = python --version 2>&1
44+
$versionPattern = 'Python (\d+)\.(\d+)\.(\d+)'
45+
echo $pythonVersion
46+
if ($pythonVersion -match $versionPattern) {
47+
$major = [int]$matches[1]
48+
$minor = [int]$matches[2]
49+
if ($major -gt 3 -or ($major -eq 3 -and $minor -ge 10)) {
50+
echo "python_exists=true" >> $GITHUB_OUTPUT
51+
}
52+
}
53+
}
54+
shell: pwsh
55+
56+
- name: Setup Python 3.10
57+
if: steps.check_python.outputs.python_exists == 'false'
3858
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
3959
with:
4060
python-version: "3.10"

0 commit comments

Comments
 (0)