Revert "ensure-tox: use venv to install"
This reverts commit 6d78fc4f900415b4e33db1653a8be64ee62a6ee6. In some environments, this error is being seen: 2020-05-07 18:36:02.139422 | debian-buster | "msg": "stdout: The virtual environment was not created successfully because ensurepip is not\navailable. On Debian/Ubuntu systems, you need to install the python3-venv\npackage using the following command.\n\n apt-get install python3-venv\n\nYou may need to use sudo with that command. After installing the python3-venv\npackage, recreate your virtual environment.\n\nFailing command: ['/home/zuul/.local/tox/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']\n\n" Change-Id: I6d38bf16cc38020c53815dfa6ab94f8cab4de0a2
This commit is contained in:
parent
64741aa73d
commit
bac2bf6c45
@ -1,7 +1,7 @@
|
|||||||
Ensure tox is installed
|
Ensure tox is installed
|
||||||
|
|
||||||
Look for ``tox``, and if not found, install it via ``pip`` into a
|
Look for ``tox``, and if not found, install it via ``pip`` in the user
|
||||||
virtual environment for the current user.
|
install directory (i.e., ``pip install --user``).
|
||||||
|
|
||||||
**Role Variables**
|
**Role Variables**
|
||||||
|
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
tox_executable: tox
|
tox_executable: tox
|
||||||
tox_venv_path: '{{ ansible_user_dir }}/.local/tox'
|
|
||||||
tox_prefer_python2: false
|
tox_prefer_python2: false
|
||||||
|
@ -4,33 +4,41 @@
|
|||||||
vars:
|
vars:
|
||||||
ensure_pip_from_packages_with_python2: '{{ tox_prefer_python2 }}'
|
ensure_pip_from_packages_with_python2: '{{ tox_prefer_python2 }}'
|
||||||
|
|
||||||
- name: Check if tox is installed
|
- name: Ensure tox is installed
|
||||||
shell: |
|
shell: |
|
||||||
command -v {{ tox_executable }} || exit 1
|
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_executable }} || $PIP install --user tox
|
||||||
args:
|
args:
|
||||||
executable: /bin/bash
|
executable: /bin/bash
|
||||||
register: tox_preinstalled
|
register: result
|
||||||
failed_when: false
|
changed_when: "'Successfully installed' in result.stdout"
|
||||||
|
|
||||||
- name: Export preinstalled tox_exectuable
|
- name: Set tox_executable fact to pip installed
|
||||||
set_fact:
|
set_fact:
|
||||||
tox_executable: '{{ tox_executable }}'
|
tox_executable: "{{ ansible_user_dir }}/.local/bin/tox"
|
||||||
cacheable: true
|
cacheable: true
|
||||||
when: tox_preinstalled.rc == 0
|
when: result is changed
|
||||||
|
|
||||||
- name: Install tox to local env
|
- name: Set tox_exectuable fact to found tox
|
||||||
when: tox_preinstalled.rc != 0
|
|
||||||
block:
|
|
||||||
- name: Install tox to local venv
|
|
||||||
pip:
|
|
||||||
name: tox
|
|
||||||
virtualenv_command: '{{ ensure_pip_virtualenv_command }}'
|
|
||||||
virtualenv: '{{ tox_venv_path }}'
|
|
||||||
|
|
||||||
- name: Export installed tox_executable path
|
|
||||||
set_fact:
|
set_fact:
|
||||||
tox_executable: '{{ tox_venv_path }}/bin/tox'
|
tox_executable: "{{ tox_executable }}"
|
||||||
cacheable: true
|
cacheable: true
|
||||||
|
when: result is not changed
|
||||||
|
|
||||||
- name: Output tox version
|
- name: Output tox version
|
||||||
command: "{{ tox_executable }} --version"
|
command: "{{ tox_executable }} --version"
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
- name: Verify tox_executable is set
|
- name: Verify tox_executable is set
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- tox_executable == "{{ ansible_user_dir }}/.local/tox/bin/tox"
|
- tox_executable == "{{ ansible_user_dir }}/.local/bin/tox"
|
||||||
- name: Verify tox is installed
|
- name: Verify tox is installed
|
||||||
command: "{{ tox_executable }} --version"
|
command: "{{ tox_executable }} --version"
|
||||||
register: result
|
register: result
|
||||||
|
Loading…
x
Reference in New Issue
Block a user