This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Fix detection of LLDB_PYTHON_EXE_RELATIVE_PATH
Needs ReviewPublic

Authored by skosukhin on Sep 8 2022, 11:44 AM.

Details

Reviewers
lawrence_danna
Summary

It looks like f07ddbc6 broke the building when sys.executable is not a symlink itself but resides in a prefix that is one:

$ readlink /sw
/opt/zmaw/sw
$ /sw/python-3.9.12/bin/python3.9 ./get-python-config.py LLDB_PYTHON_EXE_RELATIVE_PATH
Could not find a relative path to sys.executable under sys.prefix
tried: /sw/python-3.9.12/bin/python3.9
realpath(sys.prefix): /opt/zmaw/sw/python-3.9.12
sys.prefix: /sw/python-3.9.12

I think it makes sense to try sys.prefix and sys.executable first and only then try to resolve the real paths for both sys.prefix and os.path.dirname(sys.executable).
I would remove the elif os.path.islink(exe): logic as it seems to be redundant but I cannot tell for sure that it is.

Diff Detail

Event Timeline

skosukhin created this revision.Sep 8 2022, 11:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 8 2022, 11:44 AM
skosukhin requested review of this revision.Sep 8 2022, 11:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 8 2022, 11:44 AM