mirror of https://github.com/grpc/grpc.git
The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#)
https://grpc.io/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
3.1 KiB
97 lines
3.1 KiB
5 years ago
|
#!/usr/bin/env powershell
|
||
|
# Install Python 3.8 for x64 and x86 in order to build wheels on Windows.
|
||
|
|
||
|
Set-StrictMode -Version 2
|
||
5 years ago
|
$ErrorActionPreference = 'Stop'
|
||
5 years ago
|
|
||
4 years ago
|
trap {
|
||
|
$ErrorActionPreference = "Continue"
|
||
|
Write-Error $_
|
||
|
exit 1
|
||
|
}
|
||
|
|
||
5 years ago
|
# Avoid "Could not create SSL/TLS secure channel"
|
||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||
|
|
||
|
function Install-Python {
|
||
|
Param(
|
||
|
[string]$PythonVersion,
|
||
|
[string]$PythonInstaller,
|
||
|
[string]$PythonInstallPath,
|
||
|
[string]$PythonInstallerHash
|
||
|
)
|
||
5 years ago
|
$PythonInstallerUrl = "https://www.python.org/ftp/python/$PythonVersion/$PythonInstaller.exe"
|
||
|
$PythonInstallerPath = "C:\tools\$PythonInstaller.exe"
|
||
5 years ago
|
|
||
|
# Downloads installer
|
||
|
Write-Host "Downloading the Python installer: $PythonInstallerUrl => $PythonInstallerPath"
|
||
4 years ago
|
Invoke-WebRequest -Uri $PythonInstallerUrl -OutFile $PythonInstallerPath
|
||
5 years ago
|
|
||
|
# Validates checksum
|
||
|
$HashFromDownload = Get-FileHash -Path $PythonInstallerPath -Algorithm MD5
|
||
|
if ($HashFromDownload.Hash -ne $PythonInstallerHash) {
|
||
|
throw "Invalid Python installer: failed checksum!"
|
||
|
}
|
||
|
Write-Host "Python installer $PythonInstallerPath validated."
|
||
|
|
||
|
# Installs Python
|
||
5 years ago
|
& $PythonInstallerPath /quiet InstallAllUsers=1 PrependPath=1 Include_test=0 TargetDir=$PythonInstallPath
|
||
5 years ago
|
if (-Not $?) {
|
||
|
throw "The Python installation exited with error!"
|
||
|
}
|
||
|
|
||
|
# NOTE(lidiz) Even if the install command finishes in the script, that
|
||
|
# doesn't mean the Python installation is finished. If using "ps" to check
|
||
|
# for running processes, you might see ongoing installers at this point.
|
||
|
# So, we needs this "hack" to reliably validate that the Python binary is
|
||
|
# functioning properly.
|
||
|
|
||
5 years ago
|
# Wait for the installer process
|
||
|
Wait-Process -Name $PythonInstaller -Timeout 300
|
||
|
Write-Host "Installation process exits normally."
|
||
|
|
||
|
# Validate Python binary
|
||
|
$PythonBinary = "$PythonInstallPath\python.exe"
|
||
|
& $PythonBinary -c 'print(42)'
|
||
|
Write-Host "Python binary works properly."
|
||
5 years ago
|
|
||
5 years ago
|
# Installs pip
|
||
|
& $PythonBinary -m ensurepip --user
|
||
|
|
||
|
Write-Host "Python $PythonVersion installed by $PythonInstaller at $PythonInstallPath."
|
||
|
}
|
||
|
|
||
4 years ago
|
# Python 3.8
|
||
5 years ago
|
$Python38x86Config = @{
|
||
|
PythonVersion = "3.8.0"
|
||
5 years ago
|
PythonInstaller = "python-3.8.0"
|
||
5 years ago
|
PythonInstallPath = "C:\Python38_32bit"
|
||
|
PythonInstallerHash = "412a649d36626d33b8ca5593cf18318c"
|
||
|
}
|
||
|
Install-Python @Python38x86Config
|
||
|
|
||
|
$Python38x64Config = @{
|
||
|
PythonVersion = "3.8.0"
|
||
5 years ago
|
PythonInstaller = "python-3.8.0-amd64"
|
||
5 years ago
|
PythonInstallPath = "C:\Python38"
|
||
|
PythonInstallerHash = "29ea87f24c32f5e924b7d63f8a08ee8d"
|
||
|
}
|
||
|
Install-Python @Python38x64Config
|
||
4 years ago
|
|
||
|
# Python 3.9
|
||
|
$Python39x86Config = @{
|
||
|
PythonVersion = "3.9.0"
|
||
|
PythonInstaller = "python-3.9.0"
|
||
|
PythonInstallPath = "C:\Python39_32bit"
|
||
|
PythonInstallerHash = "4a2812db8ab9f2e522c96c7728cfcccb"
|
||
|
}
|
||
|
Install-Python @Python39x86Config
|
||
|
|
||
|
$Python39x64Config = @{
|
||
|
PythonVersion = "3.9.0"
|
||
|
PythonInstaller = "python-3.9.0-amd64"
|
||
|
PythonInstallPath = "C:\Python39"
|
||
|
PythonInstallerHash = "b61a33dc28f13b561452f3089c87eb63"
|
||
|
}
|
||
|
Install-Python @Python39x64Config
|