Leverage ignore_basepython_conflict to get the right python version

Currently as we have basepython set in the testenv we always get the
same python3 binary even when specifying a specific env (eg py37).

This change uses ignore_basepython_conflict to tell tox when creating
the py3X envoronments to use the major/minr from the env rather than
basepython.

Before:
 [tony@thor requirements]$ tox -re py37,py35,py36,py27 --notest
 [tony@thor requirements]$ for py in .tox/py*/bin/python ; do echo $py ; $py --version ; done
 .tox/py27/bin/python
 Python 3.6.6
 .tox/py35/bin/python
 Python 3.5.6
 .tox/py36/bin/python
 Python 3.6.6
 .tox/py37/bin/python
 Python 3.6.6

After:
 [tony@thor requirements]$ tox -re py37,py35,py36,py27 --notest
 [tony@thor requirements]$ for py in .tox/py*/bin/python ; do echo $py ; $py --version ; done
 .tox/py27/bin/python
 Python 2.7.15
 .tox/py35/bin/python
 Python 3.5.6
 .tox/py36/bin/python
 Python 3.6.6
 .tox/py37/bin/python
 Python 3.7.0

Change-Id: Ie16bfa0a96d41cc3d1712b0d3c7a6ce2378b5478
This commit is contained in:
Tony Breeds 2018-10-18 13:04:09 +11:00
parent f65caf3a0d
commit 3a6ef20dab

14
tox.ini
View File

@ -1,7 +1,8 @@
[tox] [tox]
minversion = 1.6 minversion = 3.1.0
skipsdist = True skipsdist = True
envlist = validate,py27,pep8,pip-install envlist = validate,py27,pep8,pip-install
ignore_basepython_conflict=true
[testenv] [testenv]
basepython = python3 basepython = python3
@ -58,7 +59,6 @@ deps =
hacking>=1.0.0 hacking>=1.0.0
bashate>=0.5.1 bashate>=0.5.1
whitelist_externals = bash whitelist_externals = bash
basepython = python3
commands = commands =
flake8 flake8
bash -c "find {toxinidir}/tools \ bash -c "find {toxinidir}/tools \
@ -86,17 +86,7 @@ deps = .
install_command = pip install {opts} {packages} install_command = pip install {opts} {packages}
commands = python {toxinidir}/tools/check-install.py commands = python {toxinidir}/tools/check-install.py
[testenv:py34]
basepython = python3.4
[testenv:py35]
basepython = python3.5
[testenv:py36]
basepython = python3.6
[testenv:requirements-check] [testenv:requirements-check]
basepython = python3
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/requirements.txt
commands = commands =
{toxinidir}/playbooks/files/project-requirements-change.py --local {posargs} {toxinidir}/playbooks/files/project-requirements-change.py --local {posargs}