Skip to content

Commit 1f3e5c4

Browse files
committed
Merge pull request #19 from tacaswell/tst_appveyor
TST: first attempt to get appveyor working
2 parents d69ecc2 + f632dda commit 1f3e5c4

File tree

3 files changed

+293
-0
lines changed

3 files changed

+293
-0
lines changed

appveyor.yml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# AppVeyor.com is a Continuous Integration service to build and run tests under
2+
# Windows
3+
4+
environment:
5+
global:
6+
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
7+
# /E:ON and /V:ON options are not enabled in the batch script intepreter
8+
# See: http://stackoverflow.com/a/13751649/163740
9+
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci\\appveyor\\run_with_env.cmd"
10+
11+
matrix:
12+
- PYTHON: "C:\\Python27_32"
13+
PYTHON_VERSION: "2.7"
14+
PYTHON_ARCH: "32"
15+
16+
- PYTHON: "C:\\Python27_64"
17+
PYTHON_VERSION: "2.7"
18+
PYTHON_ARCH: "64"
19+
20+
- PYTHON: "C:\\Python34_32"
21+
PYTHON_VERSION: "3.4.3"
22+
PYTHON_ARCH: "32"
23+
24+
- PYTHON: "C:\\Python34_64"
25+
PYTHON_VERSION: "3.4.3"
26+
PYTHON_ARCH: "64"
27+
28+
- PYTHON: "C:\\Python35"
29+
PYTHON_VERSION: "3.5.0"
30+
PYTHON_ARCH: "32"
31+
32+
- PYTHON: "C:\\Python35-x64"
33+
PYTHON_VERSION: "3.5.0"
34+
PYTHON_ARCH: "64"
35+
36+
install:
37+
# Install Python (from the official .msi of http://python.org) and pip when
38+
# not already installed.
39+
- "powershell ./ci/appveyor/install.ps1"
40+
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
41+
42+
# Check that we have the expected version and architecture for Python
43+
- "python --version"
44+
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
45+
46+
# Install the build and runtime dependencies of the project.
47+
- "%CMD_IN_ENV% pip install -v six nose coveralls"
48+
49+
# Install the generated wheel package to test it
50+
- "python setup.py install"
51+
52+
53+
# Not a .NET project, we build scikit-image in the install step instead
54+
build: false
55+
56+
test_script:
57+
58+
# Run unit tests with nose
59+
- "python run_tests.py"
60+
61+
artifacts:
62+
# Archive the generated wheel package in the ci.appveyor.com build report.
63+
- path: dist\*
64+
65+
#on_success:
66+
# - TODO: upload the content of dist/*.whl to a public wheelhouse

ci/appveyor/install.ps1

