Skip to content

Commit 27ca945

Browse files
[lldb] add fallback for LLDB_PYTHON_RELATIVE_PATH
Some pythons are configured to set platlib somewhere outside of their sys.prefix. It's important that we at least use some reasonable default for LLDB_PYTHON_RELATIVE_PATH even in that case, because even if the user overrides it on the cmake invocation, cmake will still be called without the override in order to build tablegen. Reviewed By: JDevlieghere, clayborg Differential Revision: https://reviews.llvm.org/D114973
1 parent 021ecbb commit 27ca945

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lldb/bindings/python/get-python-config.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,17 @@ def main():
3030
# lldb's python lib will be put in the correct place for python to find it.
3131
# If not, you'll have to use lldb -P or lldb -print-script-interpreter-info
3232
# to figure out where it is.
33-
print(relpath_nodots(sysconfig.get_path("platlib"), sys.prefix))
33+
try:
34+
print(relpath_nodots(sysconfig.get_path("platlib"), sys.prefix))
35+
except ValueError:
36+
# Try to fall back to something reasonable if sysconfig's platlib
37+
# is outside of sys.prefix
38+
if os.name == 'posix':
39+
print('lib/python%d.%d/site-packages' % sys.version_info[:2])
40+
elif os.name == 'nt':
41+
print('Lib\\site-packages')
42+
else:
43+
raise
3444
elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
3545
tried = list()
3646
exe = sys.executable
@@ -57,4 +67,4 @@ def main():
5767
parser.error(f"unknown variable {args.variable_name}")
5868

5969
if __name__ == '__main__':
60-
main()
70+
main()

0 commit comments

Comments
 (0)