From 99bf8418ee076e81c3ea7b1df333afdf3227967d Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 5 Apr 2023 13:12:36 -0400 Subject: ci: Update to Python 3.11.3 in Windows jobs Use the official embedded distribution `.zip` files, but put copies at URLs we control. --- .gitlab/ci/download_python3.cmake | 41 --------------------------------------- .gitlab/ci/python-env.ps1 | 2 +- .gitlab/ci/python.ps1 | 30 ++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 42 deletions(-) delete mode 100644 .gitlab/ci/download_python3.cmake create mode 100755 .gitlab/ci/python.ps1 (limited to '.gitlab') diff --git a/.gitlab/ci/download_python3.cmake b/.gitlab/ci/download_python3.cmake deleted file mode 100644 index 0f5b18b4ff..0000000000 --- a/.gitlab/ci/download_python3.cmake +++ /dev/null @@ -1,41 +0,0 @@ -cmake_minimum_required(VERSION 3.17) - -set(version "3.8.6") -set(sha256sum "376e18eef7e3ea467f0e3af041b01fc7e2f12855506c2ab2653ceb5e0951212e") -set(dirname "python-${version}-embed-win-x86_64") -set(tarball "${dirname}.tar.xz") - -# Download the file. -file(DOWNLOAD - "https://cmake.org/files/dependencies/${tarball}" - ".gitlab/${tarball}" - STATUS download_status - EXPECTED_HASH "SHA256=${sha256sum}") - -# Check the download status. -list(GET download_status 0 res) -if (res) - list(GET download_status 1 err) - message(FATAL_ERROR - "Failed to download ${tarball}: ${err}") -endif () - -# Extract the file. -execute_process( - COMMAND - "${CMAKE_COMMAND}" - -E tar - xzf "${tarball}" - WORKING_DIRECTORY ".gitlab" - RESULT_VARIABLE res - ERROR_VARIABLE err - ERROR_STRIP_TRAILING_WHITESPACE) -if (res) - message(FATAL_ERROR - "Failed to extract ${tarball}: ${err}") -endif () - -# Move to a predictable directory. -file(RENAME - ".gitlab/${dirname}" - ".gitlab/python3") diff --git a/.gitlab/ci/python-env.ps1 b/.gitlab/ci/python-env.ps1 index 4e897d8dc6..ce16493e61 100755 --- a/.gitlab/ci/python-env.ps1 +++ b/.gitlab/ci/python-env.ps1 @@ -1,4 +1,4 @@ $pwdpath = $pwd.Path -cmake -P .gitlab/ci/download_python3.cmake +& "$pwsh" -File ".gitlab/ci/python.ps1" Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\python3;$env:PATH" python --version diff --git a/.gitlab/ci/python.ps1 b/.gitlab/ci/python.ps1 new file mode 100755 index 0000000000..27f18071a6 --- /dev/null +++ b/.gitlab/ci/python.ps1 @@ -0,0 +1,30 @@ +$erroractionpreference = "stop" + +$version = "3.11.3" + +if ("$env:PROCESSOR_ARCHITECTURE" -eq "AMD64") { + $sha256sum = "7419B2E98516FBD0B66A1237B80187FFB21D32E47B4A4235C2D9D6379597070F" + $arch = "amd64" +} elseif ("$env:PROCESSOR_ARCHITECTURE" -eq "ARM64") { + $sha256sum = "03BAD6A7C898FC8F693982437AAB6DB698107B82EA93F76424195AE2C161246C" + $arch = "arm64" +} else { + throw ('unknown PROCESSOR_ARCHITECTURE: ' + "$env:PROCESSOR_ARCHITECTURE") +} + +$filename = "python-$version-embed-$arch" +$tarball = "$filename.zip" + +$outdir = $pwd.Path +$outdir = "$outdir\.gitlab" +$ProgressPreference = 'SilentlyContinue' +Invoke-WebRequest -Uri "https://cmake.org/files/dependencies/internal/$tarball" -OutFile "$outdir\$tarball" +$hash = Get-FileHash "$outdir\$tarball" -Algorithm SHA256 +if ($hash.Hash -ne $sha256sum) { + exit 1 +} + +Add-Type -AssemblyName System.IO.Compression.FileSystem +[System.IO.Compression.ZipFile]::ExtractToDirectory("$outdir\$tarball", "$outdir\python3") +Remove-Item "$outdir\python3\*._pth" # Avoid sys.path specific to embedded python. +Remove-Item "$outdir\$tarball" -- cgit v1.2.1