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 # https://ci.appveyor.com/project/cython/cython
version: {branch}-{build}
environment: environment:
global: global:
...@@ -81,5 +79,8 @@ test_script: ...@@ -81,5 +79,8 @@ test_script:
artifacts: artifacts:
- path: dist\* - path: dist\*
cache:
- C:\Downloads\Cython -> appveyor\install.ps1
#on_success: #on_success:
# - TODO: upload the content of dist/*.whl to a public wheelhouse # - TODO: upload the content of dist/*.whl to a public wheelhouse
...@@ -2,64 +2,76 @@ ...@@ -2,64 +2,76 @@
# Authors: Olivier Grisel and Kyle Kastner # Authors: Olivier Grisel and Kyle Kastner
# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/ # 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_URL = "https://bootstrap.pypa.io/get-pip.py"
$GET_PIP_PATH = "C:\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 + "\" function Download ($url, $filename, $destdir) {
$filepath = $basedir + $filename if ($destdir) {
if (Test-Path $filename) { $item = New-Item $destdir -ItemType directory -Force
Write-Host "Reusing" $filepath $destdir = $item.FullName
} else {
$destdir = $pwd.Path
}
$filepath = Join-Path $destdir $filename
if (Test-Path $filepath) {
Write-Host "Reusing" $filename "from" $destdir
return $filepath return $filepath
} }
# Download and retry up to 5 times in case of network transient errors.
Write-Host "Downloading" $filename "from" $url Write-Host "Downloading" $filename "from" $url
$retry_attempts = 3 $webclient = New-Object System.Net.WebClient
for($i=0; $i -lt $retry_attempts; $i++){ foreach($i in 1..3) {
try { try {
$webclient.DownloadFile($url, $filepath) $webclient.DownloadFile($url, $filepath)
break Write-Host "File saved at" $filepath
return $filepath
} }
Catch [Exception]{ Catch [Exception] {
Start-Sleep 1 Start-Sleep 1
} }
} }
Write-Host "File saved at" $filepath Write-Host "Failed to download" $filename "from" $url
return $filepath return $null
} }
function InstallPython ($python_version, $architecture, $python_home) { 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) { if (Test-Path $python_home) {
Write-Host $python_home "already exists, skipping." 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") { $url = $PYTHON_BASE_URL + $python_version + "/" + $filename
$platform_suffix = "" $filepath = Download $url $filename $DOWNLOADS
Write-Host "Installing" $filename "to" $python_home
if ($installer_exe) {
$prog = "$filepath"
$args = "/quiet TargetDir=$python_home"
} else { } else {
$platform_suffix = ".amd64" $prog = "msiexec.exe"
$args = "/quiet /qn /i $filepath TARGETDIR=$python_home"
} }
$filepath = DownloadPython $python_version $platform_suffix Write-Host $prog $args
Write-Host "Installing" $filepath "to" $python_home Start-Process -FilePath $prog -ArgumentList $args -Wait
$args = "/qn /i $filepath TARGETDIR=$python_home" Write-Host "Python $python_version ($architecture-bit) installation complete"
Write-Host "msiexec.exe" $args
Start-Process -FilePath "msiexec.exe" -ArgumentList $args -Wait
Write-Host "Python $python_version ($architecture) installation complete"
return $true
} }
function InstallPip ($python_home) { function InstallPip ($python_home) {
$pip_path = $python_home + "\Scripts\pip.exe" $python_path = Join-Path $python_home "python.exe"
$python_path = $python_home + "\python.exe" $pip_path = Join-Path $python_home "Scripts\pip.exe"
if (Test-Path $pip_path) { if (Test-Path $pip_path) {
Write-Host "Upgrading pip" Write-Host "Upgrading pip"
$args = "-m pip.__main__ install --upgrade pip" $args = "-m pip.__main__ install --upgrade pip"
...@@ -71,24 +83,25 @@ function InstallPip ($python_home) { ...@@ -71,24 +83,25 @@ function InstallPip ($python_home) {
$webclient = New-Object System.Net.WebClient $webclient = New-Object System.Net.WebClient
$webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH) $webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH)
Write-Host "Executing:" $python_path $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 "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" function InstallPipPackage ($python_home, $package) {
& $pip_path install $pkg $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 () { function main () {
InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON
InstallPip $env:PYTHON InstallPip $env:PYTHON
InstallPipPackage $env:PYTHON setuptools
InstallPipPackage $env:PYTHON wheel 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