Skip to content

Commit a83caa3

Browse files
committed
add in conda install scripts
1 parent 7d18775 commit a83caa3

File tree

3 files changed

+201
-3
lines changed

3 files changed

+201
-3
lines changed

appveyor.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ environment:
55
PYTHONPATH: c:\testdir
66
PYTHONWARNINGS: 'ignore:::pip.pep425tags:'
77

8+
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
9+
# /E:ON and /V:ON options are not enabled in the batch script intepreter
10+
# See: http://stackoverflow.com/a/13751649/163740
11+
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci\\run_with_env.cmd"
12+
13+
814
matrix:
915
# http://www.appveyor.com/docs/installed-software#python
1016
- PYTHON: "C:\\Python27"
@@ -20,12 +26,17 @@ install:
2026
- "%PYTHON%\\python.exe -m pip install --upgrade pip"
2127
- "%PYTHON%\\python.exe -m pip install wheel"
2228
- "%PYTHON%\\python.exe -m pip install six"
23-
- conda update conda
24-
- conda install conda-build
29+
30+
# install conda and deps
31+
- powershell .\ci\install.ps1
32+
- cmd: conda config --set show_channel_urls true --set always_yes true --set changeps1 false
33+
- cmd: conda update -q conda
34+
- cmd: conda install conda-build
35+
- cmd: conda info -a
2536

2637
build_script:
2738
- "%PYTHON%\\python.exe setup.py bdist_wheel"
28-
- conda build conda.recipe
39+
- cmd: conda build conda.recipe
2940

3041
test_script:
3142
- ps: '& "$env:PYTHON\\Scripts\\pip.exe" install --no-cache-dir --force-reinstall --ignore-installed ("dist\\" + (gci dist)[0].Name)'

