Skip to content

Commit 19c735e

Browse files
mgornytstellar
authored andcommitted
Merging r372835:
------------------------------------------------------------------------ r372835 | mgorny | 2019-09-25 02:47:35 -0700 (Wed, 25 Sep 2019) | 12 lines [lldb] [cmake] Fix installing Python modules on systems using /usr/lib Fix installing Python modules on systems that use /usr/lib for Python while installing other libraries in /usr/lib64. Rewrite CMake logic to query correct directories from Python, similarly to how prepare_binding_Python.py does it. Furthermore, change the regex used in get_relative_lib_dir.py to allow 'lib' without suffix. I think that the code can be further improved but I'd like to take this enterprise in smaller steps in case one of them breaks something. Differential Revision: https://reviews.llvm.org/D67890 ------------------------------------------------------------------------
1 parent 9b2d207 commit 19c735e

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

lldb/scripts/CMakeLists.txt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,18 @@ add_custom_target(swig_wrapper ALL DEPENDS
4242
)
4343

4444
if(NOT LLDB_BUILD_FRAMEWORK)
45-
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
46-
set(swig_python_subdir site-packages)
47-
else()
48-
set(swig_python_subdir python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
49-
endif()
50-
51-
set(SWIG_PYTHON_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${swig_python_subdir})
52-
set(SWIG_INSTALL_DIR lib${LLVM_LIBDIR_SUFFIX})
45+
execute_process(
46+
COMMAND ${PYTHON_EXECUTABLE}
47+
-c "import distutils.sysconfig, sys; print(distutils.sysconfig.get_python_lib(True, False, sys.argv[1]))"
48+
${CMAKE_BINARY_DIR}
49+
OUTPUT_VARIABLE SWIG_PYTHON_DIR
50+
OUTPUT_STRIP_TRAILING_WHITESPACE)
51+
execute_process(
52+
COMMAND ${PYTHON_EXECUTABLE}
53+
-c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(True, False, ''))"
54+
OUTPUT_VARIABLE SWIG_INSTALL_DIR
55+
OUTPUT_STRIP_TRAILING_WHITESPACE)
5356

5457
# Install the LLDB python module
55-
install(DIRECTORY ${SWIG_PYTHON_DIR} DESTINATION ${SWIG_INSTALL_DIR})
58+
install(DIRECTORY ${SWIG_PYTHON_DIR}/ DESTINATION ${SWIG_INSTALL_DIR})
5659
endif()

lldb/scripts/get_relative_lib_dir.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get_python_relative_libdir():
2323
# right answer always.
2424
arch_specific_libdir = distutils.sysconfig.get_python_lib(True, False)
2525
split_libdir = arch_specific_libdir.split(os.sep)
26-
lib_re = re.compile(r"^lib.+$")
26+
lib_re = re.compile(r"^lib.*$")
2727

2828
for i in range(len(split_libdir)):
2929
match = lib_re.match(split_libdir[i])

0 commit comments

Comments
 (0)