Skip to content

Commit 1384e3a

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

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

.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"

.github/workflows/reusable_fast.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,45 @@ jobs:
6262
with:
6363
fetch-depth: 0
6464

65+
- name: Check for Python >= 3.10
66+
if: matrix.os == 'windows-latest'
67+
id: check_python
68+
run: |
69+
echo "python_exists=false" >> $GITHUB_OUTPUT
70+
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
71+
echo $pythonCommand
72+
$pythonCommand3 = Get-Command python3 -ErrorAction SilentlyContinue
73+
echo $pythonCommand3
74+
echo $env:PATH
75+
if ($pythonCommand) {
76+
$pythonVersion = python --version 2>&1
77+
$versionPattern = 'Python (\d+)\.(\d+)\.(\d+)'
78+
echo $pythonVersion
79+
if ($pythonVersion -match $versionPattern) {
80+
$major = [int]$matches[1]
81+
$minor = [int]$matches[2]
82+
if ($major -gt 3 -or ($major -eq 3 -and $minor -ge 10)) {
83+
echo "python_exists=true" >> $GITHUB_OUTPUT
84+
}
85+
}
86+
}
87+
shell: pwsh
88+
89+
- name: aaa
90+
if: matrix.os == 'windows-latest'
91+
run: |
92+
echo "path: " + $env:PATH
93+
python --version
94+
python3 --version
95+
python3 -m pip install -r third_party/requirements.txt
96+
shell: pwsh
97+
98+
- name: aaa2
99+
if: matrix.os == 'windows-latest'
100+
run: |
101+
python3 -m pip install -r third_party/requirements.txt
102+
shell: pwsh
103+
65104
- name: Initialize vcpkg
66105
if: matrix.os == 'windows-latest'
67106
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5

0 commit comments

Comments
 (0)