Use the virtualenv's pip to build the wheels

Instead of requiring pip installed on the host, we can
use the pip in the virtualenv instead. This keeps the
host cleaner.

Change-Id: I8d6c77e2cfa2cbcd81df21c7ed22a0a344d3b55c
This commit is contained in:
Jesse Pretorius 2018-08-19 20:15:37 +01:00
parent 27471f7b65
commit eea695ecaa
3 changed files with 15 additions and 32 deletions

View File

@ -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
~~~~~~~~~

View File

@ -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 }}"

View File

@ -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: