-
Notifications
You must be signed in to change notification settings - Fork 543
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update and rename appveyor to appveyor/install-miniconda.ps1
- Loading branch information
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Sample script to install anaconda under windows | ||
# Authors: Stuart Mumford | ||
# Borrwed from: Olivier Grisel and Kyle Kastner | ||
# License: BSD 3 clause | ||
|
||
$MINICONDA_URL = "http://repo.continuum.io/miniconda/" | ||
|
||
function DownloadMiniconda ($version, $platform_suffix) { | ||
$webclient = New-Object System.Net.WebClient | ||
$filename = "Miniconda-" + $version + "-Windows-" + $platform_suffix + ".exe" | ||
|
||
$url = $MINICONDA_URL + $filename | ||
|
||
$basedir = $pwd.Path + "\" | ||
$filepath = $basedir + $filename | ||
if (Test-Path $filename) { | ||
Write-Host "Reusing" $filepath | ||
return $filepath | ||
} | ||
|
||
# Download and retry up to 3 times in case of network transient errors. | ||
Write-Host "Downloading" $filename "from" $url | ||
$retry_attempts = 2 | ||
for($i=0; $i -lt $retry_attempts; $i++){ | ||
try { | ||
$webclient.DownloadFile($url, $filepath) | ||
break | ||
} | ||
Catch [Exception]{ | ||
Start-Sleep 1 | ||
} | ||
} | ||
if (Test-Path $filepath) { | ||
Write-Host "File saved at" $filepath | ||
} else { | ||
# Retry once to get the error message if any at the last try | ||
$webclient.DownloadFile($url, $filepath) | ||
} | ||
return $filepath | ||
} | ||
|
||
function InstallMiniconda ($python_version, $architecture, $python_home) { | ||
Write-Host "Installing miniconda" $python_version "for" $architecture "bit architecture to" $python_home | ||
if (Test-Path $python_home) { | ||
Write-Host $python_home "already exists, skipping." | ||
return $false | ||
} | ||
if ($architecture -eq "x86") { | ||
$platform_suffix = "x86" | ||
} else { | ||
$platform_suffix = "x86_64" | ||
} | ||
$filepath = DownloadMiniconda $python_version $platform_suffix | ||
Write-Host "Installing" $filepath "to" $python_home | ||
$args = "/InstallationType=AllUsers /S /AddToPath=1 /RegisterPython=1 /D=" + $python_home | ||
Write-Host $filepath $args | ||
Start-Process -FilePath $filepath -ArgumentList $args -Wait -Passthru | ||
#Start-Sleep -s 15 | ||
if (Test-Path C:\conda) { | ||
Write-Host "Miniconda $python_version ($architecture) installation complete" | ||
} else { | ||
Write-Host "Failed to install Python in $python_home" | ||
Exit 1 | ||
} | ||
} | ||
|
||
function main () { | ||
InstallMiniconda $env:MINICONDA_VERSION $env:PLATFORM $env:PYTHON | ||
} | ||
|
||
main |