llvm.org GIT mirror llvm / e410b0a
[lit] Respect PYTHONPATH If a user has PYTHONPATH set in the environment, append new entries to it rather than blindly setting PYTHONPATH to a fixed string. This allows tests to, for example, find psutil if it is in PYTHONPATH. Without this change, lit will detect psutil but then various tests will fail because PYTHONPATH has been overwritten and psutil cannot be found. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350536 91177308-0d34-0410-b5e6-96231b3b80d8 David Greene 8 months ago
2 changed file(s) with 18 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
2727 config.test_exec_root = config.test_source_root
2828 config.target_triple = '(unused)'
2929 src_root = os.path.join(config.test_source_root, '..')
30 config.environment['PYTHONPATH'] = src_root
30
31 pythonpath_list = [src_root]
32 # Ensure the user's PYTHONPATH is included.
33 if 'PYTHONPATH' in os.environ:
34 pythonpath_list.append(os.environ['PYTHONPATH'])
35 if 'PYTHONPATH' in config.environment:
36 pythonpath_list.append(config.environment['PYTHONPATH'])
37 config.environment['PYTHONPATH'] = os.pathsep.join(pythonpath_list)
38
3139 config.substitutions.append(('%{python}', '"%s"' % (sys.executable)))
3333 else:
3434 lit_path = src_root
3535
36 config.environment['PYTHONPATH'] = lit_path # Required because some tests import the lit module
36 pythonpath_list = [lit_path] # Required because some tests import the lit module
37
38 # Ensure the user's PYTHONPATH is included.
39 if 'PYTHONPATH' in os.environ:
40 pythonpath_list.append(os.environ['PYTHONPATH'])
41 if 'PYTHONPATH' in config.environment:
42 pythonpath_list.append(config.environment['PYTHONPATH'])
43 config.environment['PYTHONPATH'] = os.pathsep.join(pythonpath_list)
44
3745 config.substitutions.append(('%{src_root}', src_root))
3846 config.substitutions.append(('%{inputs}', os.path.join(
3947 src_root, 'tests', 'Inputs')))