From 1f38deca1e947c1c405e1a1d86176bd9be91f536 Mon Sep 17 00:00:00 2001 From: GoncaloGarcia Date: Tue, 2 Jul 2024 12:45:17 +0100 Subject: [PATCH] TUN-8504: Use pre-installed python version instead of downloading it on Windows builds Recently python.org started blocking our requests. We've asked the Devtools team to upgrade the default python installation to 3.10 so that we can use it in our tests --- .teamcity/windows/component-test.ps1 | 49 ++++------------------------ 1 file changed, 7 insertions(+), 42 deletions(-) diff --git a/.teamcity/windows/component-test.ps1 b/.teamcity/windows/component-test.ps1 index e4d8727d..fe70738e 100644 --- a/.teamcity/windows/component-test.ps1 +++ b/.teamcity/windows/component-test.ps1 @@ -5,41 +5,6 @@ $ProgressPreference = "SilentlyContinue" $WorkingDirectory = Get-Location $CloudflaredDirectory = "$WorkingDirectory\go\src\github.com\cloudflare\cloudflared" -Write-Output "Installing python..." - -$PythonVersion = "3.10.11" -$PythonZipFile = "$env:Temp\python-$PythonVersion-embed-amd64.zip" -$PipInstallFile = "$env:Temp\get-pip.py" -$PythonZipUrl = "https://www.python.org/ftp/python/$PythonVersion/python-$PythonVersion-embed-amd64.zip" -$PythonPath = "$WorkingDirectory\Python" -$PythonBinPath = "$PythonPath\python.exe" - -# Download Python zip file -Invoke-WebRequest -Uri $PythonZipUrl -OutFile $PythonZipFile - -# Download Python pip file -Invoke-WebRequest -Uri "https://bootstrap.pypa.io/get-pip.py" -OutFile $PipInstallFile - -# Extract Python files -Expand-Archive $PythonZipFile -DestinationPath $PythonPath -Force - -# Add Python to PATH -$env:Path = "$PythonPath\Scripts;$PythonPath;$($env:Path)" - -Write-Output "Installed to $PythonPath" - -# Install pip -& $PythonBinPath $PipInstallFile - -# Add package paths in pythonXX._pth to unblock python -m pip -$PythonImportPathFile = "$PythonPath\python310._pth" -$ComponentTestsDir = "$CloudflaredDirectory\component-tests\" -@($ComponentTestsDir, "Lib\site-packages", $(Get-Content $PythonImportPathFile)) | Set-Content $PythonImportPathFile - -# Test Python installation -& $PythonBinPath --version -& $PythonBinPath -m pip --version - go env go version @@ -48,8 +13,8 @@ $env:CGO_ENABLED = 1 $env:TARGET_ARCH = "amd64" $env:Path = "$Env:Temp\go\bin;$($env:Path)" -& $PythonBinPath --version -& $PythonBinPath -m pip --version +python --version +python -m pip --version cd $CloudflaredDirectory @@ -72,11 +37,11 @@ if ($LASTEXITCODE -ne 0) { throw "Failed unit tests" } Write-Output "Running component tests" -& $PythonBinPath -m pip install --upgrade -r component-tests/requirements.txt -& $PythonBinPath component-tests/setup.py --type create -& $PythonBinPath -m pytest component-tests -o log_cli=true --log-cli-level=INFO +python -m pip --disable-pip-version-check install --upgrade -r component-tests/requirements.txt +python component-tests/setup.py --type create +python -m pytest component-tests -o log_cli=true --log-cli-level=INFO if ($LASTEXITCODE -ne 0) { - & $PythonBinPath component-tests/setup.py --type cleanup + python component-tests/setup.py --type cleanup throw "Failed component tests" } -& $PythonBinPath component-tests/setup.py --type cleanup \ No newline at end of file +python component-tests/setup.py --type cleanup \ No newline at end of file