diff options
author | Matt Clay <matt@mystile.com> | 2024-01-11 21:02:57 +0100 |
---|---|---|
committer | Matt Clay <matt@mystile.com> | 2024-01-11 23:10:31 +0100 |
commit | 21247c828ea58c5900fef7f2e9277fe2183b6ce0 (patch) | |
tree | feb1bb34c3e81e6388a17b5d8ea70116f34b21ea | |
parent | expect - fix argument spec error with timeout=null (#82522) (diff) | |
download | ansible-21247c828ea58c5900fef7f2e9277fe2183b6ce0.tar.xz ansible-21247c828ea58c5900fef7f2e9277fe2183b6ce0.zip |
ansible-test - Bypass PEP 668 checks
When ansible-test installs requirements, it now instructs pip to allow installs on externally managed environments as defined by PEP 668.
This only occurs in ephemeral environments managed by ansible-test, such as containers,
or when the `--requirements` option is used.
-rw-r--r-- | changelogs/fragments/ansible-test-pep-668.yml | 3 | ||||
-rw-r--r-- | test/lib/ansible_test/_util/target/setup/requirements.py | 8 |
2 files changed, 11 insertions, 0 deletions
diff --git a/changelogs/fragments/ansible-test-pep-668.yml b/changelogs/fragments/ansible-test-pep-668.yml new file mode 100644 index 0000000000..b17428c146 --- /dev/null +++ b/changelogs/fragments/ansible-test-pep-668.yml @@ -0,0 +1,3 @@ +minor_changes: +- ansible-test - When ansible-test installs requirements, it now instructs pip to allow installs on externally managed environments as defined by PEP 668. + This only occurs in ephemeral environments managed by ansible-test, such as containers, or when the `--requirements` option is used. diff --git a/test/lib/ansible_test/_util/target/setup/requirements.py b/test/lib/ansible_test/_util/target/setup/requirements.py index 0bf52157d3..a320dfce19 100644 --- a/test/lib/ansible_test/_util/target/setup/requirements.py +++ b/test/lib/ansible_test/_util/target/setup/requirements.py @@ -249,6 +249,14 @@ def common_pip_environment(): # type: () -> t.Dict[str, str] """Return common environment variables used to run pip.""" env = os.environ.copy() + # When ansible-test installs requirements outside a virtual environment, it does so under one of two conditions: + # 1) The environment is an ephemeral one provisioned by ansible-test. + # 2) The user has provided the `--requirements` option to force installation of requirements. + # It seems reasonable to bypass PEP 668 checks in both of these cases. + # Doing so with an environment variable allows it to work under any version of pip which supports it, without breaking older versions. + # NOTE: pip version 23.0 enforces PEP 668 but does not support the override, in which case upgrading pip is required. + env.update(PIP_BREAK_SYSTEM_PACKAGES='1') + return env |