aboutsummaryrefslogtreecommitdiffstats
path: root/coin/provisioning/common/windows/python.ps1
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2018-02-14 07:46:11 +0100
committerTony Sarajärvi <tony.sarajarvi@qt.io>2018-04-20 06:15:53 +0000
commit73621de8916b5d6d17a1dbd24c134d14c1c726a8 (patch)
tree8d1e21a4de97070e65183112fccc566a731788b2 /coin/provisioning/common/windows/python.ps1
parenta37f4a2485d30710d743cecdaf1775b43792ed83 (diff)
Unify Windows provisioning scripts & improve error handling
While Coin should also see exit codes != 0 as error, we should stick to one way of handling script errors. As Power Shell cmdlets signal an error by throwing an exception we should do the same (and that approach also works in Coin). Additionally extracting 7zip files was unified across scripts by using the existing helper function instead of reinventing the wheel again and again. A similar helper function was introduced for starting an external application (and handling its errors). Also echo and other "cmd" commands were replaced by their PowerShell equivalents to have a unified approach across our Windows provisioning scripts. Change-Id: I70129ce38692f1396c33c13b33a2918485fa5271 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> (cherry picked from commit cb6709ce5c48a31ba1170c71494c1a3869ffa5bb) Reviewed-by: Simo Fält <simo.falt@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'coin/provisioning/common/windows/python.ps1')
-rw-r--r--coin/provisioning/common/windows/python.ps125
1 files changed, 13 insertions, 12 deletions
diff --git a/coin/provisioning/common/windows/python.ps1 b/coin/provisioning/common/windows/python.ps1
index fe75aa35..72e9cd97 100644
--- a/coin/provisioning/common/windows/python.ps1
+++ b/coin/provisioning/common/windows/python.ps1
@@ -36,11 +36,10 @@
# Python is required for building Qt 5 from source.
$version = "2.7.13"
-if( (is64bitWinHost) -eq 1 ) {
+if (Is64BitWinHost) {
$arch = ".amd64"
$sha1 = "d9113142bae8829365c595735e1ad1f9f5e2894c"
-}
-else {
+} else {
$arch = ""
$sha1 = "7e3b54236dbdbea8fe2458db501176578a4d59c0"
}
@@ -48,23 +47,25 @@ $package = "C:\Windows\temp\python-$version.msi"
$externalUrl = "https://www.python.org/ftp/python/$version/python-$version" + $arch + ".msi"
$internalUrl = "\\ci-files01-hki.intra.qt.io\provisioning\windows\python-$version" + $arch + ".msi"
-echo "Fetching from URL..."
+Write-Host "Fetching from URL..."
Download $externalUrl $internalUrl $package
Verify-Checksum $package $sha1
-echo "Installing $package..."
-cmd /c "msiexec /passive /i $package ALLUSERS=1"
+Write-Host "Installing $package..."
+Run-Executable "msiexec" "/passive /i $package ALLUSERS=1"
+
# We need to change allowZip64 from 'False' to 'True' to be able to create ZIP files that use the ZIP64 extensions when the zipfile is larger than 2 GB
-echo "Chancing allowZip64 value to 'True'..."
+Write-Host "Changing allowZip64 value to 'True'..."
(Get-Content C:\Python27\lib\zipfile.py) | ForEach-Object { $_ -replace "allowZip64=False", "allowZip64=True" } | Set-Content C:\Python27\lib\zipfile.py
-echo "Remove $package..."
-del $package
+Write-Host "Remove $package..."
+Remove-Item -Path $package
Add-Path "C:\Python27;C:\Python27\Scripts"
-C:\Python27\python.exe -m ensurepip
+Run-Executable "C:\Python27\python.exe" "-m ensurepip"
+
# Install python virtual env
#if ( isProxyEnabled ) {
-# echo "Using proxy with pip"
+# Write-Host "Using proxy with pip"
# $pip_args = "--proxy=" + (getProxy)
#}
-C:\Python27\Scripts\pip.exe install virtualenv
+Run-Executable "C:\Python27\Scripts\pip.exe" "install virtualenv"