path: root/coin/provisioning/common/windows/python.ps1
diff options
authorOliver Wolff <>2018-02-14 07:46:11 +0100
committerLiang Qi <>2018-02-26 19:52:45 +0000
commitcb6709ce5c48a31ba1170c71494c1a3869ffa5bb (patch)
tree8fdb8721a71cba868c2fbfe7c9fbc237d1f990a8 /coin/provisioning/common/windows/python.ps1
parent08c88de5c8d531fb4fee03a0c337dd93739d365a (diff)
Unify Windows provisioning scripts & improve error handlingv5.11.0-beta1
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 <>
Diffstat (limited to 'coin/provisioning/common/windows/python.ps1')
1 files changed, 14 insertions, 13 deletions
diff --git a/coin/provisioning/common/windows/python.ps1 b/coin/provisioning/common/windows/python.ps1
index fe75aa35..ae9cbbbd 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 = "$version/python-$version" + $arch + ".msi"
$internalUrl = "\\\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\ | ForEach-Object { $_ -replace "allowZip64=False", "allowZip64=True" } | Set-Content C:\Python27\lib\
-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"
+#if (isProxyEnabled) {
+# 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"