Adding a self-taught powershell script

pull/21271/head
Lidi Zheng 5 years ago
parent 95528207ca
commit 82b579ab36
  1. 52
      tools/internal_ci/helper_scripts/install_python38.ps1
  2. 7
      tools/internal_ci/helper_scripts/prepare_build_windows.bat

@ -0,0 +1,52 @@
#!/usr/bin/env powershell
# Install Python 3.8 for x64 and x86 in order to build wheels on Windows.
Set-StrictMode -Version 2
$ErrorActionPreference = 'Stop'
# 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
)
$PythonInstallerUrl = "https://www.python.org/ftp/python/$PythonVersion/$PythonInstaller"
$PythonInstallerPath = "C:\tools\$PythonInstaller"
# Downloads installer
Write-Host "Downloading the Python installer: $PythonInstallerUrl => $PythonInstallerPath"
Invoke-WebRequest -Uri $PythonInstallerUrl -OutFile $PythonInstallerPath
# 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
& $PythonInstallerPath /quiet InstallAllUsers=1 PrependPath=1 Include_test=0 TargetDir=$PythonInstallPath
if (-Not $?) {
throw "The Python installation exited with error!"
}
Write-Host "Python $PythonVersion installed by $PythonInstaller at $PythonInstallPath."
}
$Python38x64Config = @{
PythonVersion = "3.8.0"
PythonInstaller = "python-3.8.0-amd64.exe"
PythonInstallPath = "C:\Python38"
PythonInstallerHash = "29ea87f24c32f5e924b7d63f8a08ee8d"
}
Install-Python @Python38x64Config
$Python38x86Config = @{
PythonVersion = "3.8.0"
PythonInstaller = "python-3.8.0.exe"
PythonInstallPath = "C:\Python38_32bit"
PythonInstallerHash = "412a649d36626d33b8ca5593cf18318c"
}
Install-Python @Python38x86Config

@ -36,12 +36,7 @@ powershell -File src\csharp\install_dotnet_sdk.ps1
set PATH=%LOCALAPPDATA%\Microsoft\dotnet;%PATH%
@rem Install Python 3.8.0
powershell -command "(New-Object Net.WebClient).DownloadFile('https://www.python.org/ftp/python/3.8.0/python-3.8.0-amd64.exe', 'C:\tools\python-3.8.0-amd64.exe')"
powershell -command "& 'C:\tools\python-3.8.0-amd64.exe' /quiet InstallAllUsers=1 PrependPath=1 Include_test=0 TargetDir='C:\Python38'"
@rem Install Python 3.8.0 32 Bit Version
powershell -command "(New-Object Net.WebClient).DownloadFile('https://www.python.org/ftp/python/3.8.0/python-3.8.0.exe', 'C:\tools\python-3.8.0.exe')"
powershell -command "& 'C:\tools\python-3.8.0.exe' /quiet InstallAllUsers=1 PrependPath=1 Include_test=0 TargetDir='C:\Python38_32bit'"
powershell -File tools\internal_ci\helper_scripts/install_python38.ps1
@rem Newest version of Go is required to be able to build boringssl with cmake
@rem TODO(jtattermusch): try to eliminate the dependency on Go

Loading…
Cancel
Save