Skip to content

Commit

Permalink
Merge pull request airspeed-velocity#527 from pv/fix-ci
Browse files Browse the repository at this point in the history
CI: fix pytest usage + pypy versions
  • Loading branch information
pv authored Jun 25, 2017
2 parents 18dc5fc + 2a61110 commit 4a071f5
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 26 deletions.
41 changes: 30 additions & 11 deletions .continuous-integration/appveyor/windows_sdk.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
:: To build extensions for 64 bit Python 3, we need to configure environment
:: To build extensions for 64 bit Python 3.5 or later no special environment needs
:: to be configured.
::
:: To build extensions for 64 bit Python 3.4 or earlier, 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)
::
Expand All @@ -13,33 +16,49 @@
::
:: More details at:
:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
:: http://stackoverflow.com/a/13751649/163740
:: https://stackoverflow.com/a/13751649/163740
::
:: Author: Olivier Grisel
:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
:: Original Author: Olivier Grisel
:: License: CC0 1.0 Universal: https://creativecommons.org/publicdomain/zero/1.0/
:: This version based on updates for python 3.5 by Phil Elson at:
:: https://github.com/pelson/Obvious-CI/tree/master/scripts

@ECHO OFF

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

SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%"
SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,1%
IF %MAJOR_PYTHON_VERSION% == "2" (
SET WINDOWS_SDK_VERSION="v7.0"
SET SET_SDK_64=Y
) ELSE IF %MAJOR_PYTHON_VERSION% == "3" (
SET WINDOWS_SDK_VERSION="v7.1"
IF %MINOR_PYTHON_VERSION% LEQ 4 (
SET SET_SDK_64=Y
) ELSE (
SET SET_SDK_64=N
)
) 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
IF %SET_SDK_64% == Y (
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 64 bit architecture
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%
Expand Down
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ python:
- 3.3
- 3.4
- 3.5
- 3.6
- pypy
- "pypy3.3-5.2-alpha1"
# - pypy3

matrix:
include:
- python: 2.7
env:
- USE_CONDA=true
- COVERAGE=--coverage
- COVERAGE=--cov asv

- python: 3.5
env: USE_CONDA=true
Expand Down Expand Up @@ -70,9 +70,10 @@ install:
fi
$TRAVIS_PIP install selenium six pytest feedparser python-hglib;
if [[ $COVERAGE != '' ]]; then $TRAVIS_PIP install pytest-cov coveralls; fi;
- $TRAVIS_PYTHON setup.py build_ext -i

script:
- $TRAVIS_PYTHON setup.py test $COVERAGE
- $TRAVIS_PYTHON -m pytest $COVERAGE test

after_success:
- if [[ $COVERAGE != '' ]]; then coveralls; fi
19 changes: 16 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,33 @@ environment:

matrix:

- PYTHON_VERSION: "3.5"
- PYTHON_VERSION: "2.7"
platform: x64
PYTHON_ARCH: "64"
- PYTHON_VERSION: "2.7"
- PYTHON_VERSION: "3.5"
platform: x64
PYTHON_ARCH: "64"
- PYTHON_VERSION: "2.7"
platform: x86
PYTHON_ARCH: "32"

install:
# Clear tmpdir (sometimes left behind by appveyor?)
- rmdir /s /q %APPVEYOR_BUILD_FOLDER%\\tmp & exit /b 0

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

# Install the build and runtime dependencies of the project.
- "conda update -q --yes conda"

# Tell conda to not use hardlinks: on Windows it's not possible
# to delete hard links to files in use, which causes problem when
# trying to cleanup environments during the tests
- "conda config --set always_copy True"
- "conda config --set allow_softlinks False"

# Create a conda environment
- "conda create -q --yes -n test python=%PYTHON_VERSION%"
- "activate test"
Expand All @@ -37,8 +47,11 @@ install:
# Install specified version of dependencies
- "conda install -q --yes six pytest numpy"

# In-place build
- "%CMD_IN_ENV% python setup.py build_ext -i"

# Not a .NET project
build: false

test_script:
- "%CMD_IN_ENV% python setup.py test -a --tb=native -a --basetemp=%APPVEYOR_BUILD_FOLDER%\\tmp"
- "python -m pytest --tb=native --basetemp=%APPVEYOR_BUILD_FOLDER%\\tmp test"
17 changes: 13 additions & 4 deletions asv/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,10 +965,19 @@ def long_path(path):
return "\\\\?\\" + os.path.abspath(path)

def _remove_readonly(func, path, exc_info):
"""Clear the readonly bit and reattempt the removal;
Windows rmtree doesn't do this by default"""
os.chmod(path, stat.S_IWRITE)
func(path)
"""Try harder to remove files on Windows"""

if isinstance(exc_info[1], OSError) and exc_info[1].errno == errno.EACCES:
# Clear read-only flag and try again
try:
os.chmod(path, stat.S_IWRITE | stat.S_IREAD)
func(path)
return
except OSError:
pass

# Reraise original error
six.reraise(*exc_info)

def long_path_open(filename, *a, **kw):
return open(long_path(filename), *a, **kw)
Expand Down
5 changes: 0 additions & 5 deletions test/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ def test_large_environment_matrix(tmpdir):

@pytest.mark.skipif(not (HAS_PYTHON_27 or HAS_CONDA),
reason="Requires Python 2.7")
@pytest.mark.xfail(WIN,
reason=("Fails on some Windows installations; the Python DLLs "
"in the created environments are apparently not unloaded "
"properly so that removing the environments fails. This is "
"likely not a very common occurrence in real use cases."))
def test_presence_checks(tmpdir):
conf = config.Config()

Expand Down

0 comments on commit 4a071f5

Please sign in to comment.