From 9327e4d4e930a79a31cfc4825243ca748c1ff310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20L=C3=BCke?= Date: Wed, 1 Jan 2025 21:25:57 +0100 Subject: [PATCH] use rtld_global when loading plugins - fixes debugpy/numpy import issue --- src/CMakeLists.txt | 1 + src/internal/mana_lib.hpp | 2 +- src/mana_plugin_python.cc | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 164d471..0e6ce15 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,6 +63,7 @@ if (pybind11_FOUND) target_link_libraries(mana-plugin-python PRIVATE mana mesytec-mnode rxi-logc pybind11::embed) file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/mana_python_test_plugin.py ${CMAKE_BINARY_DIR}/mana_python_test_plugin.py COPY_ON_ERROR SYMBOLIC) file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/mana_python_plugin_test_numpy.py ${CMAKE_BINARY_DIR}/mana_python_plugin_test_numpy.py COPY_ON_ERROR SYMBOLIC) + file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/mana_python_plugin_test_debugpy.py ${CMAKE_BINARY_DIR}/mana_python_plugin_test_debugpy.py COPY_ON_ERROR SYMBOLIC) endif() add_library(mana-plugin-nng-server SHARED mana_plugin_nng_server.cc) diff --git a/src/internal/mana_lib.hpp b/src/internal/mana_lib.hpp index c4a99d8..4734aa3 100644 --- a/src/internal/mana_lib.hpp +++ b/src/internal/mana_lib.hpp @@ -365,7 +365,7 @@ PluginWrapper load_mana_plugin(const std::string &filename, const std::vector &pluginArgs) { PluginWrapper result; - result.pluginHandle = boost::dll::shared_library(filename); + result.pluginHandle = boost::dll::shared_library(filename, boost::dll::load_mode::rtld_global); if (auto entryPoint = result.pluginHandle.get("mana_get_sink_plugin")) { diff --git a/src/mana_plugin_python.cc b/src/mana_plugin_python.cc index fc6f9ab..f3b5727 100644 --- a/src/mana_plugin_python.cc +++ b/src/mana_plugin_python.cc @@ -57,7 +57,7 @@ MANA_DEFINE_PLUGIN_INIT(init) ctx->usercode = py::module_::import(filename.c_str()); try { - // py::exec(R"(import debugpy; debugpy.listen(5678))"); + py::exec(R"(import debugpy; debugpy.listen(5678))"); // py::exec(R"(import numpy)"); // py::module::import("numpy"); }