Commit 226d33d2 authored by Lisandro Dalcin's avatar Lisandro Dalcin

AppVeyor: Update config file and install script

parent b91d7c74
# https://ci.appveyor.com/project/cython/cython
version: {branch}-{build}
environment:
global:
......@@ -81,5 +79,8 @@ test_script:
artifacts:
- path: dist\*
cache:
- C:\Downloads\Cython -> appveyor\install.ps1
#on_success:
# - TODO: upload the content of dist/*.whl to a public wheelhouse
......@@ -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
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment