Skip to content

Commit bf06e03

Browse files
committed
Add AppVeyor CI integration
1 parent ec0c3d7 commit bf06e03

File tree

3 files changed

+239
-0
lines changed

3 files changed

+239
-0
lines changed

appveyor.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
environment:
2+
global:
3+
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
4+
# /E:ON and /V:ON options are not enabled in the batch script intepreter
5+
# See: http://stackoverflow.com/a/13751649/163740
6+
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_env.cmd"
7+
8+
matrix:
9+
- PYTHON: "C:\\Python27"
10+
PYTHON_VERSION: "2.7.x" # currently 2.7.9
11+
PYTHON_ARCH: "32"
12+
13+
- PYTHON: "C:\\Python27-x64"
14+
PYTHON_VERSION: "2.7.x" # currently 2.7.9
15+
PYTHON_ARCH: "64"
16+
17+
- PYTHON: "C:\\Python33"
18+
PYTHON_VERSION: "3.3.x" # currently 3.3.5
19+
PYTHON_ARCH: "32"
20+
21+
- PYTHON: "C:\\Python33-x64"
22+
PYTHON_VERSION: "3.3.x" # currently 3.3.5
23+
PYTHON_ARCH: "64"
24+
25+
- PYTHON: "C:\\Python34"
26+
PYTHON_VERSION: "3.4.x" # currently 3.4.3
27+
PYTHON_ARCH: "32"
28+
29+
- PYTHON: "C:\\Python34-x64"
30+
PYTHON_VERSION: "3.4.x" # currently 3.4.3
31+
PYTHON_ARCH: "64"
32+
33+
install:
34+
- ECHO "Filesystem root:"
35+
- ps: "ls \"C:/\""
36+
37+
- ECHO "Installed SDKs:"
38+
- ps: "ls \"C:/Program Files/Microsoft SDKs/Windows\""
39+
40+
# Install Python (from the official .msi of http://python.org) and pip when
41+
# not already installed.
42+
- ps: if (-not(Test-Path($env:PYTHON))) { & appveyor\install.ps1 }
43+
44+
# Prepend newly installed Python to the PATH of this build (this cannot be
45+
# done from inside the powershell script as it would require to restart
46+
# the parent CMD process).
47+
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
48+
49+
# Check that we have the expected version and architecture for Python
50+
- "python --version"
51+
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
52+
53+
# Upgrade to the latest version of pip
54+
- "pip install --disable-pip-version-check --user --upgrade pip"
55+
56+
# Install wheel
57+
- "%CMD_IN_ENV% pip install wheel"
58+
59+
# Install dev requirements
60+
- "%CMD_IN_ENV% pip install -r dev-requirements.txt"
61+
62+
build: false # Not a C# project, build stuff at the test step instead.
63+
64+
test_script:
65+
# Build the compiled extension and run the project tests
66+
- "%CMD_IN_ENV% python setup.py build_ext --inplace"
67+
- "%CMD_IN_ENV% nosetests -v"
68+
69+
after_test:
70+
# If tests are successful, create binary packages for the project.
71+
- "%CMD_IN_ENV% python setup.py bdist_wheel"
72+
- ps: "ls dist"
73+
74+
artifacts:
75+
# Archive the generated packages in the ci.appveyor.com build report.
76+
- path: dist\*.whl
77+
78+
#on_success:
79+
# - TODO: upload the content of dist/*.whl to a public wheelhouse
80+
#

appveyor/install.ps1

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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 Download ($filename, $url) {
12+
$webclient = New-Object System.Net.WebClient
13+
14+
$basedir = $pwd.Path + "\"
15+
$filepath = $basedir + $filename
16+
if (Test-Path $filename) {
17+
Write-Host "Reusing" $filepath
18+
return $filepath
19+
}
20+
21+
# Download and retry up to 3 times in case of network transient errors.
22+
Write-Host "Downloading" $filename "from" $url
23+
$retry_attempts = 2
24+
for($i=0; $i -lt $retry_attempts; $i++){
25+
try {
26+
$webclient.DownloadFile($url, $filepath)
27+
break
28+
}
29+
Catch [Exception]{
30+
Start-Sleep 1
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
40+
}
41+
42+
43+
function DownloadPython ($python_version, $platform_suffix) {
44+
$version_obj = [version]$python_version
45+
if ($version_obj -lt [version]'3.3.0' -and $version_obj.Build -eq 0) {
46+
$python_version = "$($version_obj.Major).$($version_obj.Minor)"
47+
}
48+
$filename = "python-" + $python_version + $platform_suffix + ".msi"
49+
$url = $BASE_URL + $python_version + "/" + $filename
50+
$filepath = Download $filename $url
51+
return $filepath
52+
}
53+
54+
55+
function InstallPython ($python_version, $architecture, $python_home) {
56+
Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home
57+
if (Test-Path $python_home) {
58+
Write-Host $python_home "already exists, skipping."
59+
return $false
60+
}
61+
if ($architecture -eq "32") {
62+
$platform_suffix = ""
63+
} else {
64+
$platform_suffix = ".amd64"
65+
}
66+
$msipath = DownloadPython $python_version $platform_suffix
67+
Write-Host "Installing" $msipath "to" $python_home
68+
$install_log = $python_home + ".log"
69+
$install_args = "/qn /log $install_log /i $msipath TARGETDIR=$python_home"
70+
$uninstall_args = "/qn /x $msipath"
71+
RunCommand "msiexec.exe" $install_args
72+
if (-not(Test-Path $python_home)) {
73+
Write-Host "Python seems to be installed else-where, reinstalling."
74+
RunCommand "msiexec.exe" $uninstall_args
75+
RunCommand "msiexec.exe" $install_args
76+
}
77+
if (Test-Path $python_home) {
78+
Write-Host "Python $python_version ($architecture) installation complete"
79+
} else {
80+
Write-Host "Failed to install Python in $python_home"
81+
Get-Content -Path $install_log
82+
Exit 1
83+
}
84+
}
85+
86+
function RunCommand ($command, $command_args) {
87+
Write-Host $command $command_args
88+
Start-Process -FilePath $command -ArgumentList $command_args -Wait -Passthru
89+
}
90+
91+
92+
function InstallPip ($python_home) {
93+
$pip_path = $python_home + "\Scripts\pip.exe"
94+
$python_path = $python_home + "\python.exe"
95+
if (-not(Test-Path $pip_path)) {
96+
Write-Host "Installing pip..."
97+
$webclient = New-Object System.Net.WebClient
98+
$webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH)
99+
Write-Host "Executing:" $python_path $GET_PIP_PATH
100+
Start-Process -FilePath "$python_path" -ArgumentList "$GET_PIP_PATH" -Wait -Passthru
101+
} else {
102+
Write-Host "pip already installed."
103+
}
104+
}
105+
106+
107+
function main () {
108+
InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON
109+
InstallPip $env:PYTHON
110+
}
111+
112+
main

appveyor/run_with_env.cmd

Lines changed: 47 additions & 0 deletions
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: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
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)