From 8701591120144766442f4e915f37465f0506a9e2 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Mon, 27 Dec 2021 10:17:28 +0200 Subject: [PATCH] Replace virtualenv with exacutable for pip We create virtualenv with a separate command since we need to create constraints before running pip. In the meanwhile when using pyenv it becomes more messy to use virtualenv, as it would require setting virtualenv_command and you can't define virtualenv_python then. Using exacutable requires setuptools to be present for ansible_python_interpreter Change-Id: I5bf617ad0eca3dd5e58e25af7b44d536dc4579d3 --- tasks/python_venv_install.yml | 6 +++--- tasks/python_venv_wheel_build.yml | 2 +- vars/main.yml | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tasks/python_venv_install.yml b/tasks/python_venv_install.yml index 1b6f184..c342af4 100644 --- a/tasks/python_venv_install.yml +++ b/tasks/python_venv_install.yml @@ -55,7 +55,7 @@ - name: Create the virtualenv (if it does not exist) command: >- - {{ venv_python_executable }} + {{ venv_python_executable }} -m venv {{ venv_install_destination_path }} args: @@ -129,7 +129,7 @@ - setuptools - wheel state: "{{ venv_pip_package_state }}" - virtualenv: "{{ venv_install_destination_path }}" + executable: "{{ venv_install_destination_path }}/bin/pip" extra_args: >- --constraint {{ venv_install_destination_path }}/global-constraints.txt --constraint {{ venv_install_destination_path }}/constraints.txt @@ -151,7 +151,7 @@ pip: name: "{{ _venv_install_pip_packages }}" state: "{{ venv_pip_package_state }}" - virtualenv: "{{ venv_install_destination_path }}" + executable: "{{ venv_install_destination_path }}/bin/pip" extra_args: >- --constraint {{ venv_install_destination_path }}/global-constraints.txt --constraint {{ venv_install_destination_path }}/constraints.txt diff --git a/tasks/python_venv_wheel_build.yml b/tasks/python_venv_wheel_build.yml index b2edc27..07689a5 100644 --- a/tasks/python_venv_wheel_build.yml +++ b/tasks/python_venv_wheel_build.yml @@ -105,7 +105,7 @@ - setuptools - wheel state: "{{ venv_pip_package_state }}" - virtualenv: "{{ venv_build_host_venv_path }}" + executable: "{{ venv_build_host_venv_path }}/bin/pip" extra_args: >- --constraint {{ _venv_build_requirements_prefix }}-global-constraints.txt --constraint {{ _venv_build_requirements_prefix }}-source-constraints.txt diff --git a/vars/main.yml b/vars/main.yml index 4afb8ac..09b284a 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -20,6 +20,7 @@ _venv_build_base_distro_package_list: - "{{ (venv_python_executable == 'python2') | ternary('pkg-config', 'python3-pkgconfig') }}" - "{{ (venv_python_executable == 'python2') | ternary('python-dev', 'python3-dev') }}" - python3-venv + - python3-setuptools redhat: - autoconf - cmake @@ -30,6 +31,7 @@ _venv_build_base_distro_package_list: _venv_install_base_distro_package_list: debian: - python3-venv + - python3-setuptools redhat: [] # Set the available build targets for all nodes within an environment.