From 480580c99e9cec1833527259c73f890c0650d091 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Sun, 17 May 2020 18:10:01 +0200 Subject: [PATCH] python3-env: Install wheel packages if required. --- library/roles/python3-env/defaults/main.yml | 5 ++++ library/roles/python3-env/tasks/main.yml | 29 ++++++++++++++------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/library/roles/python3-env/defaults/main.yml b/library/roles/python3-env/defaults/main.yml index 21b5c8d3..ef5bdc44 100644 --- a/library/roles/python3-env/defaults/main.yml +++ b/library/roles/python3-env/defaults/main.yml @@ -16,6 +16,11 @@ py3_env_dpkg: - 'python{{ py3_env_version }}-venv' - 'python{{ py3_env_version }}-dev' +py3_env_pip_default_pkgs: + - 'pip' + - 'setuptools' + - 'wheel' +py3_env_wheel_pip_pkgs: [] py3_env_pip_pkgs: [] py3_env_versioned_pip_pkgs: [] diff --git a/library/roles/python3-env/tasks/main.yml b/library/roles/python3-env/tasks/main.yml index 97b3a440..4697128b 100644 --- a/library/roles/python3-env/tasks/main.yml +++ b/library/roles/python3-env/tasks/main.yml @@ -20,24 +20,33 @@ shell: python{{ py3_env_version }} -m ensurepip && pip{{ py3_env_version }} install --upgrade pip setuptools wheel when: ansible_distribution_version is version_compare('18.04', '<') - - name: Install a list of pip packages - pip: executable=pip{{ py3_env_version }} name={{ py3_env_pip_pkgs }} state={{ py3_pip_pkgs_state }} - when: ansible_distribution_version is version_compare('18.04', '<') - - - name: Install a list of pip packages - pip: executable=pip{{ py3_env_major_version }} name={{ py3_env_pip_pkgs }} state={{ py3_pip_pkgs_state }} - when: ansible_distribution_version is version_compare('18.04', '>=') - - - name: Install a list of versioned pip packages + - name: Install a list of versioned pip3 packages on Ubuntu older than Trusty pip: executable=pip{{ py3_env_version }} name={{ item.pkg }} version={{ item.version }} with_items: '{{ py3_env_versioned_pip_pkgs | default ([]) }}' when: ansible_distribution_version is version_compare('18.04', '<') - - name: Install a list of versioned pip packages + - name: Install a list of pip3 packages on Ubuntu older than Trusty + pip: executable=pip{{ py3_env_version }} name={{ py3_env_pip_pkgs }} state={{ py3_pip_pkgs_state }} + when: ansible_distribution_version is version_compare('18.04', '<') + + - name: Ensure that we have the latest pip, setuptools and wheel versions + pip: + executable: 'pip{{ py3_env_major_version }}' + name: '{{ py3_env_pip_default_pkgs }}' + state: latest + + - name: Install a list of binary pip3 packages in wheels format + pip: executable=pip{{ py3_env_major_version }} name={{ py3_env_wheel_pip_pkgs }} state={{ py3_pip_pkgs_state }} + + - name: Install a list of versioned pip3 packages on Ubuntu Bionic or newer pip: executable=pip{{ py3_env_major_version }} name={{ item.pkg }} version={{ item.version }} with_items: '{{ py3_env_versioned_pip_pkgs | default ([]) }}' when: ansible_distribution_version is version_compare('18.04', '>=') + - name: Install a list of pip3 packages on Ubuntu Bionic or newer + pip: executable=pip{{ py3_env_major_version }} name={{ py3_env_pip_pkgs }} state={{ py3_pip_pkgs_state }} + when: ansible_distribution_version is version_compare('18.04', '>=') + when: py3_env_install tags: [ "python", "py3_env", "py3_env_pkgs", 'python3' ]