Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Plugin/src/SofaPython3/PythonEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,19 @@ void PythonEnvironment::addPythonModulePathsFromPlugin(const std::string& plugin
Plugin p = elem.second;
if ( p.getModuleName() == pluginName )
{
std::string pluginLibraryPath = elem.first;
// 1. Try to find the plugin directory starting from SOFA root
for ( auto path : sofa::helper::system::PluginRepository.getPaths() )
{
std::string pluginRoot = FileSystem::cleanPath( path + "/" + pluginName );
if ( FileSystem::exists(pluginRoot) && FileSystem::isDirectory(pluginRoot) )
{
addPythonModulePathsFromDirectory(pluginRoot);
return;
}
}

// 2. Try to find the plugin directory starting from the plugin library
std::string pluginLibraryPath = elem.first;
// moduleRoot can be 1 or 2 levels above the library directory
// like "plugin_name/lib/plugin_name.so"
// or "sofa_root/bin/Release/plugin_name.dll"
Expand All @@ -413,7 +424,6 @@ void PythonEnvironment::addPythonModulePathsFromPlugin(const std::string& plugin
moduleRoot = FileSystem::getParentDirectory(moduleRoot);
maxDepth++;
}

addPythonModulePathsFromDirectory(moduleRoot);
return;
}
Expand Down