tox/appveyor: try creating pythonX.Y.bat file to run with specific python.exe

https://nedbatchelder.com/blog/201509/appveyor.html

The old TOXPYTHON trick seems to be discouraged now with tox 3.1, which
emits a warning when there is a conflict in the basepython settings for
environments containing default factors (e.g. py27, etc.)
https://github.com/tox-dev/tox/pull/841
This commit is contained in:
Cosimo Lupo 2018-07-14 15:02:07 +01:00
parent 1a94fbc121
commit e59b89c6ab
No known key found for this signature in database
GPG Key ID: 59D54DB0C9976482
2 changed files with 6 additions and 13 deletions

View File

@ -5,13 +5,11 @@ environment:
PYTHON_VERSION: "2.7.x"
PYTHON_ARCH: "32"
TOXENV: "py27-cov,py27-cov-lxml"
TOXPYTHON: "C:\\Python27\\python.exe"
- PYTHON: "C:\\Python36-x64"
PYTHON_VERSION: "3.6.x"
PYTHON_ARCH: "64"
TOXENV: "py36-cov,py36-cov-lxml"
TOXPYTHON: "C:\\Python36-x64\\python.exe"
- PYTHON: "C:\\Python37-x64"
PYTHON_VERSION: "3.7.x"
@ -19,7 +17,6 @@ environment:
# lxml doesn't have windows 3.7 wheels yet
# TOXENV: "py37-cov,py37-cov-lxml"
TOXENV: "py37-cov"
TOXPYTHON: "C:\\Python37-x64\\python.exe"
skip_branch_with_pr: true
@ -50,6 +47,12 @@ install:
# install tox to run test suite in a virtual environment
- "pip install -U tox"
# Make a python3.7.bat file in the current directory so that tox will find it
# and python3.7 will mean what we want it to. E.g. for TOXENV=py27, this will
# save a python2.7.bat file containing "@C:\Python27\python %*"
# Credit: https://nedbatchelder.com/blog/201509/appveyor.html
- "python -c \"import os; open('python{0}.{1}.bat'.format(*os.environ['TOXENV'][2:]), 'w').write('@{0}\\\\python \\x25*\\n'.format(os.environ['PYTHON']))\""
build: false
test_script:

10
tox.ini
View File

@ -4,12 +4,6 @@ minversion = 2.9.1
skip_missing_interpreters = true
[testenv]
basepython =
# we use TOXPYTHON env variable to specify the location of Appveyor Python
py27: {env:TOXPYTHON:python2.7}
py35: {env:TOXPYTHON:python3.5}
py36: {env:TOXPYTHON:python3.6}
py37: {env:TOXPYTHON:python3.7}
description = run the tests with pytest under {basepython}
setenv =
COVERAGE_FILE={toxinidir}/.coverage.{envname}
@ -24,7 +18,6 @@ commands =
[testenv:coverage]
description = run locally after tests to combine coverage data and create reports;
generates a diff coverage against origin/master (or DIFF_AGAINST env var)
basepython = {env:TOXPYTHON:python}
deps =
coverage >= 4.4.1, < 5
diff_cover
@ -44,7 +37,6 @@ commands =
[testenv:codecov]
description = upload coverage data to codecov (only run on CI)
basepython = {env:TOXPYTHON:python}
deps =
{[testenv:coverage]deps}
codecov
@ -58,7 +50,6 @@ commands =
[testenv:sdist]
description = build sdist to be uploaded to PyPI
basepython = {env:TOXPYTHON:python}
skip_install = true
deps =
setuptools >= 36.4.0
@ -70,7 +61,6 @@ commands =
[testenv:wheel]
description = build wheel package for upload to PyPI
basepython = {env:TOXPYTHON:python}
skip_install = true
deps = {[testenv:sdist]deps}
changedir = {toxinidir}