Skip to content

Commit 762ce2d

Browse files
authored
Merge branch 'master' into 202507_add_example_contactforce
2 parents 90c487d + 4cb31d0 commit 762ce2d

39 files changed

Lines changed: 1073 additions & 55 deletions

.github/workflows/build_sphinx_documentation.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ jobs:
6161
mkdir build/
6262
sphinx-build -b html -a -E source/ build/
6363
64+
- name: Fix JS file
65+
continue-on-error: true
66+
run: |
67+
# Define the file path
68+
FILE="docs/sphinx/build/_static/js/theme.js"
69+
70+
# Check if the file exists
71+
if [[ -f "$FILE" ]]; then
72+
# Use sed to perform the replacement in-place
73+
sed -i 's/\.wy-menu-vertical ul/\.wy-menu-vertical li > ul/g' "$FILE"
74+
echo "Replacement done in $FILE"
75+
else
76+
echo "File not found: $FILE"
77+
exit 1
78+
fi
79+
6480
- name: Zip Documentation
6581
run: |
6682
# Create a zip file of the documentation

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,15 @@ jobs:
224224
binary_status=$([ '${{ steps.gen-artifact.outcome }}' == 'success' ] && \
225225
[ '${{ steps.install-artifact.outcome }}' == 'success' ] && \
226226
echo 'true' || echo 'false')
227+
228+
os=$(echo "${{ matrix.os }}" | awk -F- '{ print $1 }')
227229
228230
229231
curl -X POST -H "X-API-KEY: $DASH_AUTH" -H "Content-Type: application/json" -d \
230232
"{\"id\":\"$(echo "${{ github.repository }}" | awk -F/ '{ print $2 }')\",\
231233
\"github_ref\":\"${{ github.sha }}\",\
232234
\"url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\",\
235+
\"os\":\"$os\",\
233236
\"build\":$build_status,\
234237
\"tests\":$test_status,\
235238
\"binary\":$binary_status}"\

