Skip to content

Commit 03bf83e

Browse files
authored
Install Python in Windows CI (#908)
* Install Python in Windows CI * Work around os.path issue with embeddable Python
1 parent fcdeefb commit 03bf83e

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

.vsts.pipelines/jobs/ci-local.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
- template: ../steps/setup-macos-native.yml
4848
- ${{ if eq(parameters.setupWindows, true) }}:
4949
- template: ../steps/setup-windows-bash.yml
50+
- template: ../steps/setup-windows-python.yml
5051

5152
- template: ../steps/calculate-config-flags.yml
5253

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# The dotnet-*-temp pools don't have Python installed in PATH. Install and set it up here.
2+
steps:
3+
- powershell: |
4+
$url = 'https://www.python.org/ftp/python/3.7.1/python-3.7.1-embed-amd64.zip'
5+
$checksum = 'C9E6FF79B0B9BAA948E3819334D70FDC9CE2B195DC4948C9D668334AB4FF244E'
6+
7+
echo "Creating Python bin dir to add to PATH..."
8+
$pythonDir = "$(Build.ArtifactStagingDirectory)\python"
9+
mkdir -f $pythonDir
10+
11+
echo "Downloading python from $url..."
12+
$pythonZip = "$pythonDir\python.zip"
13+
[Net.ServicePointManager]::SecurityProtocol =
14+
[Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
15+
Invoke-WebRequest $url -OutFile $pythonZip
16+
$zipChecksum = (Get-FileHash $pythonZip -Algorithm SHA256).Hash
17+
18+
if ($zipChecksum -ne $checksum)
19+
{
20+
throw "Downloaded zip SHA256 checksum $zipChecksum doesn't match expected $checksum"
21+
}
22+
23+
Add-Type -AssemblyName System.IO.Compression.FileSystem
24+
[System.IO.Compression.ZipFile]::ExtractToDirectory($pythonZip, $pythonDir)
25+
26+
# Work around https://bugs.python.org/issue34841 causing CoreCLR to fail on script dir import
27+
rm "$pythonDir\python37._pth"
28+
29+
echo "Adding $pythonDir to PATH as AzDO variable for python.exe..."
30+
$env:PATH = "$pythonDir;" + $env:PATH
31+
echo "##vso[task.setvariable variable=PATH;]$($env:PATH)"
32+
displayName: Set up Python

0 commit comments

Comments
 (0)