This is an archive of the discontinued LLVM Phabricator instance.

Respect PYTHONPATH
ClosedPublic

Authored by greened on Aug 7 2018, 7:43 AM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

greened created this revision.Aug 7 2018, 7:43 AM
delcypher added a comment.EditedAug 22 2018, 1:24 AM

@greened This seems reasonable but I'm wondering under what scenario psutil is installed in a non-standard location which requires the use of PYTHONPATH. The usual way to handle installing a python package that you don't want system wide is to use virtualenv and then run pip install psutil in that environment.

delcypher added inline comments.Aug 22 2018, 1:27 AM
utils/lit/tests/lit.cfg
39

You should add a comment above the if 'PYTHONPATH' explaining why this is being here because it looks like the Required because some tests import the lit module comment is describing the entire block of code, whereas it actually only describes the very first statement (pythonpath_list = [lit_path]).

virtualenv isn't available everywhere. Some sites prefer that users point to a specific Python installation via PYTHONPATH.

greened updated this revision to Diff 162132.Aug 22 2018, 9:35 PM

Moved comment as directed.

greened updated this revision to Diff 162180.Aug 23 2018, 7:44 AM
greened marked an inline comment as done.

Added comment about including the user's PYTHONPATH.

Ping. We're trying to clean up the last few test failures we're seeing.

delcypher accepted this revision.Jan 2 2019, 10:49 AM

@greened Sorry looks like I missed your earlier pings. LGTM

Can you commit this, or would you like me to do it on your behalf?

This revision is now accepted and ready to land.Jan 2 2019, 10:49 AM

Committed in r350536.

greened closed this revision.Jan 7 2019, 8:59 AM