ensure-tox: add prefer_python2
This patch enables the ability to set a value which prefers the installation of tox within python2 over python3. Change-Id: I29c9585aa9048c0e2855ec1eaf1f48041cfe46e2
This commit is contained in:
parent
6f491cba6c
commit
9254fbb5ff
@ -2,3 +2,18 @@ Ensure tox is installed
|
||||
|
||||
If tox is not already installed, it will be installed via pip in the
|
||||
user install directory (i.e., "pip install --user").
|
||||
|
||||
**Role Variables**
|
||||
|
||||
.. zuul:rolevar:: tox_executable
|
||||
:default: ``tox``
|
||||
|
||||
Optional path to point tox executable
|
||||
|
||||
.. zuul:rolevar:: tox_prefer_python2
|
||||
:default: ``true``
|
||||
|
||||
If tox is not detected, prefer to install tox inside Python 2 instead of
|
||||
Python 3. The default value is currently set to ``true`` for compatibility
|
||||
reasons, it will be switched to false eventually. It's best to set this to
|
||||
``false`` when using it.
|
||||
|
@ -1 +1,2 @@
|
||||
tox_executable: tox
|
||||
tox_prefer_python2: true
|
||||
|
@ -2,11 +2,19 @@
|
||||
shell: |
|
||||
set -euo pipefail
|
||||
|
||||
{% if tox_prefer_python2 %}
|
||||
if command -v pip; then
|
||||
PIP=pip
|
||||
elif command -v pip3; then
|
||||
PIP=pip3
|
||||
fi
|
||||
{% else %}
|
||||
if command -v pip3; then
|
||||
PIP=pip3
|
||||
elif command -v pip; then
|
||||
PIP=pip
|
||||
fi
|
||||
{% endif %}
|
||||
|
||||
type tox || $PIP install --user tox
|
||||
args:
|
||||
|
Loading…
Reference in New Issue
Block a user