Skip to content
Merged
Show file tree
Hide file tree
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
42 changes: 7 additions & 35 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,12 @@ jobs:
brew install ccache ninja boost eigen pybind11
python3 -m pip install numpy

- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
shell: bash

- name: Cache SOFA
uses: actions/cache@v2
id: sofa_cache
with:
path: /opt/sofa
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}

- name: Download SOFA nightly build
if: steps.sofa_cache.outputs.cache-hit != 'true'
run: |
curl --output sofa.zip -L \
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastStableBuild/CI_SCOPE=binaries_minimal/artifact/MacOS/*zip*/MacOS.zip
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries-v20.12/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/MacOS/*zip*/MacOS.zip

- name: Install SOFA nightly build
if: steps.sofa_cache.outputs.cache-hit != 'true'
run: |
sudo unzip sofa.zip -d temp
sudo unzip temp/MacOS/`ls temp/MacOS/` -d temp
Expand Down Expand Up @@ -117,28 +102,13 @@ jobs:
run: |
brew install boost
python3 -m pip install numpy

- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
shell: bash

- name: Cache SOFA
uses: actions/cache@v2
id: sofa_cache
with:
path: /opt/sofa
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}

- name: Download SOFA nightly build
if: steps.sofa_cache.outputs.cache-hit != 'true'
run: |
curl --output sofa.zip -L \
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastStableBuild/CI_SCOPE=binaries_minimal/artifact/MacOS/*zip*/MacOS.zip
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries-v20.12/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/MacOS/*zip*/MacOS.zip

- name: Install SOFA nightly build
if: steps.sofa_cache.outputs.cache-hit != 'true'
run: |
sudo unzip sofa.zip -d temp
sudo unzip temp/MacOS/`ls temp/MacOS/` -d temp
Expand All @@ -155,21 +125,23 @@ jobs:
- name: Binding.Sofa.Tests
if: ${{ always() }}
run: |
export DYLD_LIBRARY_PATH=$GITHUB_WORKSPACE/SofaPython3/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$GITHUB_WORKSPACE/SofaPython3/lib:$SOFA_ROOT/lib:$DYLD_LIBRARY_PATH
export PYTHONPATH=$GITHUB_WORKSPACE/SofaPython3/lib/python3/site-packages:$PYTHONPATH
export SOFA_PLUGIN_PATH=$SOFA_ROOT/plugins
chmod +x SofaPython3/bin/Bindings.Sofa.Tests
./SofaPython3/bin/Bindings.Sofa.Tests
- name: Bindings.SofaRuntime.Tests
if: ${{ always() }}
run: |
export DYLD_LIBRARY_PATH=$GITHUB_WORKSPACE/SofaPython3/lib:$SOFA_ROOT/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$GITHUB_WORKSPACE/SofaPython3/lib:$SOFA_ROOT/lib:$DYLD_LIBRARY_PATH
export PYTHONPATH=$GITHUB_WORKSPACE/SofaPython3/lib/python3/site-packages:$PYTHONPATH
export SOFA_PLUGIN_PATH=$SOFA_ROOT/plugins
chmod +x SofaPython3/bin/Bindings.SofaRuntime.Tests
./SofaPython3/bin/Bindings.SofaRuntime.Tests
- name: Bindings.SofaTypes.Tests
if: ${{ always() }}
run: |
export DYLD_LIBRARY_PATH=$GITHUB_WORKSPACE/SofaPython3/lib:$SOFA_ROOT/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$GITHUB_WORKSPACE/SofaPython3/lib:$SOFA_ROOT/lib:$DYLD_LIBRARY_PATH
export PYTHONPATH=$GITHUB_WORKSPACE/SofaPython3/lib/python3/site-packages:$PYTHONPATH
chmod +x SofaPython3/bin/Bindings.SofaTypes.Tests
./SofaPython3/bin/Bindings.SofaTypes.Tests
Expand Down
42 changes: 7 additions & 35 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,12 @@ jobs:
- name: Install pybind11
run: cd /tmp/pybind11 && sudo make install

- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
shell: bash

- name: Cache SOFA
uses: actions/cache@v2
id: sofa_cache
with:
path: /opt/sofa
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}

- name: Download SOFA nightly build
if: steps.sofa_cache.outputs.cache-hit != 'true'
run: |
curl --output sofa.zip -L \
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastStableBuild/CI_SCOPE=binaries_minimal/artifact/Linux/*zip*/Linux.zip
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries-v20.12/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/Linux/*zip*/Linux.zip

- name: Install SOFA nightly build
if: steps.sofa_cache.outputs.cache-hit != 'true'
run: |
sudo unzip sofa.zip -d temp
sudo unzip temp/Linux/`ls temp/Linux/` -d temp
Expand Down Expand Up @@ -134,33 +119,18 @@ jobs:
sudo apt install -qq libboost-all-dev
python3 -m pip install numpy

- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
shell: bash

- name: Cache SOFA
uses: actions/cache@v2
id: sofa_cache
with:
path: /opt/sofa
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}

- name: Download SOFA nightly build
if: steps.sofa_cache.outputs.cache-hit != 'true'
run: |
curl --output sofa.zip -L \
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastStableBuild/CI_SCOPE=binaries_minimal/artifact/Linux/*zip*/Linux.zip
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries-v20.12/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/Linux/*zip*/Linux.zip

- name: Install SOFA nightly build
if: steps.sofa_cache.outputs.cache-hit != 'true'
run: |
sudo unzip sofa.zip -d temp
sudo unzip temp/Linux/`ls temp/Linux/` -d temp
sudo rm -rf temp/Linux
mv temp/`ls temp` $SOFA_ROOT
rm -rf temp
sudo mv temp/`ls temp` $SOFA_ROOT
sudo rm -rf temp

- name: Install SP3
uses: actions/download-artifact@v2
Expand All @@ -173,21 +143,23 @@ jobs:
run: |
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/SofaPython3/lib:$SOFA_ROOT/lib:$LD_LIBRARY_PATH
export PYTHONPATH=$GITHUB_WORKSPACE/SofaPython3/lib/python3/site-packages:$PYTHONPATH
export SOFA_PLUGIN_PATH=$SOFA_ROOT/plugins/SofaSparseSolver/lib
export SOFA_PLUGIN_PATH=$SOFA_ROOT/plugins
chmod +x SofaPython3/bin/Bindings.Sofa.Tests
./SofaPython3/bin/Bindings.Sofa.Tests
- name: Bindings.SofaRuntime.Tests
if: ${{ always() }}
run: |
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/SofaPython3/lib:$SOFA_ROOT/lib:$LD_LIBRARY_PATH
export PYTHONPATH=$GITHUB_WORKSPACE/SofaPython3/lib/python3/site-packages:$PYTHONPATH
export SOFA_PLUGIN_PATH=$SOFA_ROOT/plugins
chmod +x SofaPython3/bin/Bindings.SofaRuntime.Tests
./SofaPython3/bin/Bindings.SofaRuntime.Tests
- name: Bindings.SofaTypes.Tests
if: ${{ always() }}
run: |
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/SofaPython3/lib:$SOFA_ROOT/lib:$LD_LIBRARY_PATH
export PYTHONPATH=$GITHUB_WORKSPACE/SofaPython3/lib/python3/site-packages:$PYTHONPATH
export SOFA_PLUGIN_PATH=$SOFA_ROOT/plugins
chmod +x SofaPython3/bin/Bindings.SofaTypes.Tests
./SofaPython3/bin/Bindings.SofaTypes.Tests

6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ if (APPLE)
endif()

find_package(SofaFramework REQUIRED)

if (NOT SP3_COMPILED_AS_SUBPROJECT)
get_filename_component(SOFA_ROOT_DIR "${SofaFramework_DIR}/../../.." ABSOLUTE)
message(STATUS "SOFA Framework:\n\tVersion: ${SofaFramework_VERSION}\n\tLocation: ${SOFA_ROOT_DIR}")
endif()

sofa_add_plugin(Plugin SofaPython3 ON)
sofa_add_plugin(bindings SofaPython3_Bindings ON)
sofa_add_plugin(examples SofaPython3_Examples ON)
Expand Down
1 change: 0 additions & 1 deletion Plugin/src/SofaPython3/PythonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ void PythonTest::SetUpTestCase ()
// The following will be executed once before the first python test file
PythonEnvironment::Init();
test_gil = new PythonEnvironment::gil;
simpleapi::importPlugin("SofaComponentAll");
py::module::import("SofaRuntime");
py::module::import("Sofa");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ along with sofaqtquick. If not, see <http://www.gnu.org/licenses/>.
#include <iostream>
#include <pybind11/embed.h>

#include <sofa/core/init.h>
#include <sofa/core/ObjectFactory.h>
using sofa::core::objectmodel::BaseObjectDescription;
using sofa::core::ObjectFactory;
Expand Down Expand Up @@ -59,6 +60,9 @@ class FCreator

