print-lldb-path
authorGianfranco Costamagna <locutusofborg@debian.org>
Wed, 18 Dec 2024 09:01:43 +0000 (10:01 +0100)
committerSylvestre Ledru <sylvestre@debian.org>
Wed, 18 Dec 2024 09:01:43 +0000 (10:01 +0100)
Last-Update: 2023-01-19

Gbp-Pq: Topic lldb
Gbp-Pq: Name print-lldb-path.patch

lldb/bindings/python/get-python-config.py
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

index ae84cbb1215a9e36c1718f688b44750d94d0a577..e702a3008cc5c70d5e2a0d557d6c5435862e1f37 100755 (executable)
@@ -16,6 +16,7 @@ def relpath_nodots(path, base):
 
 
 def main():
+    import sysconfig
     parser = argparse.ArgumentParser(description="extract cmake variables from python")
     parser.add_argument("variable_name")
     args = parser.parse_args()
@@ -32,7 +33,19 @@ def main():
         # If not, you'll have to use lldb -P or lldb -print-script-interpreter-info
         # to figure out where it is.
         try:
-            print(relpath_nodots(sysconfig.get_path("platlib"), sys.prefix))
+            if hasattr(sysconfig, 'get_default_scheme'):
+                scheme = sysconfig.get_default_scheme()
+            else:
+                scheme = sysconfig._get_default_scheme()
+            if scheme == 'posix_local':
+                # Debian's default scheme installs to /usr/local/ but we want to find headers in /usr/
+                scheme = 'posix_prefix'
+                path = sysconfig.get_path('purelib', scheme)
+            else:
+                from distutils import sysconfig
+                path = sysconfig.get_python_lib(0, 0)
+
+            print(relpath_nodots(path, sys.prefix))
         except ValueError:
             # Try to fall back to something reasonable if sysconfig's platlib
             # is outside of sys.prefix
index 70fa6d83e306fc58dca730f4ec1f55f7bcf68220..e96a83694fd5c248ca50a9614bf6f556f5924814 100644 (file)
@@ -261,6 +261,7 @@ void ScriptInterpreterPython::ComputePythonDir(
   // the real python interpreter uses.  (e.g. lib for most, lib64 on RHEL
   // x86_64, or bin on Windows).
   llvm::sys::path::remove_filename(path);
+  llvm::sys::path::append(path, "/llvm-" + std::to_string(LLVM_VERSION_MAJOR));
   llvm::sys::path::append(path, LLDB_PYTHON_RELATIVE_LIBDIR);
 
 #if defined(_WIN32)