+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# Sample script to install Python and pip under Windows
2+
# Authors: Olivier Grisel, Jonathan Helmus and Kyle Kastner
3+
# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
4+
5+
$MINICONDA_URL = "http://repo.continuum.io/miniconda/"
6+
$BASE_URL = "https://www.python.org/ftp/python/"
7+
$GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
8+
$GET_PIP_PATH = "C:\get-pip.py"
9+
10+
11+
function DownloadPython ($python_version, $platform_suffix) {
12+
$webclient = New-Object System.Net.WebClient
13+
$filename = "python-" + $python_version + $platform_suffix + ".msi"
14+
$url = $BASE_URL + $python_version + "/" + $filename
15+
16+
$basedir = $pwd.Path + "\"
17+
$filepath = $basedir + $filename
18+
if (Test-Path $filename) {
19+
Write-Host "Reusing" $filepath
20+
return $filepath
21+
}
22+
23+
# Download and retry up to 3 times in case of network transient errors.
24+
Write-Host "Downloading" $filename "from" $url
25+
$retry_attempts = 2
26+
for($i=0; $i -lt $retry_attempts; $i++){
27+
try {
28+
$webclient.DownloadFile($url, $filepath)
29+
break
30+
}
31+
Catch [Exception]{
32+
Start-Sleep 1
33+
}
34+
}
35+
if (Test-Path $filepath) {
36+
Write-Host "File saved at" $filepath
37+
} else {
38+
# Retry once to get the error message if any at the last try
39+
$webclient.DownloadFile($url, $filepath)
40+
}
41+
return $filepath
42+
}
43+
44+
45+
function InstallPython ($python_version, $architecture, $python_home) {
46+
Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home
47+
if (Test-Path $python_home) {
48+
Write-Host $python_home "already exists, skipping."
49+
return $false
50+
}
51+
if ($architecture -eq "32") {
52+
$platform_suffix = ""
53+
} else {
54+
$platform_suffix = ".amd64"
55+
}
56+
$msipath = DownloadPython $python_version $platform_suffix
57+
Write-Host "Installing" $msipath "to" $python_home
58+
$install_log = $python_home + ".log"
59+
$install_args = "/qn /log $install_log /i $msipath TARGETDIR=$python_home"
60+
$uninstall_args = "/qn /x $msipath"
61+
RunCommand "msiexec.exe" $install_args
62+
if (-not(Test-Path $python_home)) {
63+
Write-Host "Python seems to be installed else-where, reinstalling."
64+
RunCommand "msiexec.exe" $uninstall_args
65+
RunCommand "msiexec.exe" $install_args
66+
}
67+
if (Test-Path $python_home) {
68+
Write-Host "Python $python_version ($architecture) installation complete"
69+
} else {
70+
Write-Host "Failed to install Python in $python_home"
71+
Get-Content -Path $install_log
72+
Exit 1
73+
}
74+
}
75+
76+
function RunCommand ($command, $command_args) {
77+
Write-Host $command $command_args
78+
Start-Process -FilePath $command -ArgumentList $command_args -Wait -Passthru
79+
}
80+
81+
82+
function InstallPip ($python_home) {
83+
$pip_path = $python_home + "\Scripts\pip.exe"
84+
$python_path = $python_home + "\python.exe"
85+
if (-not(Test-Path $pip_path)) {
86+
Write-Host "Installing pip..."
87+
$webclient = New-Object System.Net.WebClient
88+
$webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH)
89+
Write-Host "Executing:" $python_path $GET_PIP_PATH
90+
Start-Process -FilePath "$python_path" -ArgumentList "$GET_PIP_PATH" -Wait -Passthru
91+
} else {
92+
Write-Host "pip already installed."
93+
}
94+
}
95+
96+
97+
function DownloadMiniconda ($python_version, $platform_suffix) {
98+
$webclient = New-Object System.Net.WebClient
99+
if ($python_version -eq "3.4") {
100+
$filename = "Miniconda3-3.5.5-Windows-" + $platform_suffix + ".exe"
101+
} else {
102+
$filename = "Miniconda-3.5.5-Windows-" + $platform_suffix + ".exe"
103+
}
104+
$url = $MINICONDA_URL + $filename
105+
106+
$basedir = $pwd.Path + "\"
107+
$filepath = $basedir + $filename
108+
if (Test-Path $filename) {
109+
Write-Host "Reusing" $filepath
110+
return $filepath
111+
}
112+
113+
# Download and retry up to 3 times in case of network transient errors.
114+
Write-Host "Downloading" $filename "from" $url
115+
$retry_attempts = 2
116+
for($i=0; $i -lt $retry_attempts; $i++){
117+
try {
118+
$webclient.DownloadFile($url, $filepath)
119+
break
120+
}
121+
Catch [Exception]{
122+
Start-Sleep 1
123+
}
124+
}
125+
if (Test-Path $filepath) {
126+
Write-Host "File saved at" $filepath
127+
} else {
128+
# Retry once to get the error message if any at the last try
129+
$webclient.DownloadFile($url, $filepath)
130+
}
131+
return $filepath
132+
}
133+
134+
135+
function InstallMiniconda ($python_version, $architecture, $python_home) {
136+
Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home
137+
if (Test-Path $python_home) {
138+
Write-Host $python_home "already exists, skipping."
139+
return $false
140+
}
141+
if ($architecture -eq "32") {
142+
$platform_suffix = "x86"
143+
} else {
144+
$platform_suffix = "x86_64"
145+
}
146+
$filepath = DownloadMiniconda $python_version $platform_suffix
147+
Write-Host "Installing" $filepath "to" $python_home
148+
$install_log = $python_home + ".log"
149+
$args = "/S /D=$python_home"
150+
Write-Host $filepath $args
151+
Start-Process -FilePath $filepath -ArgumentList $args -Wait -Passthru
152+
if (Test-Path $python_home) {
153+
Write-Host "Python $python_version ($architecture) installation complete"
154+
} else {
155+
Write-Host "Failed to install Python in $python_home"
156+
Get-Content -Path $install_log
157+
Exit 1
158+
}
159+
}
160+
161+
162+
function InstallMinicondaPip ($python_home) {
163+
$pip_path = $python_home + "\Scripts\pip.exe"
164+
$conda_path = $python_home + "\Scripts\conda.exe"
165+
if (-not(Test-Path $pip_path)) {
166+
Write-Host "Installing pip..."
167+
$args = "install --yes pip"
168+
Write-Host $conda_path $args
169+
Start-Process -FilePath "$conda_path" -ArgumentList $args -Wait -Passthru
170+
} else {
171+
Write-Host "pip already installed."
172+
}
173+
}
174+
175+
function main () {
176+
InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON
177+
InstallPip $env:PYTHON
178+
}
179+
180+
main

ci/appveyor/run_with_env.cmd

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
:: To build extensions for 64 bit Python 3, we need to configure environment
2+
:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of:
3+
:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1)
4+
::
5+
:: To build extensions for 64 bit Python 2, we need to configure environment
6+
:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
7+
:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
8+
::
9+
:: 32 bit builds do not require specific environment configurations.
10+
::
11+
:: Note: this script needs to be run with the /E:ON and /V:ON flags for the
12+
:: cmd interpreter, at least for (SDK v7.0)
13+
::
14+
:: More details at:
15+
:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
16+
:: http://stackoverflow.com/a/13751649/163740
17+
::
18+
:: Author: Olivier Grisel
19+
:: License: BSD 3 clause
20+
@ECHO OFF
21+
22+
SET COMMAND_TO_RUN=%*
23+
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
24+
25+
SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%"
26+
IF %MAJOR_PYTHON_VERSION% == "2" (
27+
SET WINDOWS_SDK_VERSION="v7.0"
28+
) ELSE IF %MAJOR_PYTHON_VERSION% == "3" (
29+
SET WINDOWS_SDK_VERSION="v7.1"
30+
) ELSE (
31+
ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
32+
EXIT 1
33+
)
34+
35+
IF "%PYTHON_ARCH%"=="64" (
36+
ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture
37+
SET DISTUTILS_USE_SDK=1
38+
SET MSSdk=1
39+
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
40+
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
41+
ECHO Executing: %COMMAND_TO_RUN%
42+
call %COMMAND_TO_RUN% || EXIT 1
43+
) ELSE (
44+
ECHO Using default MSVC build environment for 32 bit architecture
45+
ECHO Executing: %COMMAND_TO_RUN%
46+
call %COMMAND_TO_RUN% || EXIT 1
47+
)

0 commit comments

Comments
 (0)