ci/install.ps1

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Sample script to install Miniconda under Windows
2+
# Authors: Olivier Grisel, Jonathan Helmus and Kyle Kastner, Robert McGibbon
3+
# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
4+
5+
$MINICONDA_URL = "http://repo.continuum.io/miniconda/"
6+
7+
8+
function DownloadMiniconda ($python_version, $platform_suffix) {
9+
$webclient = New-Object System.Net.WebClient
10+
$filename = "Miniconda3-latest-Windows-" + $platform_suffix + ".exe"
11+
$url = $MINICONDA_URL + $filename
12+
13+
$basedir = $pwd.Path + "\"
14+
$filepath = $basedir + $filename
15+
if (Test-Path $filename) {
16+
Write-Host "Reusing" $filepath
17+
return $filepath
18+
}
19+
20+
# Download and retry up to 3 times in case of network transient errors.
21+
Write-Host "Downloading" $filename "from" $url
22+
$retry_attempts = 2
23+
for($i=0; $i -lt $retry_attempts; $i++){
24+
try {
25+
$webclient.DownloadFile($url, $filepath)
26+
break
27+
}
28+
Catch [Exception]{
29+
Start-Sleep 1
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
39+
}
40+
41+
42+
function InstallMiniconda ($python_version, $architecture, $python_home) {
43+
Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home
44+
if (Test-Path $python_home) {
45+
Write-Host $python_home "already exists, skipping."
46+
return $false
47+
}
48+
if ($architecture -match "32") {
49+
$platform_suffix = "x86"
50+
} else {
51+
$platform_suffix = "x86_64"
52+
}
53+
54+
$filepath = DownloadMiniconda $python_version $platform_suffix
55+
Write-Host "Installing" $filepath "to" $python_home
56+
$install_log = $python_home + ".log"
57+
$args = "/S /D=$python_home"
58+
Write-Host $filepath $args
59+
Start-Process -FilePath $filepath -ArgumentList $args -Wait -Passthru
60+
if (Test-Path $python_home) {
61+
Write-Host "Python $python_version ($architecture) installation complete"
62+
} else {
63+
Write-Host "Failed to install Python in $python_home"
64+
Get-Content -Path $install_log
65+
Exit 1
66+
}
67+
}
68+
69+
70+
function InstallCondaPackages ($python_home, $spec) {
71+
$conda_path = $python_home + "\Scripts\conda.exe"
72+
$args = "install --yes " + $spec
73+
Write-Host ("conda " + $args)
74+
Start-Process -FilePath "$conda_path" -ArgumentList $args -Wait -Passthru
75+
}
76+
77+
function UpdateConda ($python_home) {
78+
$conda_path = $python_home + "\Scripts\conda.exe"
79+
Write-Host "Updating conda..."
80+
$args = "update --yes conda"
81+
Write-Host $conda_path $args
82+
Start-Process -FilePath "$conda_path" -ArgumentList $args -Wait -Passthru
83+
}
84+
85+
86+
function main () {
87+
InstallMiniconda $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON
88+
UpdateConda $env:PYTHON
89+
InstallCondaPackages $env:PYTHON "conda-build jinja2 anaconda-client"
90+
}
91+
92+
main

ci/run_with_env.cmd

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
:: EXPECTED ENV VARS: PYTHON_ARCH (either x86 or x64)
2+
:: CONDA_PY (either 27, 33, 35 etc. - only major version is extracted)
3+
::
4+
::
5+
:: To build extensions for 64 bit Python 3, we need to configure environment
6+
:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of:
7+
:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1)
8+
::
9+
:: To build extensions for 64 bit Python 2, we need to configure environment
10+
:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
11+
:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
12+
::
13+
:: 32 bit builds, and 64-bit builds for 3.5 and beyond, do not require specific
14+
:: environment configurations.
15+
::
16+
:: Note: this script needs to be run with the /E:ON and /V:ON flags for the
17+
:: cmd interpreter, at least for (SDK v7.0)
18+
::
19+
:: More details at:
20+
:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
21+
:: http://stackoverflow.com/a/13751649/163740
22+
::
23+
:: Author: Phil Elson
24+
:: Original Author: Olivier Grisel (https://github.com/ogrisel/python-appveyor-demo)
25+
:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
26+
::
27+
:: Notes about batch files for Python people:
28+
::
29+
:: Quotes in values are literally part of the values:
30+
:: SET FOO="bar"
31+
:: FOO is now five characters long: " b a r "
32+
:: If you don't want quotes, don't include them on the right-hand side.
33+
::
34+
:: The CALL lines at the end of this file look redundant, but if you move them
35+
:: outside of the IF clauses, they do not run properly in the SET_SDK_64==Y
36+
:: case, I don't know why.
37+
:: originally from https://github.com/pelson/Obvious-CI/blob/master/scripts/obvci_appveyor_python_build_env.cmd
38+
@ECHO OFF
39+
40+
SET COMMAND_TO_RUN=%*
41+
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
42+
43+
:: Extract the major and minor versions, and allow for the minor version to be
44+
:: more than 9. This requires the version number to have two dots in it.
45+
SET MAJOR_PYTHON_VERSION=%CONDA_PY:~0,1%
46+
47+
IF "%CONDA_PY:~2,1%" == "" (
48+
:: CONDA_PY style, such as 27, 34 etc.
49+
SET MINOR_PYTHON_VERSION=%CONDA_PY:~1,1%
50+
) ELSE (
51+
IF "%CONDA_PY:~3,1%" == "." (
52+
SET MINOR_PYTHON_VERSION=%CONDA_PY:~2,1%
53+
) ELSE (
54+
SET MINOR_PYTHON_VERSION=%CONDA_PY:~2,2%
55+
)
56+
)
57+
58+
:: Based on the Python version, determine what SDK version to use, and whether
59+
:: to set the SDK for 64-bit.
60+
IF %MAJOR_PYTHON_VERSION% == 2 (
61+
SET WINDOWS_SDK_VERSION="v7.0"
62+
SET SET_SDK_64=Y
63+
) ELSE (
64+
IF %MAJOR_PYTHON_VERSION% == 3 (
65+
SET WINDOWS_SDK_VERSION="v7.1"
66+
IF %MINOR_PYTHON_VERSION% LEQ 4 (
67+
SET SET_SDK_64=Y
68+
) ELSE (
69+
SET SET_SDK_64=N
70+
)
71+
) ELSE (
72+
ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
73+
EXIT /B 1
74+
)
75+
)
76+
77+
IF "%PYTHON_ARCH%"=="64" (
78+
IF %SET_SDK_64% == Y (
79+
ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture
80+
SET DISTUTILS_USE_SDK=1
81+
SET MSSdk=1
82+
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
83+
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
84+
ECHO Executing: %COMMAND_TO_RUN%
85+
call %COMMAND_TO_RUN% || EXIT /B 1
86+
) ELSE (
87+
ECHO Using default MSVC build environment for 64 bit architecture
88+
ECHO Executing: %COMMAND_TO_RUN%
89+
call %COMMAND_TO_RUN% || EXIT /B 1
90+
)
91+
) ELSE (
92+
ECHO Using default MSVC build environment for 32 bit architecture
93+
ECHO Executing: %COMMAND_TO_RUN%
94+
call %COMMAND_TO_RUN% || EXIT /B 1
95+
)

0 commit comments

Comments
 (0)