Skip to content

Commit 1eefa67

Browse files
committed
Auto merge of #71995 - pietroalbini:ci-windows-detect-latest-python, r=Mark-Simulacrum
[CI] Use the latest Python available on Windows This PR changes our Windows CI to always use the latest Python interpreter available in the GHA tool cache instead of hardcoding Python 3.7.6. This is needed because occasionally GitHub bumps the installed version, deleting the previous one. This fixes the current GHA outage we're having. I fully expect the outage to propagate to Azure Pipelines in the coming days if we don't merge this, as both GHA and Azure use the same underlying image. Once the PR is merged we can re-enabled the double-gating. r? @Mark-Simulacrum
2 parents a08c473 + de2d987 commit 1eefa67

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/ci/scripts/install-msys2-packages.sh

+10-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,19 @@ if isWindows; then
99
pacman -S --noconfirm --needed base-devel ca-certificates make diffutils tar \
1010
binutils
1111

12+
# Detect the native Python version installed on the agent. On GitHub
13+
# Actions, the C:\hostedtoolcache\windows\Python directory contains a
14+
# subdirectory for each installed Python version.
15+
#
16+
# The -V flag of the sort command sorts the input by version number.
17+
native_python_version="$(ls /c/hostedtoolcache/windows/Python | sort -Vr | head -n 1)"
18+
1219
# Make sure we use the native python interpreter instead of some msys equivalent
1320
# one way or another. The msys interpreters seem to have weird path conversions
1421
# baked in which break LLVM's build system one way or another, so let's use the
1522
# native version which keeps everything as native as possible.
16-
python_home="C:/hostedtoolcache/windows/Python/3.7.6/x64"
23+
python_home="/c/hostedtoolcache/windows/Python/${native_python_version}/x64"
1724
cp "${python_home}/python.exe" "${python_home}/python3.exe"
18-
ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\3.7.6\\x64"
25+
ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64"
26+
ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64\\Scripts"
1927
fi

0 commit comments

Comments
 (0)