From 6d24dda76d82fce5e98010c8ccbee290dd66b087 Mon Sep 17 00:00:00 2001 From: Rafal Rudnicki Date: Fri, 1 Nov 2024 11:28:30 +0100 Subject: [PATCH] fix for python install on self-hosted runners --- .github/workflows/reusable_codeql.yml | 22 ++++++++++++++- .github/workflows/reusable_fast.yml | 39 +++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable_codeql.yml b/.github/workflows/reusable_codeql.yml index e76456310..b57b993a8 100644 --- a/.github/workflows/reusable_codeql.yml +++ b/.github/workflows/reusable_codeql.yml @@ -34,7 +34,27 @@ jobs: with: fetch-depth: 0 - - name: Setup newer Python + - name: Check for Python >= 3.10 + id: check_python + run: | + echo "python_exists=false" >> $GITHUB_OUTPUT + $pythonCommand = Get-Command python -ErrorAction SilentlyContinue + if ($pythonCommand) { + $pythonVersion = python --version 2>&1 + $versionPattern = 'Python (\d+)\.(\d+)\.(\d+)' + echo $pythonVersion + if ($pythonVersion -match $versionPattern) { + $major = [int]$matches[1] + $minor = [int]$matches[2] + if ($major -gt 3 -or ($major -eq 3 -and $minor -ge 10)) { + echo "python_exists=true" >> $GITHUB_OUTPUT + } + } + } + shell: pwsh + + - name: Setup Python 3.10 + if: steps.check_python.outputs.python_exists == 'false' uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 with: python-version: "3.10" diff --git a/.github/workflows/reusable_fast.yml b/.github/workflows/reusable_fast.yml index e25de68a1..3edee5816 100644 --- a/.github/workflows/reusable_fast.yml +++ b/.github/workflows/reusable_fast.yml @@ -62,6 +62,45 @@ jobs: with: fetch-depth: 0 + - name: Check for Python >= 3.10 + if: matrix.os == 'windows-latest' + id: check_python + run: | + echo "python_exists=false" >> $GITHUB_OUTPUT + $pythonCommand = Get-Command python -ErrorAction SilentlyContinue + echo $pythonCommand + $pythonCommand3 = Get-Command python3 -ErrorAction SilentlyContinue + echo $pythonCommand3 + echo $env:PATH + if ($pythonCommand) { + $pythonVersion = python --version 2>&1 + $versionPattern = 'Python (\d+)\.(\d+)\.(\d+)' + echo $pythonVersion + if ($pythonVersion -match $versionPattern) { + $major = [int]$matches[1] + $minor = [int]$matches[2] + if ($major -gt 3 -or ($major -eq 3 -and $minor -ge 10)) { + echo "python_exists=true" >> $GITHUB_OUTPUT + } + } + } + shell: pwsh + + - name: aaa + if: matrix.os == 'windows-latest' + run: | + echo "path: " + $env:PATH + Get-Command python -ErrorAction SilentlyContinue + Get-Command python3 -ErrorAction SilentlyContinue + python3 -m pip install -r third_party/requirements.txt + shell: pwsh + + - name: aaa2 + if: matrix.os == 'windows-latest' + run: | + python3 -m pip install -r third_party/requirements.txt + shell: pwsh + - name: Initialize vcpkg if: matrix.os == 'windows-latest' uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5