5
5
$MINICONDA_URL = " http://repo.continuum.io/miniconda/"
6
6
7
7
8
- function DownloadMiniconda ($python_version , $platform_suffix ) {
8
+ function DownloadMiniconda ($python_version , $platform_suffix ) {
9
9
$webclient = New-Object System.Net.WebClient
10
10
$filename = " Miniconda3-latest-Windows-" + $platform_suffix + " .exe"
11
11
$url = $MINICONDA_URL + $filename
@@ -20,30 +20,30 @@ function DownloadMiniconda ($python_version, $platform_suffix) {
20
20
# Download and retry up to 3 times in case of network transient errors.
21
21
Write-Host " Downloading" $filename " from" $url
22
22
$retry_attempts = 2
23
- for ($i = 0 ; $i -lt $retry_attempts ; $i ++ ){
23
+ for ($i = 0 ; $i -lt $retry_attempts ; $i ++ ) {
24
24
try {
25
25
$webclient.DownloadFile ($url , $filepath )
26
26
break
27
27
}
28
- Catch [Exception ]{
28
+ catch [Exception ] {
29
29
Start-Sleep 1
30
30
}
31
- }
32
- if (Test-Path $filepath ) {
33
- Write-Host " File saved at" $filepath
34
- } else {
35
- # Retry once to get the error message if any at the last try
36
- $webclient.DownloadFile ($url , $filepath )
37
- }
38
- return $filepath
31
+ }
32
+
33
+ if (Test-Path $filepath ) {
34
+ Write-Host " File saved at" $filepath
35
+ } else {
36
+ # Retry once to get the error message if any at the last try
37
+ $webclient.DownloadFile ($url , $filepath )
38
+ }
39
+ return $filepath
39
40
}
40
41
41
42
42
- function InstallMiniconda ($python_version , $architecture , $python_home ) {
43
- Write-Host " Installing Python" $python_version " for " $architecture " bit architecture to " $python_home
43
+ function InstallMiniconda ($python_version , $architecture , $python_home ) {
44
+ Write-Host " Installing Python $python_version $architecture bit to $python_home "
44
45
if (Test-Path $python_home ) {
45
- Write-Host $python_home " already exists, skipping."
46
- # return $false
46
+ Write-Host " $python_home already exists, skipping."
47
47
}
48
48
if ($architecture -match " 32" ) {
49
49
$platform_suffix = " x86"
@@ -52,13 +52,13 @@ function InstallMiniconda ($python_version, $architecture, $python_home) {
52
52
}
53
53
54
54
$filepath = DownloadMiniconda $python_version $platform_suffix
55
- Write-Host " Installing" $filepath " to " $python_home
55
+ Write-Host " Installing $filepath to $python_home "
56
56
$install_log = $python_home + " .log"
57
57
$args = " /S /D=$python_home "
58
58
Write-Host $filepath $args
59
59
Start-Process - FilePath $filepath - ArgumentList $args - Wait - Passthru
60
60
if (Test-Path $python_home ) {
61
- Write-Host " Python $python_version ( $architecture ) installation complete"
61
+ Write-Host " Python $python_version $architecture bit installation complete"
62
62
} else {
63
63
Write-Host " Failed to install Python in $python_home "
64
64
Get-Content - Path $install_log
@@ -67,27 +67,29 @@ function InstallMiniconda ($python_version, $architecture, $python_home) {
67
67
}
68
68
69
69
70
- function InstallCondaPackages ($python_home , $spec ) {
70
+ function InstallCondaPackages ($python_home , $spec ) {
71
71
$conda_path = $python_home + " \Scripts\conda.exe"
72
72
$args = " install --yes " + $spec
73
- Write-Host (" conda " + $args )
73
+ Write-Host (" conda " + $args ) - ForegroundColor " Green "
74
74
Start-Process - FilePath " $conda_path " - ArgumentList $args - Wait - Passthru
75
75
}
76
76
77
77
78
- function UpdateConda ($python_home ) {
78
+ function UpdateConda ($python_home ) {
79
79
$conda_path = $python_home + " \Scripts\conda.exe"
80
- Write-Host " Updating conda..."
80
+ Write-Host " Updating conda..." - ForegroundColor " Green "
81
81
$args = " update --yes conda"
82
82
Write-Host $conda_path $args
83
83
Start-Process - FilePath " $conda_path " - ArgumentList $args - Wait - Passthru
84
84
}
85
85
86
86
87
- function main () {
87
+ function main () {
88
+ Write-Host " Starting install_miniconda.ps1" - ForegroundColor " Green"
88
89
InstallMiniconda $env: CONDA_BLD_VERSION $env: CONDA_BLD_ARCH $env: CONDA_BLD
89
90
UpdateConda $env: CONDA_BLD
90
91
InstallCondaPackages $env: CONDA_BLD " conda-build jinja2 anaconda-client"
92
+ Write-Host " Completed install_miniconda.ps1" - ForegroundColor " Green"
91
93
}
92
94
93
95
main
0 commit comments