diff --git a/tools/internal_ci/helper_scripts/install_python38.ps1 b/tools/internal_ci/helper_scripts/install_python38.ps1 index b8abd3f09ca..a343bea4d80 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" }