[lit] Drop the user-site packages directory from search paths when running tests

Do not add user-site packages directory to the python search path.
This avoids test failures if there's an incompatible lit module installed
inside the user-site packages directory, as it gets prioritized over the lit
from the PYTHONPATH.
This commit is contained in:
Alex Lorenz 2019-10-27 13:28:59 -07:00
parent 06d3fce01d
commit 32837a60ac
1 changed files with 4 additions and 0 deletions

View File

@ -40,6 +40,10 @@ if llvm_config:
llvm_config.with_environment('PYTHONPATH', lit_path, append_path=True)
else:
config.environment['PYTHONPATH'] = os.pathsep.join([lit_path])
# Do not add user-site packages directory to the python search path. This avoids test failures if there's an
# incompatible lit module installed inside the user-site packages directory, as it gets prioritized over the lit
# from the PYTHONPATH.
config.environment['PYTHONNOUSERSITE'] = '1'
# Add llvm and lit tools directories if this config is being loaded indirectly.
# In this case, we can also expect llvm_config to have been imported correctly.