From 6280bd7af2ee3ae212010a5c7883cc9cd09a7dbe Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Thu, 11 Jun 2020 00:15:07 +0200 Subject: [PATCH] Fix ansible-test PATH handling. (#69407) (cherry picked from commit f1b3e8364ea4556b6ab74b017c5fc7bd076bd1b6) Co-authored-by: Matt Clay --- changelogs/fragments/ansible-test-path-to-python.yml | 3 +++ test/lib/ansible_test/_internal/util_common.py | 5 ----- 2 files changed, 3 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/ansible-test-path-to-python.yml diff --git a/changelogs/fragments/ansible-test-path-to-python.yml b/changelogs/fragments/ansible-test-path-to-python.yml new file mode 100644 index 00000000000..c126de85f53 --- /dev/null +++ b/changelogs/fragments/ansible-test-path-to-python.yml @@ -0,0 +1,3 @@ +bugfixes: + - ansible-test no longer optimizes setting ``PATH`` by prepending the directory containing the selected Python interpreter when it is named ``python``. + This avoids unintentionally making other programs available on ``PATH``, including an already installed version of Ansible. diff --git a/test/lib/ansible_test/_internal/util_common.py b/test/lib/ansible_test/_internal/util_common.py index 5be20ee749f..b8f3e217c27 100644 --- a/test/lib/ansible_test/_internal/util_common.py +++ b/test/lib/ansible_test/_internal/util_common.py @@ -171,11 +171,6 @@ def get_python_path(args, interpreter): :type interpreter: str :rtype: str """ - # When the python interpreter is already named "python" its directory can simply be added to the path. - # Using another level of indirection is only required when the interpreter has a different name. - if os.path.basename(interpreter) == 'python': - return os.path.dirname(interpreter) - python_path = PYTHON_PATHS.get(interpreter) if python_path: