[Lldb-commits] [lldb] 27ca945 - [lldb] add fallback for LLDB_PYTHON_RELATIVE_PATH
Lawrence D'Anna via lldb-commits
lldb-commits at lists.llvm.org
Thu Dec 2 21:14:03 PST 2021
Author: Lawrence D'Anna
Date: 2021-12-02T21:13:35-08:00
New Revision: 27ca9458012caf8b556ce31fc7aaac571af878d2
URL: https://github.com/llvm/llvm-project/commit/27ca9458012caf8b556ce31fc7aaac571af878d2
DIFF: https://github.com/llvm/llvm-project/commit/27ca9458012caf8b556ce31fc7aaac571af878d2.diff
LOG: [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
Added:
Modified:
lldb/bindings/python/get-python-config.py
Removed:
################################################################################
diff --git a/lldb/bindings/python/get-python-config.py b/lldb/bindings/python/get-python-config.py
index 5b670d77451a3..32d82a54c160f 100755
--- a/lldb/bindings/python/get-python-config.py
+++ b/lldb/bindings/python/get-python-config.py
@@ -30,7 +30,17 @@ def main():
# lldb's python lib will be put in the correct place for python to find it.
# If not, you'll have to use lldb -P or lldb -print-script-interpreter-info
# to figure out where it is.
- print(relpath_nodots(sysconfig.get_path("platlib"), sys.prefix))
+ try:
+ print(relpath_nodots(sysconfig.get_path("platlib"), sys.prefix))
+ except ValueError:
+ # Try to fall back to something reasonable if sysconfig's platlib
+ # is outside of sys.prefix
+ if os.name == 'posix':
+ print('lib/python%d.%d/site-packages' % sys.version_info[:2])
+ elif os.name == 'nt':
+ print('Lib\\site-packages')
+ else:
+ raise
elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
tried = list()
exe = sys.executable
@@ -57,4 +67,4 @@ def main():
parser.error(f"unknown variable {args.variable_name}")
if __name__ == '__main__':
- main()
\ No newline at end of file
+ main()
More information about the lldb-commits
mailing list