Allow to set ENV vars for wheels build and venv install

It's not always enough to provide extra arguments for pip installation.
For usescases, like isolated installations, and some specific packages
that still utilize deprecated setuptools.installer instead of
PEP 517 installer,
you might find impossible to provide some easyisntall options without
having a configuration file that should be created by deployer as
pre-step. However, these options might be covered with ENV variables.

Change-Id: I9a060cbcdf9f5c54efd423a4b4fe32b418377f86
This commit is contained in:
Dmitriy Rabotyagov 2023-01-23 14:17:47 +01:00
parent a6c6dfe358
commit 7fd75008cf
4 changed files with 22 additions and 4 deletions

View File

@ -75,6 +75,9 @@ venv_build_global_constraints: []
# Arguments to pass to pip when building the wheels
venv_pip_build_args: ""
# Environemnt to be set for building the wheels
venv_pip_build_env: {}
# Default arguments to pass to pip when installing into
# the venv.
venv_default_pip_install_args: >-
@ -86,6 +89,9 @@ venv_default_pip_install_args: >-
# Arguments to pass to pip when installing into the venv
venv_pip_install_args: ""
# Environemnt to be set for building the wheels
venv_pip_install_env: {}
# Some python packages have C bindings which tend to be very
# particular about the version of their underlying shared libraries.
# To ensure things run smoothly for stable releases, we opt to

View File

@ -0,0 +1,6 @@
---
features:
- |
Added variables ``venv_pip_build_env`` and ``venv_pip_install_env`` that
allows to set extra environment variables during wheels build or venv
installation.

View File

@ -135,8 +135,10 @@
--log /var/log/python_venv_build.log
{{ venv_default_pip_install_args }}
{{ venv_pip_install_args }}
environment:
PIP_CONFIG_FILE: "{{ (venv_pip_upgrade_noconf | bool) | ternary('/dev/null', '') }}"
environment: "{{ venv_pip_install_env | combine(_pip_upgrade_noconf) }}"
vars:
_pip_upgrade_noconf:
PIP_CONFIG_FILE: "{{ (venv_pip_upgrade_noconf | bool) | ternary('/dev/null', '') }}"
register: _update_virtualenv_packages
until: _update_virtualenv_packages is success
retries: 5
@ -158,6 +160,7 @@
--log /var/log/python_venv_build.log
{{ venv_default_pip_install_args }}
{{ venv_pip_install_args }}
environment: "{{ venv_pip_install_env }}"
when: (_requirement_file is changed) or (_global_constraint_file is changed) or (_constraint_file is changed)
register: _install_venv_pip_packages
until: _install_venv_pip_packages is success

View File

@ -113,8 +113,10 @@
--find-links {{ venv_build_host_wheel_path }}/
--log /var/log/python_venv_build.log
{{ venv_pip_build_args }}
environment:
PIP_CONFIG_FILE: "{{ (venv_pip_upgrade_noconf | bool) | ternary('/dev/null', '') }}"
environment: "{{ venv_pip_build_env | combine(_pip_upgrade_noconf) }}"
vars:
_pip_upgrade_noconf:
PIP_CONFIG_FILE: "{{ (venv_pip_upgrade_noconf | bool) | ternary('/dev/null', '') }}"
register: _update_virtualenv_packages
until: _update_virtualenv_packages is success
retries: 5
@ -138,6 +140,7 @@
--find-links {{ venv_build_host_wheel_path }}/
--log /var/log/python_wheel_build.log
{{ venv_pip_build_args }}
environment: "{{ venv_pip_build_env }}"
register: _build_python_wheels
until: _build_python_wheels is success
retries: 5