[Lldb-commits] [PATCH] D114973: [lldb] add fallback for LLDB_PYTHON_RELATIVE_PATH

Lawrence D'Anna via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 2 10:32:31 PST 2021


lawrence_danna created this revision.
lawrence_danna added reviewers: labath, jingham, JDevlieghere.
lawrence_danna requested review of this revision.
Herald added a project: LLDB.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114973

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


Index: lldb/bindings/python/get-python-config.py
===================================================================
--- lldb/bindings/python/get-python-config.py
+++ lldb/bindings/python/get-python-config.py
@@ -30,7 +30,17 @@
         # 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114973.391384.patch
Type: text/x-patch
Size: 1105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211202/8fba2efe/attachment.bin>


More information about the lldb-commits mailing list