Skip to content
This repository was archived by the owner on Jul 26, 2022. It is now read-only.

Commit cd32736

Browse files
committed
appveyor support
1 parent 9361964 commit cd32736

File tree

4 files changed

+270
-0
lines changed

4 files changed

+270
-0
lines changed

appveyor.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# With infos from
2+
# http://tjelvarolsson.com/blog/how-to-continuously-test-your-python-code-on-windows-using-appveyor/
3+
# https://packaging.python.org/en/latest/appveyor/
4+
# https://github.com/rmcgibbo/python-appveyor-conda-example
5+
6+
# Backslashes in quotes need to be escaped: \ -> "\\"
7+
8+
matrix:
9+
fast_finish: true # immediately finish build once one of the jobs fails.
10+
11+
environment:
12+
global:
13+
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
14+
# /E:ON and /V:ON options are not enabled in the batch script intepreter
15+
# See: http://stackoverflow.com/a/13751649/163740
16+
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci\\run_with_env.cmd"
17+
clone_folder: C:\projects\pandas-msgpack
18+
19+
matrix:
20+
21+
- CONDA_ROOT: "C:\\Miniconda3_64"
22+
PYTHON_VERSION: "3.6"
23+
PYTHON_ARCH: "64"
24+
CONDA_PY: "36"
25+
CONDA_NPY: "112"
26+
27+
- CONDA_ROOT: "C:\\Miniconda3_64"
28+
PYTHON_VERSION: "2.7"
29+
PYTHON_ARCH: "64"
30+
CONDA_PY: "27"
31+
CONDA_NPY: "110"
32+
33+
# We always use a 64-bit machine, but can build x86 distributions
34+
# with the PYTHON_ARCH variable (which is used by CMD_IN_ENV).
35+
platform:
36+
- x64
37+
38+
# all our python builds have to happen in tests_script...
39+
build: false
40+
41+
install:
42+
# cancel older builds for the same PR
43+
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
44+
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
45+
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
46+
throw "There are newer queued builds for this pull request, failing early." }
47+
48+
# this installs the appropriate Miniconda (Py2/Py3, 32/64 bit)
49+
# updates conda & installs: conda-build jinja2 anaconda-client
50+
- powershell .\ci\install.ps1
51+
- SET PATH=%CONDA_ROOT%;%CONDA_ROOT%\Scripts;%PATH%
52+
- echo "install"
53+
- cd
54+
- ls -ltr
55+
- git tag --sort v:refname
56+
57+
# this can conflict with git
58+
- cmd: rmdir C:\cygwin /s /q
59+
60+
# install our build environment
61+
- cmd: conda config --set show_channel_urls true --set always_yes true --set changeps1 false
62+
- cmd: conda update -q conda
63+
- cmd: conda config --set ssl_verify false
64+
- cmd: conda config --add channels conda-forge
65+
66+
# this is now the downloaded conda...
67+
- cmd: conda info -a
68+
69+
# create our env
70+
- cmd: conda create -n pandas-msgpack python=%PYTHON_VERSION% pandas cython pytest
71+
- cmd: activate pandas-msgpack
72+
- cmd: conda list -n pandas-msgpack
73+
74+
# build em using the local source checkout in the correct windows env
75+
- cmd: '%CMD_IN_ENV% python setup.py build_ext --inplace'
76+
77+
test_script:
78+
# tests
79+
- cmd: activate pandas-msgpack
80+
- cmd: test.bat

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 "3.5" $env:PYTHON_ARCH $env:CONDA_ROOT
88+
UpdateConda $env:CONDA_ROOT
89+
InstallCondaPackages $env:CONDA_ROOT "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+
)

ci/test.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:: test on windows
2+
3+
pytest pandas-msgpack %*

0 commit comments

Comments
 (0)