diff --git a/README.rst b/README.rst index 8b3eb38..8d4f55b 100644 --- a/README.rst +++ b/README.rst @@ -15,9 +15,9 @@ This Ansible role prepares a python venv for use in OpenStack-Ansible. The role requires the following to be present prior to execution: -* pip >= 7.1 (to support using the constraints option) -* virtualenv >= 13.0.0 (to support using the no-pip, no-setuptools, no-wheels - options) +* virtualenv >= 1.10 (to support using the never-download option) +* pip >= 7.1 (to support using the constraints option) in the virtualenv + once it has been created. Use-cases ~~~~~~~~~ diff --git a/tasks/python_venv_build.yml b/tasks/python_venv_build.yml index cfc10ab..40989cd 100644 --- a/tasks/python_venv_build.yml +++ b/tasks/python_venv_build.yml @@ -41,11 +41,15 @@ with_items: - "{{ venv_build_archive_path }}" - "{{ venv_build_wheel_path }}" - - "{{ venv_install_destination_path }}" + +- name: Create the virtualenv (if it does not exist) + command: "virtualenv --no-site-packages {{ _venv_create_no_download }} {{ venv_install_destination_path }}" + args: + creates: "{{ venv_install_destination_path }}/bin/activate" - name: Build wheels for the packages to be installed into the venv command: >- - pip wheel + {{ venv_install_destination_path }}/bin/pip wheel --wheel-dir {{ venv_build_wheel_path }}/ --find-links {{ venv_build_wheel_path }}/ --log /var/log/python_wheel_build.log @@ -54,13 +58,6 @@ when: - venv_build_wheels | bool -#TODO(odyssey4me): -# Split the venv build into multiple parts: -# 1. Create the venv without pip, setuptools, wheel -# 2. Use get-pip.py to install the right versions -# of pip, setuptools, wheel into the venv -# 3. Install the packages into the venv - - name: Build venv pip: name: "{{ venv_pip_packages }}" diff --git a/tasks/python_venv_preflight.yml b/tasks/python_venv_preflight.yml index 259d4de..af5fdf2 100644 --- a/tasks/python_venv_preflight.yml +++ b/tasks/python_venv_preflight.yml @@ -30,34 +30,20 @@ failed_when: false register: _virtualenv_version -- name: Collect the version of pip - shell: | - pip --version 2>/dev/null | awk '{print $2}' || echo 'none' - args: - executable: /bin/bash - changed_when: false - failed_when: false - register: _pip_version - - name: Fail when required virtualenv version is not present fail: msg: >- The required virtualenv version is not present. - The minimum version of 13.0.0 is required, but + The minimum version of 1.10 is required, but {{ _virtualenv_version.stdout }} is installed. when: - ((_virtualenv_version.stdout | trim) == 'none') or - ((_virtualenv_version.stdout | trim) is version_compare('13.0.0', '<')) + ((_virtualenv_version.stdout | trim) is version_compare('1.10', '<')) -- name: Fail when required pip version is not present - fail: - msg: >- - The required virtualenv version is not present. - The minimum version of 7.1 is required, but - {{ _pip_version.stdout }} is installed. - when: - - ((_pip_version.stdout | trim) == 'none') or - ((_pip_version.stdout | trim) is version_compare('7.1', '<')) +- name: Set the correct virtualenv parameter to prevent downloads when creating + set_fact: + _venv_create_no_download: >- + {{ ((_virtualenv_version.stdout | trim) is version_compare('14.0.0', '<')) | ternary('--never-download', '--no-download') }} - name: Check whether the venv_install_source_path is a URL or a file path set_fact: