Skip to content

Commit 33a34c1

Browse files
committed
Merge remote-tracking branch 'upstream/master' into pr-add-createobject-behavior
2 parents 9c1d0c9 + 204aac4 commit 33a34c1

File tree

13 files changed

+55
-28
lines changed

13 files changed

+55
-28
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ SP3_add_python_package(
183183
Sofa/constants
184184
)
185185

186+
## This is only to warn users that splib is now relocated in its own repository
187+
# it just contains a __init__.py rising an exception indicating to where to find the plugin.
188+
# If splib is available, then splib/__init__.py will be overriden by the one from the real splib.
189+
SP3_add_python_package(
190+
SOURCE_DIRECTORY
191+
${CMAKE_CURRENT_SOURCE_DIR}/splib
192+
TARGET_DIRECTORY
193+
splib
194+
)
195+
186196
sofa_create_package(
187197
PACKAGE_NAME ${PROJECT_NAME}
188198
PACKAGE_VERSION ${PROJECT_VERSION}

Plugin/src/SofaPython3/PythonEnvironment.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@
3030
#pragma push_macro("slots")
3131
#undef slots
3232
/// This should come from python3.
33-
#include <Python.h>
33+
#if defined(WIN32) && defined(_DEBUG)
34+
#undef _DEBUG // Prevent linking debug build of python
35+
#include <Python.h>
36+
#define _DEBUG 1
37+
#else
38+
#include <Python.h>
39+
#endif
3440
#pragma pop_macro("slots")
3541

3642
#include <sofa/simulation/SceneLoaderFactory.h>

Plugin/src/SofaPython3/PythonFactory.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,16 @@ void PythonFactory::fromPython(BaseData* d, const py::object& o)
346346
// To smooth the deprecation process we are still allowing it ...but prints a warning.
347347
if( !nfo.Text() && py::isinstance<py::str>(o) )
348348
{
349-
msg_deprecated(d->getOwner()) << "Data field '" << d->getName() << "' is initialized from a string."
350-
<< " This behavior was allowed with SofaPython2 but have very poor performance so it is now "
351-
<< "deprecated with SofaPython3. Please fix your scene (as this behavior will be removed)."
352-
<< PythonEnvironment::getPythonCallingPointString();
353-
d->read( py::cast<std::string>(o) );
349+
std::string s = py::cast<std::string>(o);
350+
if(s.size() > 1 && s[0] != '@')
351+
{
352+
msg_deprecated(d->getOwner()) << "Data field '" << d->getName() << "' is initialized from a string." << msgendl
353+
<< " This behavior was allowed with SofaPython2 but have very poor performance so it is now "
354+
<< "deprecated with SofaPython3. Please fix your scene (as this behavior will be removed)." << msgendl
355+
<< msgendl
356+
<< PythonEnvironment::getPythonCallingPointString();
357+
}
358+
d->read( s );
354359
return;
355360
}
356361

bindings/Modules/tests/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ foreach(dir_binding ${DIR_BINDING_LIST})
3434
endif()
3535
if (_isMultiConfig) # MSVC
3636
foreach(config_type ${CMAKE_CONFIGURATION_TYPES})
37-
SP3_configure_directory(${CMAKE_CURRENT_SOURCE_DIR}/${dir_binding} ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${config_type}/${dir_binding})
38-
install(DIRECTORY ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${config_type}/${dir_binding} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY})
37+
SP3_configure_directory(${CMAKE_CURRENT_SOURCE_DIR}/${dir_binding} ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${config_type}/${PROJECT_NAME}.d/${dir_binding})
38+
install(DIRECTORY ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${config_type}/${PROJECT_NAME}.d/${dir_binding} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.d)
3939
endforeach()
4040
else()
41-
SP3_configure_directory(${CMAKE_CURRENT_SOURCE_DIR}/${dir_binding} ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${dir_binding})
42-
install(DIRECTORY ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${dir_binding} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY})
41+
SP3_configure_directory(${CMAKE_CURRENT_SOURCE_DIR}/${dir_binding} ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.d/${dir_binding})
42+
install(DIRECTORY ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.d/${dir_binding} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.d)
4343
endif()
4444
endforeach()
4545

bindings/Modules/tests/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ static struct Tests : public sofapython3::PythonTestExtractor
3838
MessageDispatcher::addHandler(&MainPerComponentLoggingMessageHandler::getInstance()) ;
3939

4040
const std::string executable_directory = sofa::helper::Utils::getExecutableDirectory();
41-
addTestDirectory(executable_directory+"/SofaBaseTopology", "SofaBaseTopology_");
42-
addTestDirectory(executable_directory+"/SofaDeformable", "SofaDeformable_");
41+
addTestDirectory(executable_directory+"/Bindings.Modules.Tests.d/SofaBaseTopology", "SofaBaseTopology_");
42+
addTestDirectory(executable_directory+"/Bindings.Modules.Tests.d/SofaDeformable", "SofaDeformable_");
4343
}
4444
} python_tests;
4545

bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Node.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ py::object getObject(Node &n, const std::string &name, const py::kwargs& kwargs)
172172
if(kwargs.size()!=0)
173173
{
174174
msg_deprecated(&n) << "Calling the method getObject() with extra arguments is not supported anymore."
175-
<< "To remove this message please refer to the documentation of the getObject method";
175+
<< "To remove this message please refer to the documentation of the getObject method"
176+
<< msgendl
177+
<< PythonEnvironment::getPythonCallingPointString() ;
176178
}
177179

178180
BaseObject *object = n.getObject(name);

bindings/Sofa/tests/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
6060
foreach(dir_binding ${DIR_BINDING_LIST})
6161
if (_isMultiConfig) # MSVC
6262
foreach(config_type ${CMAKE_CONFIGURATION_TYPES})
63-
SP3_configure_directory(${CMAKE_CURRENT_SOURCE_DIR}/${dir_binding} ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${config_type}/${dir_binding})
64-
install(DIRECTORY ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${config_type}/${dir_binding} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY})
63+
SP3_configure_directory(${CMAKE_CURRENT_SOURCE_DIR}/${dir_binding} ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${config_type}/${PROJECT_NAME}.d/${dir_binding})
64+
install(DIRECTORY ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${config_type}/${PROJECT_NAME}.d/${dir_binding} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.d)
6565
endforeach()
6666
else()
67-
SP3_configure_directory(${CMAKE_CURRENT_SOURCE_DIR}/${dir_binding} ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${dir_binding})
68-
install(DIRECTORY ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${dir_binding} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY})
67+
SP3_configure_directory(${CMAKE_CURRENT_SOURCE_DIR}/${dir_binding} ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.d/${dir_binding})
68+
install(DIRECTORY ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.d/${dir_binding} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.d)
6969
endif()
7070
endforeach()
7171

bindings/Sofa/tests/PythonModule_Sofa_test.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ static struct PythonModule_Sofa_tests : public PythonTestExtractor
5454
PythonModule_Sofa_tests()
5555
{
5656
const std::string executable_directory = sofa::helper::Utils::getExecutableDirectory();
57-
addTestDirectory(executable_directory+"/Core", "Sofa_Core_");
58-
addTestDirectory(executable_directory+"/Helper", "Sofa_Helper_");
59-
addTestDirectory(executable_directory+"/Simulation", "Sofa_Simulation_");
60-
addTestDirectory(executable_directory+"/Types", "Sofa_Types_");
61-
addTestDirectory(executable_directory+"/Components", "Sofa_Components_");
57+
addTestDirectory(executable_directory+"/Bindings.Sofa.Tests.d/Core", "Sofa_Core_");
58+
addTestDirectory(executable_directory+"/Bindings.Sofa.Tests.d/Helper", "Sofa_Helper_");
59+
addTestDirectory(executable_directory+"/Bindings.Sofa.Tests.d/Simulation", "Sofa_Simulation_");
60+
addTestDirectory(executable_directory+"/Bindings.Sofa.Tests.d/Types", "Sofa_Types_");
61+
addTestDirectory(executable_directory+"/Bindings.Sofa.Tests.d/Components", "Sofa_Components_");
6262
}
6363
} python_tests;
6464

bindings/SofaRuntime/tests/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ sofa_auto_set_target_rpath(
2525

2626
add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})
2727

28-
SP3_configure_directory(${CMAKE_CURRENT_SOURCE_DIR}/SofaRuntime ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/SofaRuntime)
29-
install(DIRECTORY ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/SofaRuntime DESTINATION ${RUNTIME_OUTPUT_DIRECTORY})
28+
SP3_configure_directory(${CMAKE_CURRENT_SOURCE_DIR}/SofaRuntime ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.d/SofaRuntime)
29+
install(DIRECTORY ${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.d/SofaRuntime DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.d)
3030

3131
install(
3232
TARGETS ${PROJECT_NAME}

bindings/SofaRuntime/tests/PythonModule_SofaRuntime_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static struct PythonModule_Sofa_tests : public PythonTestExtractor
5454
PythonModule_Sofa_tests()
5555
{
5656
const std::string executable_directory = sofa::helper::Utils::getExecutableDirectory();
57-
addTestDirectory(executable_directory+"/SofaRuntime", "SofaRuntime_");
57+
addTestDirectory(executable_directory+"/Bindings.SofaRuntime.Tests.d/SofaRuntime", "SofaRuntime_");
5858
}
5959
} python_tests;
6060

0 commit comments

Comments
 (0)