[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 21:14:15 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG27ca9458012c: [lldb] add fallback for LLDB_PYTHON_RELATIVE_PATH (authored by lawrence_danna).

Changed prior to commit:
  https://reviews.llvm.org/D114973?vs=391384&id=391541#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114973/new/

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
@@ -57,4 +67,4 @@
         parser.error(f"unknown variable {args.variable_name}")
 
 if __name__ == '__main__':
-    main()
\ No newline at end of file
+    main()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114973.391541.patch
Type: text/x-patch
Size: 1269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211203/c9a9aeba/attachment-0001.bin>


More information about the lldb-commits mailing list