.readthedocs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ build:
1313
os: "ubuntu-22.04"
1414
commands:
1515
- mkdir --parents $READTHEDOCS_OUTPUT/html/
16-
- wget https://github.com/sofa-framework/SofaPython3/releases/download/v24.12.00-doc-generation/SofaPython3_v24.12.00_docs.zip
16+
- wget https://github.com/sofa-framework/SofaPython3/releases/download/v25.06.00-doc-generation/SofaPython3_v25.06.00_docs.zip
1717
- mkdir docUnzipped/
18-
- unzip SofaPython3_v24.12.00_docs.zip -d docUnzipped/
19-
- cp --recursive docUnzipped/SofaPython3_v24.12.00_docs/* $READTHEDOCS_OUTPUT/html/
18+
- unzip SofaPython3_v25.06.00_docs.zip -d docUnzipped/
19+
- cp --recursive docUnzipped/SofaPython3_v25.06.00_docs/* $READTHEDOCS_OUTPUT/html/
2020
- ls $READTHEDOCS_OUTPUT/html/

SofaPython3Config.cmake.in

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
99
include(SofaPython3Tools)
1010

1111
# Find Python3
12-
if(NOT Python_FOUND)
13-
find_package(Python @PythonMAJMIN@ EXACT QUIET REQUIRED COMPONENTS Interpreter Development)
12+
if(NOT TARGET Python::Python)
13+
if(CMAKE_VERSION VERSION_LESS "3.24.0")
14+
find_package(Python @PythonMAJMIN@ EXACT QUIET REQUIRED COMPONENTS Interpreter Development)
15+
else()
16+
find_package(Python @PythonMAJMIN@ EXACT QUIET REQUIRED COMPONENTS Interpreter Development GLOBAL)
17+
endif()
1418
endif()
1519

1620
# Find pybind11
17-
if(NOT pybind11_FOUND)
21+
if(NOT TARGET pybind11)
1822
# Save PYTHON_* vars
1923
set(PYTHON_VERSION_RESET "${PYTHON_VERSION}")
2024
set(PYTHON_EXECUTABLE_RESET "${PYTHON_EXECUTABLE}")
@@ -40,7 +44,11 @@ if(NOT pybind11_FOUND)
4044
set(PYTHON_INCLUDE_DIR "${Python_INCLUDE_DIRS}" CACHE INTERNAL "" FORCE)
4145
endif()
4246

43-
find_package(pybind11 @pybind11_VERSION@ QUIET REQUIRED CONFIG)
47+
if(CMAKE_VERSION VERSION_LESS "3.24.0")
48+
find_package(pybind11 @pybind11_VERSION@ QUIET REQUIRED CONFIG)
49+
else()
50+
find_package(pybind11 @pybind11_VERSION@ QUIET REQUIRED CONFIG GLOBAL)
51+
endif()
4452

4553
# Reset PYTHON_* vars
4654
set(PYTHON_VERSION "${PYTHON_VERSION_RESET}" CACHE STRING "" FORCE)

bindings/BindingsConfig.cmake.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55

66
set(SP3_WITH_SOFAEXPORTER @SP3_WITH_SOFAEXPORTER@)
77

8-
find_package(SofaPython3 QUIET REQUIRED COMPONENTS
8+
find_package(Sofa.Config QUIET REQUIRED)
9+
10+
sofa_find_package(SofaPython3 QUIET REQUIRED COMPONENTS
911
Bindings.Modules
1012
Bindings.Sofa
1113
Bindings.SofaGui
1214
Bindings.SofaRuntime
1315
Bindings.SofaTypes
1416
)
1517
if(SP3_WITH_SOFAEXPORTER)
16-
find_package(SofaPython3 QUIET REQUIRED COMPONENTS Bindings.SofaExporter)
18+
sofa_find_package(SofaPython3 QUIET REQUIRED COMPONENTS Bindings.SofaExporter)
1719
endif()
1820

1921
# If we are importing this config file and the target is not yet there this is indicating that

bindings/Modules/Bindings.ModulesConfig.cmake.in

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
@PACKAGE_GUARD@
44
@PACKAGE_INIT@
55

6-
find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin Bindings.Sofa)
6+
find_package(Sofa.Config QUIET REQUIRED)
7+
sofa_find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin Bindings.Sofa)
78

89
# Required by Bindings.Modules.SofaBaseTopology
9-
find_package(Sofa.Component.Topology.Container.Grid QUIET REQUIRED)
10+
sofa_find_package(Sofa.Component.Topology.Container.Grid QUIET REQUIRED)
1011

1112
# Required by Bindings.Modules.SofaDeformable
12-
find_package(Sofa.Component.SolidMechanics.Spring QUIET REQUIRED)
13+
sofa_find_package(Sofa.Component.SolidMechanics.Spring QUIET REQUIRED)
1314

1415
# Required by Bindings.Modules.SofaLinearSolver
15-
find_package(Sofa.Component.LinearSolver.Iterative QUIET REQUIRED)
16+
sofa_find_package(Sofa.Component.LinearSolver.Iterative QUIET REQUIRED)
1617

1718
# If we are importing this config file and the target is not yet there this is indicating that
1819
# target is an imported one. So we include it

bindings/Sofa/Bindings.SofaConfig.cmake.in

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@
33
@PACKAGE_GUARD@
44
@PACKAGE_INIT@
55

6-
find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin)
6+
find_package(Sofa.Config QUIET REQUIRED)
7+
8+
sofa_find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin)
79

810
# Required by Bindings.Sofa.Helper, Bindings.Sofa.Types
9-
find_package(Sofa.Core QUIET REQUIRED)
11+
sofa_find_package(Sofa.Core QUIET REQUIRED)
1012

1113
# Required by Bindings.Sofa.Core
12-
find_package(Sofa.Simulation.Core QUIET REQUIRED)
14+
sofa_find_package(Sofa.Simulation.Core QUIET REQUIRED)
1315

1416
# Required by Bindings.Sofa.Core
15-
find_package(Sofa.Component.Visual QUIET REQUIRED)
16-
find_package(Sofa.Component.Collision.Response.Contact QUIET REQUIRED)
17-
find_package(Sofa.SimpleApi QUIET REQUIRED)
17+
sofa_find_package(Sofa.Component.Visual QUIET REQUIRED)
18+
sofa_find_package(Sofa.Component.Collision.Response.Contact QUIET REQUIRED)
19+
sofa_find_package(Sofa.SimpleApi QUIET REQUIRED)
1820

1921
# Required by Bindings.Sofa.Simulation
20-
find_package(Sofa.Simulation.Graph QUIET REQUIRED)
22+
sofa_find_package(Sofa.Simulation.Graph QUIET REQUIRED)
2123

2224
# If we are importing this config file and the target is not yet there this is indicating that
2325
# target is an imported one. So we include it

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,13 @@ std::unique_ptr<DataContainerContext> writeableArray(BaseData* self)
112112
return nullptr;
113113
}
114114

115-
void __setattr__(py::object self, const std::string& s, py::object value)
115+
py::object getValue(py::object self)
116+
{
117+
return PythonFactory::valueToPython_ro(py::cast<BaseData*>(self));
118+
}
119+
120+
void setValue(py::object self, py::object value)
116121
{
117-
SOFA_UNUSED(s);
118122
BaseData* selfdata = py::cast<BaseData*>(self);
119123

120124
if(py::isinstance<DataContainer>(value))
@@ -132,14 +136,20 @@ void __setattr__(py::object self, const std::string& s, py::object value)
132136
BindingBase::SetAttr(py::cast(selfdata->getOwner()),selfdata->getName(),value);
133137
}
134138

139+
void __setattr__(py::object self, const std::string& s, py::object value)
140+
{
141+
SOFA_UNUSED(s);
142+
setValue(self, value);
143+
}
144+
135145
py::object __getattr__(py::object self, const std::string& s)
136146
{
137147
/// If this is data.value we returns the content value of the data field converted into
138148
/// a python object that is easy to manipulate. The conversion is done with the toPython
139149
/// function.
140150
if(s == "value")
141151
{
142-
return PythonFactory::valueToPython_ro(py::cast<BaseData*>(self));
152+
return getValue(self);
143153
}
144154

145155
if(s == "linkpath")
@@ -150,6 +160,8 @@ py::object __getattr__(py::object self, const std::string& s)
150160
throw py::attribute_error("There is no attribute '"+s+"'");
151161
}
152162

163+
164+
153165
void setParent(BaseData* self, BaseData* parent)
154166
{
155167
self->setParent(parent);
@@ -211,6 +223,8 @@ void moduleAddBaseData(py::module& m)
211223
data.def("getName", [](BaseData& b){ return b.getName(); }, sofapython3::doc::baseData::getName);
212224
data.def("setName", [](BaseData& b, const std::string& s){ b.setName(s); }, sofapython3::doc::baseData::setName);
213225
data.def("getCounter", [](BaseData& self) { return self.getCounter(); }, sofapython3::doc::baseData::getCounter);
226+
data.def("setValue", setValue);
227+
data.def("getValue", getValue);
214228
data.def("getHelp", &BaseData::getHelp, sofapython3::doc::baseData::getHelp);
215229
data.def("unset", [](BaseData& b){ b.unset(); }, sofapython3::doc::baseData::unset);
216230
data.def("getOwner", &getOwner, sofapython3::doc::baseData::getOwner);

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ using sofa::core::objectmodel::BaseLink;
2424
#include <sofa/core/objectmodel/BaseObject.h>
2525
using sofa::core::objectmodel::BaseObject;
2626

27+
#include <SofaPython3/PythonFactory.h>
28+
2729
#include <SofaPython3/Sofa/Core/Binding_LinkPath.h>
2830
#include <SofaPython3/Sofa/Core/Binding_LinkPath_doc.h>
2931

@@ -79,6 +81,13 @@ void moduleAddLinkPath(py::module& m)
7981
py::class_<LinkPath> link(m, "LinkPath", sofapython3::doc::linkpath::linkpath);
8082
link.def("__str__", &__str__);
8183
link.def("__repr__", &__repr__);
84+
link.def("target", [](const LinkPath& entry) -> py::object{
85+
if(entry.targetData != nullptr)
86+
return PythonFactory::toPython(entry.targetData);
87+
else if(entry.targetBase.get() != nullptr)
88+
return PythonFactory::toPython(entry.targetBase.get());
89+
return py::none();
90+
});
8291
}
8392

8493
}/// namespace sofapython3

0 commit comments

Comments
 (0)