summaryrefslogtreecommitdiff
path: root/appveyor
diff options
context:
space:
mode:
authorLisandro Dalcin <dalcinl@gmail.com>2015-10-01 22:22:56 +0300
committerLisandro Dalcin <dalcinl@gmail.com>2015-10-01 22:22:56 +0300
commit226d33d26bc7677d52876b0d689961b6b9878296 (patch)
treebbdaeca4c4bb7351edb541cf977cd0befa64fce2 /appveyor
parentb91d7c74ad6b570ff13171389be3ccfd5b2d8c3d (diff)
downloadcython-226d33d26bc7677d52876b0d689961b6b9878296.tar.gz
AppVeyor: Update config file and install script
Diffstat (limited to 'appveyor')
-rw-r--r--appveyor/install.ps197
1 files changed, 55 insertions, 42 deletions
diff --git a/appveyor/install.ps1 b/appveyor/install.ps1
index 57ff08062..ab027fcfe 100644
--- a/appveyor/install.ps1
+++ b/appveyor/install.ps1
@@ -2,64 +2,76 @@
# Authors: Olivier Grisel and Kyle Kastner
# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
-$BASE_URL = "https://www.python.org/ftp/python/"
+$PYTHON_BASE_URL = "https://www.python.org/ftp/python/"
$GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
$GET_PIP_PATH = "C:\get-pip.py"
+$DOWNLOADS = "C:\Downloads\Cython"
-function DownloadPython ($python_version, $platform_suffix) {
- $webclient = New-Object System.Net.WebClient
- $filename = "python-" + $python_version + $platform_suffix + ".msi"
- $url = $BASE_URL + $python_version + "/" + $filename
- $basedir = $pwd.Path + "\"
- $filepath = $basedir + $filename
- if (Test-Path $filename) {
- Write-Host "Reusing" $filepath
+function Download ($url, $filename, $destdir) {
+ if ($destdir) {
+ $item = New-Item $destdir -ItemType directory -Force
+ $destdir = $item.FullName
+ } else {
+ $destdir = $pwd.Path
+ }
+ $filepath = Join-Path $destdir $filename
+ if (Test-Path $filepath) {
+ Write-Host "Reusing" $filename "from" $destdir
return $filepath
}
-
- # Download and retry up to 5 times in case of network transient errors.
Write-Host "Downloading" $filename "from" $url
- $retry_attempts = 3
- for($i=0; $i -lt $retry_attempts; $i++){
+ $webclient = New-Object System.Net.WebClient
+ foreach($i in 1..3) {
try {
$webclient.DownloadFile($url, $filepath)
- break
+ Write-Host "File saved at" $filepath
+ return $filepath
}
- Catch [Exception]{
+ Catch [Exception] {
Start-Sleep 1
}
- }
- Write-Host "File saved at" $filepath
- return $filepath
+ }
+ Write-Host "Failed to download" $filename "from" $url
+ return $null
}
function InstallPython ($python_version, $architecture, $python_home) {
- Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home
+ Write-Host "Installing Python $python_version ($architecture-bit) to $python_home"
if (Test-Path $python_home) {
Write-Host $python_home "already exists, skipping."
- return $false
+ return
+ }
+ $py_major = $python_version[0]; $py_minor = $python_version[2]
+ $installer_exe = ($py_major + $py_minor) -as [int] -ge 35
+ if ($installer_exe) {
+ $arch_suffix = @{"32"="";"64"="-amd64"}[$architecture]
+ $filename = "python-" + $python_version + $arch_suffix + ".exe"
+ } else {
+ $arch_suffix = @{"32"="";"64"=".amd64"}[$architecture]
+ $filename = "python-" + $python_version + $arch_suffix + ".msi"
}
- if ($architecture -eq "32") {
- $platform_suffix = ""
+ $url = $PYTHON_BASE_URL + $python_version + "/" + $filename
+ $filepath = Download $url $filename $DOWNLOADS
+ Write-Host "Installing" $filename "to" $python_home
+ if ($installer_exe) {
+ $prog = "$filepath"
+ $args = "/quiet TargetDir=$python_home"
} else {
- $platform_suffix = ".amd64"
+ $prog = "msiexec.exe"
+ $args = "/quiet /qn /i $filepath TARGETDIR=$python_home"
}
- $filepath = DownloadPython $python_version $platform_suffix
- Write-Host "Installing" $filepath "to" $python_home
- $args = "/qn /i $filepath TARGETDIR=$python_home"
- Write-Host "msiexec.exe" $args
- Start-Process -FilePath "msiexec.exe" -ArgumentList $args -Wait
- Write-Host "Python $python_version ($architecture) installation complete"
- return $true
+ Write-Host $prog $args
+ Start-Process -FilePath $prog -ArgumentList $args -Wait
+ Write-Host "Python $python_version ($architecture-bit) installation complete"
}
function InstallPip ($python_home) {
- $pip_path = $python_home + "\Scripts\pip.exe"
- $python_path = $python_home + "\python.exe"
+ $python_path = Join-Path $python_home "python.exe"
+ $pip_path = Join-Path $python_home "Scripts\pip.exe"
if (Test-Path $pip_path) {
Write-Host "Upgrading pip"
$args = "-m pip.__main__ install --upgrade pip"
@@ -71,24 +83,25 @@ function InstallPip ($python_home) {
$webclient = New-Object System.Net.WebClient
$webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH)
Write-Host "Executing:" $python_path $GET_PIP_PATH
- Start-Process -FilePath "$python_path" -ArgumentList "$GET_PIP_PATH"
+ Start-Process -FilePath $python_path -ArgumentList "$GET_PIP_PATH" -Wait
Write-Host "pip installation complete"
- }
- Write-Host "Upgrading setuptools"
- $args = "install --upgrade setuptools"
- Write-Host "Executing:" $pip_path $args
- Start-Process -FilePath $pip_path -ArgumentList $args -Wait
- Write-Host "setuptools upgrade complete"
+ }
}
-function InstallPipPackage ($python_home, $pkg) {
- $pip_path = $python_home + "\Scripts\pip.exe"
- & $pip_path install $pkg
+
+function InstallPipPackage ($python_home, $package) {
+ $pip_path = Join-Path $python_home "Scripts\pip.exe"
+ Write-Host "Installing/Upgrading $package"
+ $args = "install --upgrade $package"
+ Write-Host "Executing:" $pip_path $args
+ Start-Process -FilePath $pip_path -ArgumentList $args -Wait
+ Write-Host "$package install/upgrade complete"
}
function main () {
InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON
InstallPip $env:PYTHON
+ InstallPipPackage $env:PYTHON setuptools
InstallPipPackage $env:PYTHON wheel
}