Skip to content

Commit

Permalink
Merge pull request #232 from larrybradley/appveyor
Browse files Browse the repository at this point in the history
Enable AppVeyor Windows CI testing
  • Loading branch information
larrybradley committed Jan 21, 2015
2 parents 5c1c581 + b18e9bb commit abd8362
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 7 deletions.
47 changes: 47 additions & 0 deletions .appveyor_windows_sdk.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
:: To build extensions for 64 bit Python 3, we need to configure environment
:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of:
:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1)
::
:: To build extensions for 64 bit Python 2, we need to configure environment
:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
::
:: 32 bit builds do not require specific environment configurations.
::
:: Note: this script needs to be run with the /E:ON and /V:ON flags for the
:: cmd interpreter, at least for (SDK v7.0)
::
:: More details at:
:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
:: http://stackoverflow.com/a/13751649/163740
::
:: Author: Olivier Grisel
:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
@ECHO OFF

SET COMMAND_TO_RUN=%*
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows

SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%"
IF %MAJOR_PYTHON_VERSION% == "2" (
SET WINDOWS_SDK_VERSION="v7.0"
) ELSE IF %MAJOR_PYTHON_VERSION% == "3" (
SET WINDOWS_SDK_VERSION="v7.1"
) ELSE (
ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
EXIT 1
)

IF "%PYTHON_ARCH%"=="64" (
ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture
SET DISTUTILS_USE_SDK=1
SET MSSdk=1
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
ECHO Executing: %COMMAND_TO_RUN%
call %COMMAND_TO_RUN% || EXIT 1
) ELSE (
ECHO Using default MSVC build environment for 32 bit architecture
ECHO Executing: %COMMAND_TO_RUN%
call %COMMAND_TO_RUN% || EXIT 1
)
71 changes: 71 additions & 0 deletions .install-miniconda.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Sample script to install anaconda under windows
# Authors: Stuart Mumford
# Borrwed from: Olivier Grisel and Kyle Kastner
# License: BSD 3 clause

$MINICONDA_URL = "http://repo.continuum.io/miniconda/"

function DownloadMiniconda ($version, $platform_suffix) {
$webclient = New-Object System.Net.WebClient
$filename = "Miniconda-" + $version + "-Windows-" + $platform_suffix + ".exe"

$url = $MINICONDA_URL + $filename

$basedir = $pwd.Path + "\"
$filepath = $basedir + $filename
if (Test-Path $filename) {
Write-Host "Reusing" $filepath
return $filepath
}

# Download and retry up to 3 times in case of network transient errors.
Write-Host "Downloading" $filename "from" $url
$retry_attempts = 2
for($i=0; $i -lt $retry_attempts; $i++){
try {
$webclient.DownloadFile($url, $filepath)
break
}
Catch [Exception]{
Start-Sleep 1
}
}
if (Test-Path $filepath) {
Write-Host "File saved at" $filepath
} else {
# Retry once to get the error message if any at the last try
$webclient.DownloadFile($url, $filepath)
}
return $filepath
}

function InstallMiniconda ($python_version, $architecture, $python_home) {
Write-Host "Installing miniconda" $python_version "for" $architecture "bit architecture to" $python_home
if (Test-Path $python_home) {
Write-Host $python_home "already exists, skipping."
return $false
}
if ($architecture -eq "x86") {
$platform_suffix = "x86"
} else {
$platform_suffix = "x86_64"
}
$filepath = DownloadMiniconda $python_version $platform_suffix
Write-Host "Installing" $filepath "to" $python_home
$args = "/InstallationType=AllUsers /S /AddToPath=1 /RegisterPython=1 /D=" + $python_home
Write-Host $filepath $args
Start-Process -FilePath $filepath -ArgumentList $args -Wait -Passthru
#Start-Sleep -s 15
if (Test-Path C:\conda) {
Write-Host "Miniconda $python_version ($architecture) installation complete"
} else {
Write-Host "Failed to install Python in $python_home"
Exit 1
}
}

function main () {
InstallMiniconda $env:MINICONDA_VERSION $env:PLATFORM $env:PYTHON
}

main
48 changes: 48 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# AppVeyor.com is a Continuous Integration service to build and run tests under
# Windows

environment:

global:
PYTHON: "C:\\conda"
MINICONDA_VERSION: "3.5.5"
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\.appveyor_windows_sdk.cmd"
PYTHON_ARCH: "64" # needs to be set for CMD_IN_ENV to succeed. If a mix
# of 32 bit and 64 bit builds are needed, move this
# to the matrix section.

matrix:
- PYTHON_VERSION: "2.6"
ASTROPY_VERSION: "0.4.2"
NUMPY_VERSION: "1.9.1"

- PYTHON_VERSION: "2.7"
ASTROPY_VERSION: "0.4.2"
NUMPY_VERSION: "1.9.1"

platform:
-x64

install:
# Install miniconda using a powershell script.
- "powershell ./.install-miniconda.ps1"
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"

# Install the build and runtime dependencies of the project.
- "conda update --yes conda"
# Create a conda environment using the astropy bonus packages
- "conda create -q --yes -n test -c astropy-ci-extras python=%PYTHON_VERSION%"
- "activate test"

# Check that we have the expected version of Python
- "python --version"

# Install specified version of numpy and dependencies
- "conda install -q --yes numpy=%NUMPY_VERSION% astropy=%ASTROPY_VERSION% pytest Cython scipy jinja2 scikit-image matplotlib"

# Not a .NET project, we build SunPy in the install step instead
build: false

test_script:
- "%CMD_IN_ENV% python setup.py test"

15 changes: 8 additions & 7 deletions photutils/tests/test_morphology.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from ..morphology import (centroid_com, centroid_1dg, centroid_2dg,
gaussian1d_moments, data_properties)
from astropy.modeling import models
from astropy.convolution.kernels import Gaussian2DKernel
try:
import skimage
HAS_SKIMAGE = True
Expand Down Expand Up @@ -61,18 +62,18 @@ def test_centroids_witherror(xc_ref, yc_ref, x_stddev, y_stddev, theta):

@pytest.mark.skipif('not HAS_SKIMAGE')
def test_centroids_withmask():
data = np.zeros((5, 5))
data[2, 2] = 1.
data[0, 0] = 1.
size = 9
xc_ref, yc_ref = (size - 1) / 2, (size - 1) / 2
data = Gaussian2DKernel(1., x_size=size, y_size=size).array
mask = np.zeros_like(data, dtype=bool)
data[0, 0] = 1.
mask[0, 0] = True
xc, yc = centroid_com(data, mask=mask)
xc_ref, yc_ref = 2, 2
assert_allclose([xc_ref, yc_ref], [xc, yc], rtol=0, atol=1.e-3)
assert_allclose([xc, yc], [xc_ref, yc_ref], rtol=0, atol=1.e-3)
xc2, yc2 = centroid_1dg(data, mask=mask)
assert_allclose([xc_ref, yc_ref], [xc2, yc2], rtol=0, atol=1.e-3)
assert_allclose([xc2, yc2], [xc_ref, yc_ref], rtol=0, atol=1.e-3)
xc3, yc3 = centroid_2dg(data, mask=mask)
assert_allclose([xc_ref, yc_ref], [xc3, yc3], rtol=0, atol=1.e-3)
assert_allclose([xc3, yc3], [xc_ref, yc_ref], rtol=0, atol=1.e-3)


@pytest.mark.skipif('not HAS_SKIMAGE')
Expand Down

0 comments on commit abd8362

Please sign in to comment.