Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
c7fbef5
Clean-ups before release (#82)
jnbrunet Jan 14, 2021
a3804e9
Improve CMake for v20.12 (#83)
guparan Jan 14, 2021
3ed6f22
[cmake] Fix rpath for MacOS on SOFA relocatable dependencies
jnbrunet Jan 15, 2021
418bbdc
[cmake] Fix rpath for MacOS on SOFA relocatable dependencies (part 2)
jnbrunet Jan 15, 2021
4651242
[examples] Add an advanced timer scene demonstration (#84)
jnbrunet Jan 15, 2021
5a3094e
Update license before the release (#85)
jnbrunet Jan 15, 2021
82c98ce
[CMake] Re-enable building SofaPython3 alongside SofaPython
guparan Jan 15, 2021
b7bdc97
Rename contributors.txt to Authors.txt
hugtalbot Jan 16, 2021
8d4bf9e
Add badges for Doc and License (#89)
hugtalbot Jan 16, 2021
a852361
Update examples 202101 (#86)
hugtalbot Jan 16, 2021
2639e66
Fix institutions (#88)
hugtalbot Jan 16, 2021
963202e
[cmake] Fix compilation issue on MacOS (#90)
jnbrunet Jan 18, 2021
19bf4d8
Added a binding for getLookAtFromOrientation. (#91)
ScheiklP Jan 18, 2021
af21c4a
[cmake] Export SP3 cmake tools for usage in external projects (#94)
jnbrunet Jan 21, 2021
a0a7e56
Wider RPATH for python modules (#95)
guparan Jan 21, 2021
a40e0ed
[CMake] Simplify RPATH (#96)
guparan Jan 21, 2021
727556e
[Examples] Fix scenes before the release
jnbrunet Jan 22, 2021
f63aec7
[Examples] Remove the pygame scene as it is broken without glew bindi…
jnbrunet Jan 22, 2021
530ed03
[CMake] FIX SofaPython3Tools inclusion (#99)
guparan Jan 22, 2021
ae814a4
[cmake] Remove RPATH debug message (#101)
jnbrunet Jan 22, 2021
74a8b73
[SofaBaseTopology] Fix binding entry point (#103)
jnbrunet Jan 26, 2021
b9d1211
[Plugin] Change the initialization order of the Prefab (#105)
jnbrunet Jan 26, 2021
5012482
[examples] Remove warning and dep (#107)
hugtalbot Jan 27, 2021
65d008c
[Plugin] Remove unused files
jnbrunet Jan 21, 2021
289c369
[cmake] Fix missing module path for external projects (#104)
jnbrunet Jan 26, 2021
018e383
Add PluginManager callback for sys.path auto-adds
guparan Feb 4, 2021
50ee47a
[Plugin] Improve PluginManager callback for Windows install
guparan Feb 5, 2021
ad081cd
FIX PythonEnvironment use FileSystem::exists
guparan Feb 5, 2021
e4eba7d
[SofaGui] Use new qt.conf.h for custom qt.conf loading at runtime
guparan Feb 15, 2021
fc7664e
[Plugin] CLEAN PythonEnvironment messages
guparan Feb 19, 2021
b4f78aa
[Bindings] ADD current dir to RPATH
guparan Feb 19, 2021
110c062
[Bindings] ADD debug log for qt.conf loading
guparan Feb 19, 2021
47e698f
[cmake] CMake config was exporting the wrong python version (#116)
jnbrunet Feb 24, 2021
2a32ac6
[CMake] Disable PYTHON_EXECUTABLE reading
guparan Mar 5, 2021
ced247c
[CMake] Disable PYTHON_EXECUTABLE reading (2)
guparan Mar 5, 2021
b8487f8
Quickfix compilation
guparan Mar 5, 2021
d053b99
Merge remote-tracking branch 'sofa-framework/v20.12' into v20.12_changes
guparan Mar 31, 2021
05bd399
[GitHub] Update SOFA minimal binaries to v20.12.02
guparan Mar 31, 2021
31dc482
[SofaGui] FIX qt.conf.h include depends on SofaGuiQt availability
guparan Mar 31, 2021
52f64f7
Merge pull request #131 from guparan/v20.12_changes
guparan Mar 31, 2021
5dcede7
Fix _setattr__ (#145)
May 12, 2021
9246570
Merge remote-tracking branch 'sofa-framework/master' into v21.06
guparan Jul 2, 2021
3e52828
[CMake] Make SP3_BUILD_TEST a dependent option
guparan Jul 2, 2021
ab2f334
Merge branch 'build_alongside_sofapython' into v21.06
guparan Jul 2, 2021
d82303f
[CMake] CLEAN SofaPython3Config.cmake.in
guparan Jul 3, 2021
c90f984
[Plugin] Remove noisy "No python3 dir found" message
guparan Jul 3, 2021
c1d9b92
[GitHub] Use master version of SOFA
guparan Jul 6, 2021
8198a5b
Merge remote-tracking branch 'sofa-framework/master' into v21.06_changes
guparan Aug 26, 2021
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
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ include(SofaPython3Tools)
# OPTIONS
include(CMakeDependentOption)

if (SP3_COMPILED_AS_SOFA_SUBPROJECT)
option(SP3_BUILD_TEST "Compile the automatic tests for SofaPython3, along with the gtest library." ${SOFA_BUILD_TESTS})
else()
option(SP3_BUILD_TEST "Compile the automatic tests for SofaPython3, along with the gtest library." ON)
endif()
# If SOFA_BUILD_TESTS exists and is OFF, then this option will be auto-disabled
cmake_dependent_option(SP3_BUILD_TEST "Compile the automatic tests for SofaPython3, along with the gtest library." ON "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF)
if(SP3_BUILD_TEST)
# TODO: remove this when SOFA's GTest handles threads correctly
find_package(Threads REQUIRED)
Expand Down
43 changes: 37 additions & 6 deletions Plugin/src/SofaPython3/PythonEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ PythonEnvironmentData* PythonEnvironment::getStaticData()
return m_staticdata;
}

std::string PythonEnvironment::pluginLibraryPath = "";

SOFAPYTHON3_API py::module PythonEnvironment::importFromFile(const std::string& module, const std::string& path, py::object* globals)
{
PythonEnvironment::gil lock;
Expand Down Expand Up @@ -238,6 +240,17 @@ void PythonEnvironment::Init()

// python modules are automatically reloaded at each scene loading
//setAutomaticModuleReload( true );

// Initialize pluginLibraryPath by reading PluginManager's map
std::map<std::string, Plugin>& map = PluginManager::getInstance().getPluginMap();
for( const auto& elem : map)
{
Plugin p = elem.second;
if ( p.getModuleName() == sofa_tostring(SOFA_TARGET) )
{
pluginLibraryPath = elem.first;
}
}
}

void PythonEnvironment::executePython(std::function<void()> cb)
Expand Down Expand Up @@ -329,11 +342,6 @@ void PythonEnvironment::addPythonModulePathsForPlugins(const std::string& plugin
added = true;
}
}

if(!added)
{
msg_warning("PythonEnvironment") << "No python dir found in " << pluginsDirectory;
}
}

void PythonEnvironment::addPythonModulePathsForPluginsByName(const std::string& pluginName)
Expand All @@ -352,7 +360,30 @@ void PythonEnvironment::addPythonModulePathsForPluginsByName(const std::string&
return;
}
}
msg_warning("PythonEnvironment") << pluginName << " not found in PluginManager's map.";
msg_info("SofaPython3") << pluginName << " not found in PluginManager's map.";
}

void PythonEnvironment::addPluginManagerCallback()
{
PluginManager::getInstance().addOnPluginLoadedCallback(pluginLibraryPath,
[](const std::string& pluginLibraryPath, const Plugin& plugin) {
// WARNING: loaded plugin must be organized like plugin_name/lib/plugin_name.so
for ( auto path : sofa::helper::system::PluginRepository.getPaths() )
{
std::string pluginRoot = FileSystem::cleanPath( path + "/" + plugin.getModuleName() );
if ( FileSystem::exists(pluginRoot) && FileSystem::isDirectory(pluginRoot) )
{
addPythonModulePathsForPlugins(pluginRoot);
return;
}
}
}
);
}

void PythonEnvironment::removePluginManagerCallback()
{
PluginManager::getInstance().removeOnPluginLoadedCallback(pluginLibraryPath);
}


Expand Down
6 changes: 6 additions & 0 deletions Plugin/src/SofaPython3/PythonEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ class SOFAPYTHON3_API PythonEnvironment
const std::string& path,
pybind11::object* globals = nullptr);

/// Add a new callback in PluginManager to auto-add future
/// loaded plugins to sys.path
static void addPluginManagerCallback();
static void removePluginManagerCallback();

/// Add a path to sys.path, the list of search path for Python modules.
static void addPythonModulePath(const std::string& path);

Expand Down Expand Up @@ -134,6 +139,7 @@ class SOFAPYTHON3_API PythonEnvironment

private:
static PythonEnvironmentData* getStaticData() ;
static std::string pluginLibraryPath;
};

} // namespace sofapython3
Expand Down
2 changes: 2 additions & 0 deletions Plugin/src/SofaPython3/PythonTestExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <sofa/helper/system/PluginManager.h>
using sofa::helper::system::PluginManager;

#include <sofa/helper/logging/Messaging.h>

using sofa::helper::system::SetDirectory;
namespace py = pybind11;

Expand Down
1 change: 1 addition & 0 deletions Plugin/src/SofaPython3/initModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void initExternalModule()
PythonEnvironment::Init();
first = false;
}
PythonEnvironment::addPluginManagerCallback();
}

const char* getModuleName()
Expand Down
4 changes: 4 additions & 0 deletions bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ endif()
# This will set rpaths relative to SP3 plugin library
if(UNIX)
set(CMAKE_INSTALL_RPATH
"$ORIGIN"
"$$ORIGIN"
"$ORIGIN/../lib"
"$$ORIGIN/../lib"
)
if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
list(APPEND CMAKE_INSTALL_RPATH
"@loader_path"
"@executable_path"
"@loader_path/../lib"
"@executable_path/../lib"
)
Expand Down
2 changes: 2 additions & 0 deletions bindings/Modules/tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include <sofa/helper/logging/Messaging.h>
#include <sofa/core/logging/PerComponentLoggingMessageHandler.h>
#include <sofa/helper/logging/MessageDispatcher.h>
using sofa::helper::logging::MessageDispatcher;


/// static build of the test list
Expand Down
12 changes: 2 additions & 10 deletions bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,8 @@ void BindingBase::SetAttr(py::object self, const std::string& s, py::object valu
return;
}

/// We are falling back to dynamically adding the objet into the object dict.
py::dict t = self.attr("__dict__");
if(!t.is_none())
{
t[s.c_str()] = value;
return;
}

/// Well this should never happen unless there is no __dict__
throw py::attribute_error("Unable to set attribute '"+s+"', unknow data type");
// If it's not a data or a link, rely on object implementation of __setattr__
py::module::import("builtins").attr("object").attr("__setattr__")(self, s, value);
}

void BindingBase::SetAttr(Base& self, const std::string& s, py::object value)
Expand Down
1 change: 1 addition & 0 deletions bindings/Sofa/tests/PythonModule_Sofa_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ using std::string;

#include <sofa/helper/logging/Messaging.h>
#include <sofa/core/logging/PerComponentLoggingMessageHandler.h>
#include <sofa/helper/logging/MessageDispatcher.h>
using sofa::helper::logging::MessageDispatcher;
using sofa::helper::logging::MainPerComponentLoggingMessageHandler;

Expand Down
31 changes: 30 additions & 1 deletion bindings/SofaGui/src/SofaPython3/SofaGui/Module_SofaGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@

#include <SofaGui/initSofaGui.h>
#include <sofa/core/init.h>
#include <sofa/helper/logging/Messaging.h>
#include <sofa/helper/Utils.h>
#include <sofa/helper/system/FileSystem.h>
using sofa::helper::system::FileSystem;

#if SOFAGUI_HAVE_SOFAGUIQT
#include <sofa/gui/qt/qt.conf.h>
#endif // SOFAGUI_HAVE_SOFAGUIQT

#include "Binding_BaseGui.h"
#include "Binding_GUIManager.h"
Expand Down Expand Up @@ -55,6 +63,26 @@ PYBIND11_MODULE(Gui, m) {
:members:
)doc";

#if SOFAGUI_HAVE_SOFAGUIQT
std::string sofaPrefixAbsolute = sofa::helper::Utils::getSofaPathPrefix();
std::string inputFilepath = FileSystem::cleanPath(sofaPrefixAbsolute + "/bin/qt.conf");
bool success = sofa::gui::qt::loadQtConfWithCustomPrefix(inputFilepath, sofaPrefixAbsolute);
if(success)
{
msg_info("Sofa.Gui") << "Loaded qt.conf from " << inputFilepath << " customized with Prefix = " << sofaPrefixAbsolute;
}
else
{
msg_warning("Sofa.Gui") << "Failed loading and/or customizing qt.conf from " << inputFilepath;

std::cout << "qt_resource_data:" << std::endl;
for (int i = 0 ; i < qt_resource_data.size() ; ++i) {
std::cout << qt_resource_data[i];
}
std::cout << std::endl;
}
#endif // SOFAGUI_HAVE_SOFAGUIQT

// This is needed to make sure the GuiMain library (libSofaGuiMain.so) is correctly
// linked since the GUIs are statically created during the load of the library.
sofa::gui::initSofaGui();
Expand All @@ -63,4 +91,5 @@ PYBIND11_MODULE(Gui, m) {
moduleAddBaseGui(m);
moduleAddGuiManager(m);
}
}

} // namespace sofapython3
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
* Contact information: contact@sofa-framework.org *
******************************************************************************/

#include <sofa/helper/AdvancedTimer.h>
#include <stack>
using sofa::helper::AdvancedTimer;

#include "Submodule_Timer.h"
#include "Submodule_Timer_doc.h"

#include <sofa/helper/logging/Messaging.h>
#include <sofa/helper/AdvancedTimer.h>
using sofa::helper::AdvancedTimer;

#include <stack>

#include <sofa/helper/logging/Messaging.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ using std::string;

#include <sofa/helper/logging/Messaging.h>
#include <sofa/core/logging/PerComponentLoggingMessageHandler.h>
#include <sofa/helper/logging/MessageDispatcher.h>
using sofa::helper::logging::MessageDispatcher;
using sofa::helper::logging::MainPerComponentLoggingMessageHandler;

Expand Down