From a3d29e2acf2be968e99f68effcfce886a17d349b Mon Sep 17 00:00:00 2001 From: Lidi Zheng <lidiz@google.com> Date: Mon, 2 Dec 2019 16:56:01 -0800 Subject: [PATCH] Ensure the installation process is finished --- .../helper_scripts/install_python38.ps1 | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tools/internal_ci/helper_scripts/install_python38.ps1 b/tools/internal_ci/helper_scripts/install_python38.ps1 index b8abd3f09c..a343bea4d8 100644 --- a/tools/internal_ci/helper_scripts/install_python38.ps1 +++ b/tools/internal_ci/helper_scripts/install_python38.ps1 @@ -13,8 +13,8 @@ function Install-Python { [string]$PythonInstallPath, [string]$PythonInstallerHash ) - $PythonInstallerUrl = "https://www.python.org/ftp/python/$PythonVersion/$PythonInstaller" - $PythonInstallerPath = "C:\tools\$PythonInstaller" + $PythonInstallerUrl = "https://www.python.org/ftp/python/$PythonVersion/$PythonInstaller.exe" + $PythonInstallerPath = "C:\tools\$PythonInstaller.exe" # Downloads installer Write-Host "Downloading the Python installer: $PythonInstallerUrl => $PythonInstallerPath" @@ -55,6 +55,22 @@ function Install-Python { Start-Sleep -Seconds 1 } + # Waits until the installer process is gone + $ValidationStartTime = Get-Date + $EarlyExitDDL = $ValidationStartTime.addminutes(5) + While ($True) { + $CurrentTime = Get-Date + if ($CurrentTime -ge $EarlyExitDDL) { + throw "Python installation process hangs!" + } + $InstallProcess = Get-Process -Name $PythonInstaller + if ($InstallProcess -eq $null) { + Write-Host "Installation process exits normally." + break + } + Start-Sleep -Seconds 1 + } + # Installs pip & $PythonBinary -m ensurepip --user @@ -63,7 +79,7 @@ function Install-Python { $Python38x86Config = @{ PythonVersion = "3.8.0" - PythonInstaller = "python-3.8.0.exe" + PythonInstaller = "python-3.8.0" PythonInstallPath = "C:\Python38_32bit" PythonInstallerHash = "412a649d36626d33b8ca5593cf18318c" } @@ -71,7 +87,7 @@ Install-Python @Python38x86Config $Python38x64Config = @{ PythonVersion = "3.8.0" - PythonInstaller = "python-3.8.0-amd64.exe" + PythonInstaller = "python-3.8.0-amd64" PythonInstallPath = "C:\Python38" PythonInstallerHash = "29ea87f24c32f5e924b7d63f8a08ee8d" } -- GitLab