Skip to content

Commit adbff52

Browse files
authored
[Plugin] FIX environment init on Windows install (#295)
1 parent 39b5a50 commit adbff52

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

Plugin/src/SofaPython3/PythonEnvironment.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,19 @@ void PythonEnvironment::addPythonModulePathsFromPlugin(const std::string& plugin
401401
Plugin p = elem.second;
402402
if ( p.getModuleName() == pluginName )
403403
{
404-
std::string pluginLibraryPath = elem.first;
404+
// 1. Try to find the plugin directory starting from SOFA root
405+
for ( auto path : sofa::helper::system::PluginRepository.getPaths() )
406+
{
407+
std::string pluginRoot = FileSystem::cleanPath( path + "/" + pluginName );
408+
if ( FileSystem::exists(pluginRoot) && FileSystem::isDirectory(pluginRoot) )
409+
{
410+
addPythonModulePathsFromDirectory(pluginRoot);
411+
return;
412+
}
413+
}
405414

415+
// 2. Try to find the plugin directory starting from the plugin library
416+
std::string pluginLibraryPath = elem.first;
406417
// moduleRoot can be 1 or 2 levels above the library directory
407418
// like "plugin_name/lib/plugin_name.so"
408419
// or "sofa_root/bin/Release/plugin_name.dll"
@@ -413,7 +424,6 @@ void PythonEnvironment::addPythonModulePathsFromPlugin(const std::string& plugin
413424
moduleRoot = FileSystem::getParentDirectory(moduleRoot);
414425
maxDepth++;
415426
}
416-
417427
addPythonModulePathsFromDirectory(moduleRoot);
418428
return;
419429
}

0 commit comments

Comments
 (0)