PYBIND11_MODULE(Components, m)
{
// These are needed to force the dynamic loading of module dependencies (found in CMakeLists.txt)
sofa::core::init();

py::class_<FCreator> mm(m, "Creator");
mm.def("__call__", [](FCreator& s, const py::args& args, const py::kwargs& kwargs){
if(args.size() != 1)
Expand Down
8 changes: 1 addition & 7 deletions bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,7 @@ void setParent(BaseData* self, BaseData* parent)

bool hasParent(BaseData *self)
{
return !self->getLinkPath().empty();
}

py::str getAsACreateObjectParameter(BaseData *self)
{
return self->getLinkPath();
return (self->getParent() != nullptr);
}

void updateIfDirty(BaseData* self)
Expand Down Expand Up @@ -207,7 +202,6 @@ void moduleAddBaseData(py::module& m)
data.def("setPersistent", &BaseData::setPersistent, sofapython3::doc::baseData::setPersistent);
data.def("setParent", setParent, sofapython3::doc::baseData::setParent);
data.def("hasParent", hasParent, sofapython3::doc::baseData::hasParent);
data.def("getAsACreateObjectParameter", getAsACreateObjectParameter, sofapython3::doc::baseData::getAsACreateObjectParameter);
data.def("read", &BaseData::read, sofapython3::doc::baseData::read);
data.def("updateIfDirty", updateIfDirty, sofapython3::doc::baseData::updateIfDirty);
data.def("isDirty", isDirty, sofapython3::doc::baseData::isDirty);
Expand Down
3 changes: 2 additions & 1 deletion bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ endif()

find_package(SofaFramework REQUIRED)
find_package(SofaBase REQUIRED)
find_package(SofaCommon REQUIRED)
find_package(SofaSimulation REQUIRED)

SP3_add_python_module(
Expand All @@ -80,5 +81,5 @@ SP3_add_python_module(
MODULE_NAME Core
SOURCES ${SOURCE_FILES}
HEADERS ${HEADER_FILES}
DEPENDS SofaCore SofaSimulationCore SofaSimulationGraph SofaBaseVisual SofaPython3::Plugin
DEPENDS SofaBase SofaCore SofaSimulation SofaCommon SofaPython3::Plugin
)
16 changes: 10 additions & 6 deletions bindings/Sofa/src/SofaPython3/Sofa/Core/Submodule_Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ along with sofaqtquick. If not, see <http://www.gnu.org/licenses/>.
#include <sofa/helper/logging/Messaging.h>
using sofa::helper::logging::Message;

#include <sofa/core/objectmodel/BaseNode.h>
#include <sofa/core/objectmodel/BaseContext.h>
#include <sofa/core/behavior/BaseForceField.h>
#include <sofa/core/objectmodel/Context.h>

#include "Binding_Base.h"
#include "Binding_BaseContext.h"
#include "Binding_BaseObject.h"
Expand All @@ -58,14 +53,23 @@ using sofa::helper::logging::Message;

#include "Submodule_Core.h"


#include <sofa/core/init.h>
#include <SofaBase/initSofaBase.h>
#include <SofaCommon/initSofaCommon.h>
#include <SofaSimulation/initSofaSimulation.h>

namespace sofapython3
{

/// The first parameter must be named the same as the module file to load.
PYBIND11_MODULE(Core, core)
{
// These are needed to force the dynamic loading of module dependencies (found in CMakeLists.txt)
sofa::core::init();
sofa::component::initSofaBase();
sofa::component::initSofaCommon();
sofa::initSofaSimulation();

core.doc() = R"doc(
Scene components
-----------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ along with sofaqtquick. If not, see <http://www.gnu.org/licenses/>.
- thierry.gaugry@inria.fr
********************************************************************/


#include <sofa/core/init.h>
#include <sofa/helper/logging/Messaging.h>
#include <SofaPython3/PythonEnvironment.h>
#include <sofa/core/objectmodel/Base.h>
#include "System/Submodule_System.h"
#include "Submodule_Helper.h"
#include "Binding_MessageHandler.h"
#include "Binding_Vector.h"

Expand Down Expand Up @@ -111,6 +110,9 @@ static void parse_emitter_message_then(py::args args, const Action& action) {
/// The first parameter must be named the same as the module file to load.
PYBIND11_MODULE(Helper, helper)
{
// These are needed to force the dynamic loading of module dependencies (found in CMakeLists.txt)
sofa::core::init();

helper.doc() = R"doc(
Utility functions
-----------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,24 @@ using sofa::simulation::Simulation;
#include <sofa/core/visual/VisualParams.h>
#include "Submodule_Simulation_doc.h"

#include <sofa/core/init.h>
#include <sofa/simulation/init.h>
#include <SofaSimulationGraph/init.h>
#include <SofaBaseVisual/initBaseVisual.h>

namespace py = pybind11;

namespace sofapython3
{

PYBIND11_MODULE(Simulation, simulation)
{
// These are needed to force the dynamic loading of module dependencies (found in CMakeLists.txt)
sofa::core::init();
sofa::simulation::core::init();
sofa::simulation::graph::init();
sofa::component::initBaseVisual();

if(!sofa::simulation::getSimulation())
sofa::simulation::setSimulation(new DAGSimulation());

Expand Down
5 changes: 5 additions & 0 deletions bindings/Sofa/src/SofaPython3/Sofa/Types/Submodule_Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ along with sofaqtquick. If not, see <http://www.gnu.org/licenses/>.
- thierry.gaugry@inria.fr
********************************************************************/

#include <sofa/core/init.h>

#include "Submodule_Types.h"
#include "Binding_BoundingBox.h"

Expand All @@ -33,6 +35,9 @@ namespace sofapython3
/// The first parameter must be named the same as the module file to load.
PYBIND11_MODULE(Types, types)
{
// These are needed to force the dynamic loading of module dependencies (found in CMakeLists.txt)
sofa::core::init();

types.doc() = R"doc(
Default data types
-------------------------------
Expand Down
1 change: 0 additions & 1 deletion bindings/Sofa/tests/Components/Components.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
class Test(unittest.TestCase):
def test_component_creation(self):
root = Sofa.Core.Node("rootNode")
root.addObject("RequiredPlugin", name="SofaComponentAll")

c = Sofa.Components.MechanicalObject(root, name="dofs")
self.assertTrue(c.name.value == "dofs")
Loading