[Lldb-commits] [PATCH] D67890: [lldb] [cmake] Fix installing Python modules on systems using /usr/lib

Michał Górny via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 24 10:49:58 PDT 2019


mgorny updated this revision to Diff 221555.
mgorny marked 8 inline comments as done.
mgorny retitled this revision from "[lldb] [cmake] Unify and correct Python module installation paths" to "[lldb] [cmake] Fix installing Python modules on systems using /usr/lib".
mgorny edited the summary of this revision.
mgorny added a comment.

This turned out much harder than expected. Let's go with my original patch instead, and in the meantime I'll try to figure out how to properly use relative libdir everywhere.


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

https://reviews.llvm.org/D67890

Files:
  lldb/scripts/CMakeLists.txt
  lldb/scripts/get_relative_lib_dir.py


Index: lldb/scripts/get_relative_lib_dir.py
===================================================================
--- lldb/scripts/get_relative_lib_dir.py
+++ lldb/scripts/get_relative_lib_dir.py
@@ -23,7 +23,7 @@
     # right answer always.
     arch_specific_libdir = distutils.sysconfig.get_python_lib(True, False)
     split_libdir = arch_specific_libdir.split(os.sep)
-    lib_re = re.compile(r"^lib.+$")
+    lib_re = re.compile(r"^lib.*$")
 
     for i in range(len(split_libdir)):
         match = lib_re.match(split_libdir[i])
Index: lldb/scripts/CMakeLists.txt
===================================================================
--- lldb/scripts/CMakeLists.txt
+++ lldb/scripts/CMakeLists.txt
@@ -42,15 +42,18 @@
 )
 
 if(NOT LLDB_BUILD_FRAMEWORK)
-  if(CMAKE_SYSTEM_NAME MATCHES "Windows")
-    set(swig_python_subdir site-packages)
-  else()
-    set(swig_python_subdir python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
-  endif()
-
-  set(SWIG_PYTHON_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${swig_python_subdir})
-  set(SWIG_INSTALL_DIR lib${LLVM_LIBDIR_SUFFIX})
+  execute_process(
+    COMMAND ${PYTHON_EXECUTABLE}
+        -c "import distutils.sysconfig, sys; print(distutils.sysconfig.get_python_lib(True, False, sys.argv[1]))"
+        ${CMAKE_BINARY_DIR}
+    OUTPUT_VARIABLE SWIG_PYTHON_DIR
+    OUTPUT_STRIP_TRAILING_WHITESPACE)
+  execute_process(
+    COMMAND ${PYTHON_EXECUTABLE}
+        -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(True, False, ''))"
+    OUTPUT_VARIABLE SWIG_INSTALL_DIR
+    OUTPUT_STRIP_TRAILING_WHITESPACE)
 
   # Install the LLDB python module
-  install(DIRECTORY ${SWIG_PYTHON_DIR} DESTINATION ${SWIG_INSTALL_DIR})
+  install(DIRECTORY ${SWIG_PYTHON_DIR}/ DESTINATION ${SWIG_INSTALL_DIR})
 endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67890.221555.patch
Type: text/x-patch
Size: 1774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190924/658342a8/attachment-0001.bin>


More information about the lldb-commits mailing list