Remove the virtualenv version check
Simplify this code by making the assumption that we always have a
new enough version of virtualenv present. Centos-7 ships 15.1.0 so
it is now possible to remove some conditional logic as well.
This patch removes the version check and replaces it with a check
that the virtualenv command is present on the system patch and
is usable.
Change-Id: I1a8f4961358c9551c5493b332187b411177b2769
(cherry picked from commit aabd3c07c2
)
This commit is contained in:
@@ -50,7 +50,7 @@
|
|||||||
- name: Create the virtualenv (if it does not exist)
|
- name: Create the virtualenv (if it does not exist)
|
||||||
command: >-
|
command: >-
|
||||||
virtualenv
|
virtualenv
|
||||||
{{ _venv_create_extra_options }}
|
--no-download
|
||||||
--python={{ venv_python_executable }}
|
--python={{ venv_python_executable }}
|
||||||
{{ (ansible_pkg_mgr == 'apt') | ternary('--always-copy', '') }}
|
{{ (ansible_pkg_mgr == 'apt') | ternary('--always-copy', '') }}
|
||||||
{{ venv_install_destination_path }}
|
{{ venv_install_destination_path }}
|
||||||
|
@@ -21,34 +21,15 @@
|
|||||||
when:
|
when:
|
||||||
- venv_install_destination_path is not defined
|
- venv_install_destination_path is not defined
|
||||||
|
|
||||||
- name: Collect the version of virtualenv from either stdout or stderr
|
- name: Check for virtualenv command being available on system path
|
||||||
shell: |
|
command: 'which virtualenv'
|
||||||
virtualenv --version 2>&1 || echo 'none'
|
register: virtualenv_installed
|
||||||
args:
|
ignore_errors: yes
|
||||||
executable: /bin/bash
|
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: false
|
|
||||||
register: _virtualenv_version
|
|
||||||
|
|
||||||
# _virtualenv_version may take two forms:
|
- name: Fail when required virtualenv is not present
|
||||||
# (stdout) '15.1.0'
|
|
||||||
# (stderr) 'virtualenv 20.0.1 from /usr/local/lib/python2.7/dist-packages/virtualenv/__init__.pyc'
|
|
||||||
- name: Extract just the virtualevn version number
|
|
||||||
set_fact:
|
|
||||||
_virtualenv_version_number: "{{ (_virtualenv_version.stdout.split(' ') | length == 1) | ternary(_virtualenv_version.stdout, _virtualenv_version.stdout.split(' ')[1]) }}"
|
|
||||||
|
|
||||||
- name: Fail when required virtualenv version is not present
|
|
||||||
fail:
|
fail:
|
||||||
msg: >-
|
msg: >-
|
||||||
The required virtualenv version is not present.
|
The command 'virtualenv' version is not present.
|
||||||
The minimum version of 1.10 is required, but
|
|
||||||
{{ _virtualenv_version_number }} is installed.
|
|
||||||
when:
|
when:
|
||||||
- ((_virtualenv_version_number | trim) == 'none') or
|
virtualenv_installed.rc != 0
|
||||||
((_virtualenv_version_number | trim) is version('1.10', '<'))
|
|
||||||
|
|
||||||
- name: Set extra virtualenv parameters
|
|
||||||
set_fact:
|
|
||||||
_venv_create_extra_options: >-
|
|
||||||
{{ ((_virtualenv_version_number | trim) is version('14.0.0', '<')) | ternary('--never-download', '--no-download') }}
|
|
||||||
{{ ((_virtualenv_version_number | trim) is version('1.7.0', '<')) | ternary('--no-site-packages', '') }}
|
|
||||||
|
@@ -69,7 +69,7 @@
|
|||||||
- name: Create the wheel build virtualenv (if it does not exist)
|
- name: Create the wheel build virtualenv (if it does not exist)
|
||||||
command: >-
|
command: >-
|
||||||
virtualenv
|
virtualenv
|
||||||
{{ _venv_create_extra_options }}
|
--no-download
|
||||||
--python={{ venv_python_executable }}
|
--python={{ venv_python_executable }}
|
||||||
{{ (ansible_pkg_mgr == 'apt') | ternary('--always-copy', '') }}
|
{{ (ansible_pkg_mgr == 'apt') | ternary('--always-copy', '') }}
|
||||||
{{ venv_build_host_venv_path }}
|
{{ venv_build_host_venv_path }}
|
||||||
|
Reference in New Issue
Block a user