From eb2fd11b4dec5428eaef843c4b6beb7008ddc76c Mon Sep 17 00:00:00 2001 From: Andrew Bonney Date: Wed, 25 Feb 2026 13:33:36 +0000 Subject: [PATCH] Add variable/env var for extra venv build deps and their binaries Where a wheel build requires an extra build tool (e.g. maturin) this provides a way to specify the extra build dependency without having to re-specify the core requirements. Additionally this respects the venv bin directory as part of the PATH when building wheels so that any build tool binaries are executable by pip. Signed-off-by: Andrew Bonney Change-Id: I7c93e808f4a87bcaa5e2ee6f507bd1f9575d8f94 --- defaults/main.yml | 3 +++ tasks/python_venv_wheel_build.yml | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 2419dbc..631c130 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -75,6 +75,9 @@ venv_build_requirements: - setuptools - wheel +# Additional build venv dependencies +venv_build_requirements_extra: [] + # A list of constraints to be applied when building # or installing python packages. venv_build_constraints: [] diff --git a/tasks/python_venv_wheel_build.yml b/tasks/python_venv_wheel_build.yml index cad9c14..ad35663 100644 --- a/tasks/python_venv_wheel_build.yml +++ b/tasks/python_venv_wheel_build.yml @@ -97,7 +97,7 @@ - name: Upgrade the wheel build virtualenv pip/setuptools/wheel to the versions we want ansible.builtin.pip: - name: "{{ ['pip'] + venv_build_requirements }}" + name: "{{ ['pip'] + venv_build_requirements + venv_build_requirements_extra }}" state: "{{ venv_pip_package_state }}" virtualenv: "{{ venv_build_host_venv_path }}" virtualenv_command: "{{ venv_python_executable }} -m venv" @@ -139,7 +139,10 @@ {{ venv_default_pip_build_args }} {{ venv_pip_build_args }} {{ venv_wheels_rebuild | ternary('--no-cache-dir', '') }} - environment: "{{ venv_pip_build_env }}" + environment: "{{ venv_pip_build_env | combine(_venv_pip_build_env_path) }}" + vars: + _venv_pip_build_env_path: + PATH: "{{ venv_build_host_venv_path }}/bin:{{ ansible_facts['env']['PATH'] }}" register: _build_python_wheels until: _build_python_wheels is success retries: 5