summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2021-01-28 23:53:05 +0100
committerMatt Clay <matt@mystile.com>2021-01-29 00:59:55 +0100
commitc7cb944315a67fe575d5e83bdb897cdacaea8a44 (patch)
tree6c40b8f686f7462b157e20d0cd2405fc456452f5 /test
parentAdd Python 3.8 and Python 3.9 to the fallback list (#73405) (diff)
downloadansible-c7cb944315a67fe575d5e83bdb897cdacaea8a44.tar.xz
ansible-c7cb944315a67fe575d5e83bdb897cdacaea8a44.zip
Always use python exec wrapper in ansible-test.
Diffstat (limited to 'test')
-rw-r--r--test/lib/ansible_test/_internal/util_common.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/test/lib/ansible_test/_internal/util_common.py b/test/lib/ansible_test/_internal/util_common.py
index de3d284d19..ed7fa08ab2 100644
--- a/test/lib/ansible_test/_internal/util_common.py
+++ b/test/lib/ansible_test/_internal/util_common.py
@@ -252,18 +252,17 @@ def get_python_path(args, interpreter):
python_path = tempfile.mkdtemp(prefix=prefix, suffix=suffix, dir=root_temp_dir)
injected_interpreter = os.path.join(python_path, 'python')
- # A symlink is faster than the execv wrapper, but isn't compatible with virtual environments.
- # Attempt to detect when it is safe to use a symlink by checking the real path of the interpreter.
- use_symlink = os.path.dirname(os.path.realpath(interpreter)) == os.path.dirname(interpreter)
+ # A symlink is faster than the execv wrapper, but isn't guaranteed to provide the correct result.
+ # There are several scenarios known not to work with symlinks:
+ #
+ # - A virtual environment where the target is a symlink to another directory.
+ # - A pyenv environment where the target is a shell script that changes behavior based on the program name.
+ #
+ # To avoid issues for these and other scenarios, only an exec wrapper is used.
- if use_symlink:
- display.info('Injecting "%s" as a symlink to the "%s" interpreter.' % (injected_interpreter, interpreter), verbosity=1)
+ display.info('Injecting "%s" as a execv wrapper for the "%s" interpreter.' % (injected_interpreter, interpreter), verbosity=1)
- os.symlink(interpreter, injected_interpreter)
- else:
- display.info('Injecting "%s" as a execv wrapper for the "%s" interpreter.' % (injected_interpreter, interpreter), verbosity=1)
-
- create_interpreter_wrapper(interpreter, injected_interpreter)
+ create_interpreter_wrapper(interpreter, injected_interpreter)
os.chmod(python_path, MODE_DIRECTORY)