Skip to content

Conversation

@RyanPaulMcKenna
Copy link

Title: Fix Python::Python missing when building bindings via SP3_add_python_module (CMake FindPython Development.Embed)

Summary
This PR fixes a CMake configuration/build failure seen when downstream plugins (e.g. Cosserat) use SofaPython3’s SP3_add_python_module() helper and it internally calls python_add_library().

Problem
On newer CMake/FindPython (observed with CMake 3.28 + Python 3.12 on Ubuntu), python_add_library() requires the imported target Python::Python to be defined. In some configurations, Python::Python is not created because find_package(Python … COMPONENTS Development.Embed …) was never requested, leading to:

Python_ADD_LIBRARY: dependent target 'Python::Python' is not defined.
Did you miss to request COMPONENT 'Development.Embed'?

This then causes a cascade (e.g. missing CosseratBindings alias target).

Solution
Make SP3_add_python_module() self-contained by ensuring Python::Python exists before calling python_add_library():

  • If Python::Python is not already defined, explicitly call:
    find_package(Python REQUIRED COMPONENTS Interpreter Development Development.Module Development.Embed)

This guarantees the required Python::Python target is present and prevents downstream projects from needing to add extra FindPython boilerplate.

Testing
Tested locally by building SOFA with SofaPython3 and the Cosserat plugin bindings enabled. After applying this change:

  • CMake configure completes successfully (no Python::Python / Development.Embed error)
  • Build and install succeed
  • Example scenes run as expected.

bakpaul and others added 5 commits July 16, 2025 16:06
…ods to enable numpy 2 (sofa-framework#518)

* Use set_printoptions(legacy=True) in node binfing to force usage of legacy repr for numpy objects. This is ocmpatible with numpy 1

* Patch addChild

* Add RAII mechanism to make sure numpy is put back its initial state

* Add [[maybe_unused]]

Co-authored-by: Frederick Roy <fredroy@users.noreply.github.com>

---------

Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>
Co-authored-by: Frederick Roy <fredroy@users.noreply.github.com>
* Add explicit getter and setter

* Remove mistake
* [examples] Update examples using imgui as default

* Add example to keep the Qt GUI example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants