Skip to content

Commit f57e587

Browse files
committed
Add appveyor config file
1 parent beb53da commit f57e587

File tree

5 files changed

+162
-2
lines changed

5 files changed

+162
-2
lines changed

appveyor.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# TODO: How to automatically use the version string
2+
# produced by the build?
3+
version: 0.6.6.{build}
4+
5+
# branches to build
6+
branches:
7+
only:
8+
- master
9+
clone_depth: 1
10+
11+
# Do not build on tags (GitHub only)
12+
skip_tags: true
13+
14+
environment:
15+
# Operating system (build VM template)
16+
os: Windows Server 2012
17+
18+
matrix:
19+
- PYTHON: "C:\\Python34-x64"
20+
PYTHON_VERSION: "3.4.1"
21+
PYTHON_ARCH: "64"
22+
23+
install:
24+
- 'ECHO Filesystem root:'
25+
- 'dir "C:/"'
26+
27+
- 'ECHO Installed SDKs:'
28+
- 'dir "C:/Program Files/Microsoft SDKs/Windows"'
29+
30+
# Install Python (from the official .msi of http://python.org) and pip when
31+
# not already installed.
32+
- "powershell ./appveyor/install.ps1"
33+
34+
# Prepend newly installed Python to the PATH of this build (this cannot be
35+
# done from inside the powershell script as it would require to restart
36+
# the parent CMD process).
37+
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
38+
39+
# Install the build dependencies of the project. If some dependencies
40+
# contain compiled extensions and are not provided as pre-built wheel
41+
# packages, pip will build them from source using the MSVC compiler
42+
# matching the target Python version and architecture
43+
- "%CMD_IN_ENV% pip install -r dev-requirements.txt"
44+
45+
46+
build_script:
47+
- python setup.py bdist_wheel
48+
49+
test_script:
50+
- pip install dist\*.whl
51+
- pushd C:\
52+
- python -c "import dynd;dynd.test(exit=True)"
53+
- popd
54+
55+
artifacts:
56+
- path: dist\*

appveyor/install.ps1

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

dev-requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
numpy
2+
cython

requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
numpy
2-
cython

setup.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ def get_outputs(self):
151151
# build_ext is overridden to call cmake, the Extension is just
152152
# needed so things like bdist_wheel understand what's going on.
153153
ext_modules = [Extension('dynd._pydynd', sources=[])],
154-
install_requires=open('requirements.txt').read().strip().split('\n'),
154+
# This includes both build and install requirements. Setuptools' setup_requires
155+
# option does not actually install things, so isn't actually helpful...
156+
install_requires=open('dev-requirements.txt').read().strip().split('\n'),
155157
classifiers = [
156158
'Development Status :: 3 - Alpha',
157159
'Intended Audience :: Developers',

0 commit comments

Comments
 (0)