use rtld_global when loading plugins - fixes debugpy/numpy import issue

This commit is contained in:
Florian Lüke 2025-01-01 21:25:57 +01:00
parent 35dc005e0a
commit 9327e4d4e9
3 changed files with 3 additions and 2 deletions

View file

@ -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)

View file

@ -365,7 +365,7 @@ PluginWrapper load_mana_plugin(const std::string &filename,
const std::vector<std::string> &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_sink_plugin_t()>("mana_get_sink_plugin"))
{

View file

@ -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");
}