mirror of
https://github.com/ansible/ansible.git
synced 2026-08-04 16:13:32 +02:00
respawn: Update ENV dict copy with PYTHONPATH value (#84962)
* Use shallow copy of os.environ to update PYTHONPATH value instead of using '|' operator Fixes: #84954 Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- respawn - use copy of env variables to update existing PYTHONPATH value (https://github.com/ansible/ansible/issues/84954).
|
||||||
@@ -56,10 +56,13 @@ def probe_interpreters_for_module(interpreter_paths, module_name):
|
|||||||
:arg interpreter_paths: iterable of paths to Python interpreters. The paths will be probed
|
:arg interpreter_paths: iterable of paths to Python interpreters. The paths will be probed
|
||||||
in order, and the first path that exists and can successfully import the named module will
|
in order, and the first path that exists and can successfully import the named module will
|
||||||
be returned (or ``None`` if probing fails for all supplied paths).
|
be returned (or ``None`` if probing fails for all supplied paths).
|
||||||
:arg module_name: fully-qualified Python module name to probe for (eg, ``selinux``)
|
:arg module_name: fully-qualified Python module name to probe for (for example, ``selinux``)
|
||||||
"""
|
"""
|
||||||
PYTHONPATH = os.getenv('PYTHONPATH', '')
|
PYTHONPATH = os.getenv('PYTHONPATH', '')
|
||||||
env = os.environ | {'PYTHONPATH': f'{_ANSIBLE_PARENT_PATH}:{PYTHONPATH}'.rstrip(': ')}
|
env = os.environ.copy()
|
||||||
|
env.update({
|
||||||
|
'PYTHONPATH': f'{_ANSIBLE_PARENT_PATH}:{PYTHONPATH}'.rstrip(': ')
|
||||||
|
})
|
||||||
for interpreter_path in interpreter_paths:
|
for interpreter_path in interpreter_paths:
|
||||||
if not os.path.exists(interpreter_path):
|
if not os.path.exists(interpreter_path):
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user