Skip to content

Commit 49e536b

Browse files
fix: push down cpython module down
This is to avoid the cyclic import error when lldb is loaded directly from Python
1 parent 10f6d01 commit 49e536b

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

lldb/bindings/python/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function(finish_swig_python swig_target lldb_python_bindings_dir lldb_python_tar
6060
# Add a Post-Build Event to copy over Python files and create the symlink to
6161
# liblldb.so for the Python API(hardlink on Windows).
6262
add_custom_target(${swig_target} ALL VERBATIM
63-
COMMAND ${CMAKE_COMMAND} -E make_directory ${lldb_python_target_dir}
63+
COMMAND ${CMAKE_COMMAND} -E make_directory ${lldb_python_target_dir}/native/
6464
DEPENDS ${lldb_python_bindings_dir}/lldb.py
6565
COMMENT "Python script sym-linking LLDB Python API")
6666

@@ -74,6 +74,8 @@ function(finish_swig_python swig_target lldb_python_bindings_dir lldb_python_tar
7474
"${LLDB_SOURCE_DIR}/source/Interpreter/embedded_interpreter.py"
7575
"${lldb_python_target_dir}")
7676

77+
create_python_package(${swig_target} ${lldb_python_target_dir} "native" FILES)
78+
7779
# Distribute the examples as python packages.
7880
create_python_package(
7981
${swig_target}
@@ -141,7 +143,7 @@ function(finish_swig_python swig_target lldb_python_bindings_dir lldb_python_tar
141143
endif()
142144
set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb${LLDB_PYTHON_EXT_SUFFIX}")
143145
create_relative_symlink(${swig_target} ${LIBLLDB_SYMLINK_DEST}
144-
${lldb_python_target_dir} ${LIBLLDB_SYMLINK_OUTPUT_FILE})
146+
${lldb_python_target_dir}/native/ ${LIBLLDB_SYMLINK_OUTPUT_FILE})
145147

146148

147149
if (NOT WIN32)

lldb/bindings/python/python.swig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Older swig versions will simply ignore this setting.
5050
import $module
5151
except ImportError:
5252
# Relative import should work if we are being loaded by Python.
53-
from . import $module"
53+
from .native import $module"
5454
%enddef
5555

5656
// The name of the module to be created.

lldb/source/API/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ add_lldb_library(liblldb SHARED ${option_framework}
145145
${option_install_prefix}
146146
)
147147

148-
# lib/pythonX.Y/dist-packages/lldb/_lldb.so is a symlink to lib/liblldb.so,
148+
# lib/pythonX.Y/site-packages/lldb/_lldb.so is a symlink to lib/liblldb.so,
149149
# which depends on lib/libLLVM*.so (BUILD_SHARED_LIBS) or lib/libLLVM-10git.so
150150
# (LLVM_LINK_LLVM_DYLIB). Add an additional rpath $ORIGIN/../../../../lib so
151151
# that _lldb.so can be loaded from Python.

0 commit comments

Comments
 (0)