From 484315be4d0748d4dcdceb83aa8655bf1980ea3f Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Wed, 23 Mar 2022 10:45:29 +0100 Subject: [PATCH 01/26] [CMake] Improve package granularity + Clean Adds the possibility to do: find_package(SofaPython3 REQUIRED COMPONENTS Plugin Bindings.Modules Bindings.Sofa Bindings.SofaGui Bindings.SofaRuntime Bindings.SofaTypes ) And thus to not depend on Bindings.SofaGui if not needed. --- Plugin/CMakeLists.txt | 2 +- Plugin/PluginConfig.cmake.in | 14 ++-- SofaPython3Config.cmake.in | 74 ++++++++++--------- bindings/BindingsConfig.cmake.in | 42 +++-------- .../Modules/Bindings.ModulesConfig.cmake.in | 20 +++++ bindings/Modules/CMakeLists.txt | 9 ++- .../SofaBaseTopology/CMakeLists.txt | 2 +- .../SofaPython3/SofaDeformable/CMakeLists.txt | 4 +- .../src/SofaPython3/SofaGL/CMakeLists.txt | 4 +- bindings/Sofa/Bindings.SofaConfig.cmake.in | 20 +++++ bindings/Sofa/CMakeLists.txt | 9 ++- .../Sofa/Components/CMakeLists.txt | 2 +- .../src/SofaPython3/Sofa/Core/CMakeLists.txt | 4 +- .../SofaPython3/Sofa/Helper/CMakeLists.txt | 2 +- .../Sofa/Simulation/CMakeLists.txt | 6 +- .../src/SofaPython3/Sofa/Types/CMakeLists.txt | 6 +- .../Bindings.SofaExporterConfig.cmake.in | 17 +++++ bindings/SofaExporter/CMakeLists.txt | 10 ++- .../SofaGui/Bindings.SofaGuiConfig.cmake.in | 20 +++++ bindings/SofaGui/CMakeLists.txt | 10 ++- .../Bindings.SofaRuntimeConfig.cmake.in | 18 +++++ bindings/SofaRuntime/CMakeLists.txt | 8 +- .../Bindings.SofaTypesConfig.cmake.in | 15 ++++ bindings/SofaTypes/CMakeLists.txt | 10 ++- 24 files changed, 228 insertions(+), 100 deletions(-) create mode 100644 bindings/Modules/Bindings.ModulesConfig.cmake.in create mode 100644 bindings/Sofa/Bindings.SofaConfig.cmake.in create mode 100644 bindings/SofaExporter/Bindings.SofaExporterConfig.cmake.in create mode 100644 bindings/SofaGui/Bindings.SofaGuiConfig.cmake.in create mode 100644 bindings/SofaRuntime/Bindings.SofaRuntimeConfig.cmake.in create mode 100644 bindings/SofaTypes/Bindings.SofaTypesConfig.cmake.in diff --git a/Plugin/CMakeLists.txt b/Plugin/CMakeLists.txt index 314f04a9b..0fd25ad2c 100644 --- a/Plugin/CMakeLists.txt +++ b/Plugin/CMakeLists.txt @@ -48,7 +48,7 @@ add_library(SofaPython3::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_compile_definitions(${PROJECT_NAME} PRIVATE "-DSOFA_BUILD_SOFAPYTHON3") -target_link_libraries(${PROJECT_NAME} PUBLIC SofaCore SofaDefaultType SofaSimulationCore SofaSimulationGraph Sofa.Helper) +target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Core Sofa.DefaultType Sofa.SimulationCore SofaSimulationGraph Sofa.Helper) target_link_libraries(${PROJECT_NAME} PUBLIC pybind11::module pybind11::embed) if(SP3_BUILD_TEST AND Sofa.Testing_FOUND) diff --git a/Plugin/PluginConfig.cmake.in b/Plugin/PluginConfig.cmake.in index 0641dc00d..0febbeaf3 100644 --- a/Plugin/PluginConfig.cmake.in +++ b/Plugin/PluginConfig.cmake.in @@ -1,21 +1,21 @@ -# CMake package configuration file for the @PROJECT_NAME@ module +# CMake package configuration file for @PROJECT_NAME@ + @PACKAGE_GUARD@ @PACKAGE_INIT@ set(SP3_BUILD_TEST @SP3_BUILD_TEST@) -find_package(pybind11 CONFIG REQUIRED) -find_package(SofaFramework REQUIRED) -find_package(SofaSimulationGraph REQUIRED) - +find_package(pybind11 QUIET REQUIRED CONFIG) +find_package(SofaFramework QUIET REQUIRED) +find_package(SofaSimulationGraph QUIET REQUIRED) if(SP3_BUILD_TEST) - find_package(Sofa.Testing REQUIRED) + find_package(Sofa.Testing QUIET REQUIRED) endif() # If we are importing this config file and the target is not yet there this is indicating that # target is an imported one. So we include it if(NOT TARGET @PROJECT_NAME@) - include("${CMAKE_CURRENT_LIST_DIR}/PluginTargets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") endif() # Check that the component/target is there. diff --git a/SofaPython3Config.cmake.in b/SofaPython3Config.cmake.in index e9ff715aa..b8b94de31 100644 --- a/SofaPython3Config.cmake.in +++ b/SofaPython3Config.cmake.in @@ -1,6 +1,5 @@ -# CMake package configuration file for the @PROJECT_NAME@ module +# CMake package configuration file for @PROJECT_NAME@ -@PACKAGE_GUARD@ @PACKAGE_INIT@ set(SP3_WITH_SOFAEXPORTER @SP3_WITH_SOFAEXPORTER@) @@ -10,44 +9,49 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") include(SofaPython3Tools) # Find Python3 -find_package(Python @PYBIND11_PYTHON_VERSION@ COMPONENTS Interpreter Development REQUIRED) +if(NOT Python_FOUND) + find_package(Python @Python_VERSION@ QUIET REQUIRED COMPONENTS Interpreter Development) +endif() -# Save PYTHON_* vars -set(PYTHON_VERSION_RESET "${PYTHON_VERSION}") -set(PYTHON_EXECUTABLE_RESET "${PYTHON_EXECUTABLE}") -set(PYTHON_LIBRARIES_RESET "${PYTHON_LIBRARIES}") -set(PYTHON_INCLUDE_DIRS_RESET "${PYTHON_INCLUDE_DIRS}") -set(PYTHON_LIBRARY_RESET "${PYTHON_LIBRARY}") -set(PYTHON_INCLUDE_DIR_RESET "${PYTHON_INCLUDE_DIR}") +# Find pybind11 +if(NOT pybind11_FOUND) + # Save PYTHON_* vars + set(PYTHON_VERSION_RESET "${PYTHON_VERSION}") + set(PYTHON_EXECUTABLE_RESET "${PYTHON_EXECUTABLE}") + set(PYTHON_LIBRARIES_RESET "${PYTHON_LIBRARIES}") + set(PYTHON_INCLUDE_DIRS_RESET "${PYTHON_INCLUDE_DIRS}") + set(PYTHON_LIBRARY_RESET "${PYTHON_LIBRARY}") + set(PYTHON_INCLUDE_DIR_RESET "${PYTHON_INCLUDE_DIR}") -# Change PYTHON_* vars before pybind11 find_package -# to be sure that pybind11 relies on the right Python version -set(PYTHON_VERSION "${Python_VERSION}" CACHE STRING "" FORCE) -set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}" CACHE FILEPATH "" FORCE) -set(PYTHON_LIBRARIES "${Python_LIBRARIES}" CACHE STRING "" FORCE) -set(PYTHON_INCLUDE_DIRS "${Python_INCLUDE_DIRS}" CACHE STRING "" FORCE) -if(EXISTS "${Python_LIBRARY}") - set(PYTHON_LIBRARY "${Python_LIBRARY}" CACHE INTERNAL "" FORCE) -elseif(EXISTS "${Python_LIBRARIES}") - set(PYTHON_LIBRARY "${Python_LIBRARIES}" CACHE INTERNAL "" FORCE) -endif() -if(EXISTS "${Python_INCLUDE_DIR}") - set(PYTHON_INCLUDE_DIR "${Python_INCLUDE_DIR}" CACHE INTERNAL "" FORCE) -elseif(EXISTS "${Python_INCLUDE_DIRS}") - set(PYTHON_INCLUDE_DIR "${Python_INCLUDE_DIRS}" CACHE INTERNAL "" FORCE) -endif() + # Change PYTHON_* vars before pybind11 find_package + # to be sure that pybind11 relies on the right Python version + set(PYTHON_VERSION "${Python_VERSION}" CACHE STRING "" FORCE) + set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}" CACHE FILEPATH "" FORCE) + set(PYTHON_LIBRARIES "${Python_LIBRARIES}" CACHE STRING "" FORCE) + set(PYTHON_INCLUDE_DIRS "${Python_INCLUDE_DIRS}" CACHE STRING "" FORCE) + if(EXISTS "${Python_LIBRARY}") + set(PYTHON_LIBRARY "${Python_LIBRARY}" CACHE INTERNAL "" FORCE) + elseif(EXISTS "${Python_LIBRARIES}") + set(PYTHON_LIBRARY "${Python_LIBRARIES}" CACHE INTERNAL "" FORCE) + endif() + if(EXISTS "${Python_INCLUDE_DIR}") + set(PYTHON_INCLUDE_DIR "${Python_INCLUDE_DIR}" CACHE INTERNAL "" FORCE) + elseif(EXISTS "${Python_INCLUDE_DIRS}") + set(PYTHON_INCLUDE_DIR "${Python_INCLUDE_DIRS}" CACHE INTERNAL "" FORCE) + endif() -# Set the minimum pybind11 version to 2.3 (before that the pybind11::embed target did not exist) -find_package(pybind11 2.3 CONFIG QUIET REQUIRED) + find_package(pybind11 @pybind11_VERSION@ QUIET REQUIRED CONFIG) -# Reset PYTHON_* vars -set(PYTHON_VERSION "${PYTHON_VERSION_RESET}" CACHE STRING "" FORCE) -set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE_RESET}" CACHE FILEPATH "" FORCE) -set(PYTHON_LIBRARIES "${PYTHON_LIBRARIES_RESET}" CACHE STRING "" FORCE) -set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS_RESET}" CACHE STRING "" FORCE) -set(PYTHON_LIBRARY "${PYTHON_LIBRARY_RESET}" CACHE INTERNAL "" FORCE) -set(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_DIR_RESET}" CACHE INTERNAL "" FORCE) + # Reset PYTHON_* vars + set(PYTHON_VERSION "${PYTHON_VERSION_RESET}" CACHE STRING "" FORCE) + set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE_RESET}" CACHE FILEPATH "" FORCE) + set(PYTHON_LIBRARIES "${PYTHON_LIBRARIES_RESET}" CACHE STRING "" FORCE) + set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS_RESET}" CACHE STRING "" FORCE) + set(PYTHON_LIBRARY "${PYTHON_LIBRARY_RESET}" CACHE INTERNAL "" FORCE) + set(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_DIR_RESET}" CACHE INTERNAL "" FORCE) +endif() +# Find SofaPython3::XXXXX if(NOT SofaPython3_FIND_COMPONENTS) set(SofaPython3_FIND_COMPONENTS Plugin Bindings) endif() diff --git a/bindings/BindingsConfig.cmake.in b/bindings/BindingsConfig.cmake.in index 42e41b64c..d270f1dd7 100644 --- a/bindings/BindingsConfig.cmake.in +++ b/bindings/BindingsConfig.cmake.in @@ -1,45 +1,25 @@ -# CMake package configuration file for the @PROJECT_NAME@ module +# CMake package configuration file for @PROJECT_NAME@ @PACKAGE_GUARD@ @PACKAGE_INIT@ -# Required by all targets -find_package(pybind11 CONFIG REQUIRED) +set(SP3_WITH_SOFAEXPORTER @SP3_WITH_SOFAEXPORTER@) -# Required by Modules.SofaBaseTopology, Sofa.Components, Sofa.Core, Sofa.Helper, Sofa.Types, SofaExporter, SofaGui, SofaRuntime, SofaTypes -find_package(SofaPython3 COMPONENTS Plugin) - -# Required by the bindings Modules.SofaBaseTopology -find_package(SofaBaseTopology REQUIRED) - -# Required by the bindings Modules.SofaDeformable -find_package(SofaDeformable REQUIRED) - -# Required by the bindings Sofa.Components, Sofa.Core, Sofa.Helper, Sofa.Simulation, Sofa.Types, SofaGui -find_package(SofaFramework REQUIRED) - -# Required by the bindings Sofa.Simulation, SofaRuntime -find_package(SofaSimulationGraph REQUIRED) - -# Required by the bindings SofaRuntime -find_package(SofaSimulationCommon REQUIRED) - -# Required by the bindings SofaGui -find_package(Sofa.GL QUIET) -find_package(SofaGui REQUIRED) - -# Required by the bindings Sofa.Core -find_package(SofaBaseVisual REQUIRED) - -# Required by the bindings SofaExporter +find_package(SofaPython3 QUIET REQUIRED COMPONENTS + Bindings.Modules + Bindings.Sofa + Bindings.SofaGui + Bindings.SofaRuntime + Bindings.SofaTypes + ) if(SP3_WITH_SOFAEXPORTER) - find_package(SofaExporter REQUIRED) + find_package(SofaPython3 QUIET REQUIRED COMPONENTS Bindings.SofaExporter) endif() # If we are importing this config file and the target is not yet there this is indicating that # target is an imported one. So we include it if(NOT TARGET @PROJECT_NAME@) - include("${CMAKE_CURRENT_LIST_DIR}/BindingsTargets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") endif() # Check that the component/target is there. diff --git a/bindings/Modules/Bindings.ModulesConfig.cmake.in b/bindings/Modules/Bindings.ModulesConfig.cmake.in new file mode 100644 index 000000000..314a4b35d --- /dev/null +++ b/bindings/Modules/Bindings.ModulesConfig.cmake.in @@ -0,0 +1,20 @@ +# CMake package configuration file for @PROJECT_NAME@ + +@PACKAGE_GUARD@ +@PACKAGE_INIT@ + +find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin Bindings.Sofa) + +# Required by Bindings.Modules.SofaBaseTopology +find_package(SofaBaseTopology QUIET REQUIRED) +# Required by Bindings.Modules.SofaDeformable +find_package(SofaDeformable QUIET REQUIRED) + +# If we are importing this config file and the target is not yet there this is indicating that +# target is an imported one. So we include it +if(NOT TARGET @PROJECT_NAME@) + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +endif() + +# Check that the component/target is there. +check_required_components(@PROJECT_NAME@) diff --git a/bindings/Modules/CMakeLists.txt b/bindings/Modules/CMakeLists.txt index d653248e4..6cf000c9f 100644 --- a/bindings/Modules/CMakeLists.txt +++ b/bindings/Modules/CMakeLists.txt @@ -23,8 +23,13 @@ foreach(modulebindings_module ${MODULEBINDINGS_MODULE_LIST}) set_target_properties(${PROJECT_NAME}.${modulebindings_module} PROPERTIES FOLDER "Bindings/Modules") endforeach() -install(TARGETS ${PROJECT_NAME} EXPORT BindingsTargets) - if(SP3_BUILD_TEST) add_subdirectory(tests) endif() + +sofa_create_component_in_package_with_targets( + COMPONENT_NAME ${PROJECT_NAME} + COMPONENT_VERSION ${SofaPython3_VERSION} + PACKAGE_NAME SofaPython3 + TARGETS ${PROJECT_NAME} + ) diff --git a/bindings/Modules/src/SofaPython3/SofaBaseTopology/CMakeLists.txt b/bindings/Modules/src/SofaPython3/SofaBaseTopology/CMakeLists.txt index b9604287f..a549f5d6e 100644 --- a/bindings/Modules/src/SofaPython3/SofaBaseTopology/CMakeLists.txt +++ b/bindings/Modules/src/SofaPython3/SofaBaseTopology/CMakeLists.txt @@ -17,7 +17,7 @@ find_package(SofaBaseTopology REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings + PACKAGE Bindings.Modules MODULE SofaBaseTopology DESTINATION Sofa SOURCES ${SOURCE_FILES} diff --git a/bindings/Modules/src/SofaPython3/SofaDeformable/CMakeLists.txt b/bindings/Modules/src/SofaPython3/SofaDeformable/CMakeLists.txt index d4f3f54ef..4f4a304f3 100644 --- a/bindings/Modules/src/SofaPython3/SofaDeformable/CMakeLists.txt +++ b/bindings/Modules/src/SofaPython3/SofaDeformable/CMakeLists.txt @@ -14,7 +14,7 @@ set(HEADER_FILES ) if (NOT TARGET SofaPython3::Plugin) - find_package(SofaPython3 REQUIRED) + find_package(SofaPython3 REQUIRED COMPONENTS Plugin Bindings.Sofa) endif() find_package(SofaBase REQUIRED) @@ -22,7 +22,7 @@ find_package(SofaDeformable REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings + PACKAGE Bindings.Modules MODULE SofaDeformable DESTINATION Sofa SOURCES ${SOURCE_FILES} diff --git a/bindings/Modules/src/SofaPython3/SofaGL/CMakeLists.txt b/bindings/Modules/src/SofaPython3/SofaGL/CMakeLists.txt index 2e8ad764c..16eafb236 100644 --- a/bindings/Modules/src/SofaPython3/SofaGL/CMakeLists.txt +++ b/bindings/Modules/src/SofaPython3/SofaGL/CMakeLists.txt @@ -11,14 +11,14 @@ set(HEADER_FILES ) if (NOT TARGET SofaPython3::Plugin) - find_package(SofaPython3 REQUIRED) + find_package(SofaPython3 REQUIRED COMPONENTS Plugin Bindings.Sofa) endif() find_package(Sofa.GL REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings + PACKAGE Bindings.Modules MODULE SofaGL DESTINATION Sofa SOURCES ${SOURCE_FILES} diff --git a/bindings/Sofa/Bindings.SofaConfig.cmake.in b/bindings/Sofa/Bindings.SofaConfig.cmake.in new file mode 100644 index 000000000..dfdffa0d9 --- /dev/null +++ b/bindings/Sofa/Bindings.SofaConfig.cmake.in @@ -0,0 +1,20 @@ +# CMake package configuration file for @PROJECT_NAME@ + +@PACKAGE_GUARD@ +@PACKAGE_INIT@ + +find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin) + +# Required by Bindings.Sofa.Components, Bindings.Sofa.Core, Bindings.Sofa.Helper, Bindings.Sofa.Simulation, Bindings.Sofa.Types, Bindings.SofaGui +find_package(SofaFramework QUIET REQUIRED) +# Required by Bindings.Sofa.Simulation, Bindings.SofaRuntime +find_package(SofaSimulationGraph QUIET REQUIRED) + +# If we are importing this config file and the target is not yet there this is indicating that +# target is an imported one. So we include it +if(NOT TARGET @PROJECT_NAME@) + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +endif() + +# Check that the component/target is there. +check_required_components(@PROJECT_NAME@) diff --git a/bindings/Sofa/CMakeLists.txt b/bindings/Sofa/CMakeLists.txt index 371c13d15..9bfab5b51 100644 --- a/bindings/Sofa/CMakeLists.txt +++ b/bindings/Sofa/CMakeLists.txt @@ -26,8 +26,13 @@ foreach(sofabindings_module ${SOFABINDINGS_MODULE_LIST}) target_link_libraries(${PROJECT_NAME} INTERFACE ${PROJECT_NAME}.${sofabindings_module}) endforeach() -install(TARGETS ${PROJECT_NAME} EXPORT BindingsTargets) - if(SP3_BUILD_TEST) add_subdirectory(tests) endif() + +sofa_create_component_in_package_with_targets( + COMPONENT_NAME ${PROJECT_NAME} + COMPONENT_VERSION ${SofaPython3_VERSION} + PACKAGE_NAME SofaPython3 + TARGETS ${PROJECT_NAME} + ) diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Components/CMakeLists.txt b/bindings/Sofa/src/SofaPython3/Sofa/Components/CMakeLists.txt index cfb3d04ba..755c179dc 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Components/CMakeLists.txt +++ b/bindings/Sofa/src/SofaPython3/Sofa/Components/CMakeLists.txt @@ -12,7 +12,7 @@ find_package(SofaFramework REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings + PACKAGE Bindings.Sofa MODULE Components DESTINATION Sofa SOURCES ${SOURCE_FILES} diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt b/bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt index 2019180d1..6920bf831 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt +++ b/bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt @@ -70,7 +70,7 @@ set(SOURCE_FILES ) if (NOT TARGET SofaPython3::Plugin) - find_package(SofaPython3 REQUIRED) + find_package(SofaPython3 REQUIRED COMPONENTS Plugin) endif() find_package(SofaFramework REQUIRED) @@ -80,7 +80,7 @@ find_package(SofaBaseUtils REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings + PACKAGE Bindings.Sofa MODULE Core DESTINATION Sofa SOURCES ${SOURCE_FILES} diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt b/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt index a0350531f..d4e108b3e 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt +++ b/bindings/Sofa/src/SofaPython3/Sofa/Helper/CMakeLists.txt @@ -19,7 +19,7 @@ find_package(SofaFramework REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings + PACKAGE Bindings.Sofa MODULE Helper DESTINATION Sofa SOURCES ${SOURCE_FILES} diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Simulation/CMakeLists.txt b/bindings/Sofa/src/SofaPython3/Sofa/Simulation/CMakeLists.txt index f15f819e6..91550974e 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Simulation/CMakeLists.txt +++ b/bindings/Sofa/src/SofaPython3/Sofa/Simulation/CMakeLists.txt @@ -9,7 +9,7 @@ set(SOURCE_FILES ) if (NOT TARGET SofaPython3::Plugin) - find_package(SofaPython3 REQUIRED) + find_package(SofaPython3 REQUIRED COMPONENTS Plugin) endif() find_package(SofaFramework REQUIRED) @@ -17,10 +17,10 @@ find_package(SofaSimulationGraph REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings + PACKAGE Bindings.Sofa MODULE Simulation DESTINATION Sofa SOURCES ${SOURCE_FILES} HEADERS ${HEADER_FILES} - DEPENDS SofaCore SofaSimulationCore SofaSimulationGraph SofaPython3::Plugin + DEPENDS Sofa.Core Sofa.SimulationCore SofaSimulationGraph SofaPython3::Plugin ) diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Types/CMakeLists.txt b/bindings/Sofa/src/SofaPython3/Sofa/Types/CMakeLists.txt index f3edb6261..2331a4f60 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Types/CMakeLists.txt +++ b/bindings/Sofa/src/SofaPython3/Sofa/Types/CMakeLists.txt @@ -13,10 +13,10 @@ find_package(SofaFramework REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings + PACKAGE Bindings.Sofa MODULE Types DESTINATION Sofa SOURCES ${SOURCE_FILES} HEADERS ${HEADER_FILES} - DEPENDS SofaCore SofaDefaultType SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core -) \ No newline at end of file + DEPENDS Sofa.Core Sofa.DefaultType SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core +) diff --git a/bindings/SofaExporter/Bindings.SofaExporterConfig.cmake.in b/bindings/SofaExporter/Bindings.SofaExporterConfig.cmake.in new file mode 100644 index 000000000..d37d4146d --- /dev/null +++ b/bindings/SofaExporter/Bindings.SofaExporterConfig.cmake.in @@ -0,0 +1,17 @@ +# CMake package configuration file for @PROJECT_NAME@ + +@PACKAGE_GUARD@ +@PACKAGE_INIT@ + +find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin Bindings.Sofa) + +find_package(SofaExporter QUIET REQUIRED) + +# If we are importing this config file and the target is not yet there this is indicating that +# target is an imported one. So we include it +if(NOT TARGET @PROJECT_NAME@) + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +endif() + +# Check that the component/target is there. +check_required_components(@PROJECT_NAME@) diff --git a/bindings/SofaExporter/CMakeLists.txt b/bindings/SofaExporter/CMakeLists.txt index 77e1dc056..05da9aa44 100644 --- a/bindings/SofaExporter/CMakeLists.txt +++ b/bindings/SofaExporter/CMakeLists.txt @@ -17,9 +17,15 @@ find_package(SofaExporter REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings MODULE SofaExporter SOURCES ${SOURCE_FILES} HEADERS ${HEADER_FILES} DEPENDS SofaExporter SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core -) \ No newline at end of file +) + +sofa_create_component_in_package_with_targets( + COMPONENT_NAME ${PROJECT_NAME} + COMPONENT_VERSION ${SofaPython3_VERSION} + PACKAGE_NAME SofaPython3 + TARGETS ${PROJECT_NAME} + ) diff --git a/bindings/SofaGui/Bindings.SofaGuiConfig.cmake.in b/bindings/SofaGui/Bindings.SofaGuiConfig.cmake.in new file mode 100644 index 000000000..72c979df2 --- /dev/null +++ b/bindings/SofaGui/Bindings.SofaGuiConfig.cmake.in @@ -0,0 +1,20 @@ +# CMake package configuration file for @PROJECT_NAME@ + +@PACKAGE_GUARD@ +@PACKAGE_INIT@ + +find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin Bindings.Sofa) + +find_package(Sofa.GL QUIET REQUIRED) +find_package(Sofa.Core QUIET REQUIRED) +find_package(SofaGuiCommon QUIET REQUIRED) +find_package(SofaGui QUIET REQUIRED) + +# If we are importing this config file and the target is not yet there this is indicating that +# target is an imported one. So we include it +if(NOT TARGET @PROJECT_NAME@) + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +endif() + +# Check that the component/target is there. +check_required_components(@PROJECT_NAME@) diff --git a/bindings/SofaGui/CMakeLists.txt b/bindings/SofaGui/CMakeLists.txt index 7b3865d32..1ae3d8093 100644 --- a/bindings/SofaGui/CMakeLists.txt +++ b/bindings/SofaGui/CMakeLists.txt @@ -17,10 +17,16 @@ find_package(SofaFramework REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings MODULE Gui DESTINATION Sofa SOURCES ${SOURCE_FILES} HEADERS ${HEADER_FILES} - DEPENDS SofaCore SofaGuiCommon SofaGui SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core + DEPENDS Sofa.Core SofaGuiCommon SofaGui SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core ) + +sofa_create_component_in_package_with_targets( + COMPONENT_NAME ${PROJECT_NAME} + COMPONENT_VERSION ${SofaPython3_VERSION} + PACKAGE_NAME SofaPython3 + TARGETS ${PROJECT_NAME} + ) diff --git a/bindings/SofaRuntime/Bindings.SofaRuntimeConfig.cmake.in b/bindings/SofaRuntime/Bindings.SofaRuntimeConfig.cmake.in new file mode 100644 index 000000000..cff20baf4 --- /dev/null +++ b/bindings/SofaRuntime/Bindings.SofaRuntimeConfig.cmake.in @@ -0,0 +1,18 @@ +# CMake package configuration file for @PROJECT_NAME@ + +@PACKAGE_GUARD@ +@PACKAGE_INIT@ + +find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin Bindings.Sofa) + +find_package(SofaSimulationGraph QUIET REQUIRED) +find_package(SofaSimulationCommon QUIET REQUIRED) + +# If we are importing this config file and the target is not yet there this is indicating that +# target is an imported one. So we include it +if(NOT TARGET @PROJECT_NAME@) + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +endif() + +# Check that the component/target is there. +check_required_components(@PROJECT_NAME@) diff --git a/bindings/SofaRuntime/CMakeLists.txt b/bindings/SofaRuntime/CMakeLists.txt index dc894ec39..587d52f14 100644 --- a/bindings/SofaRuntime/CMakeLists.txt +++ b/bindings/SofaRuntime/CMakeLists.txt @@ -22,7 +22,6 @@ SP3_add_python_package( SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings MODULE SofaRuntime DESTINATION SofaRuntime SOURCES ${SOURCE_FILES} @@ -30,6 +29,13 @@ SP3_add_python_module( DEPENDS Sofa.Core Sofa.Helper Sofa.SimulationCore SofaSimulationGraph SofaSimulationCommon SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core ) +sofa_create_component_in_package_with_targets( + COMPONENT_NAME ${PROJECT_NAME} + COMPONENT_VERSION ${SofaPython3_VERSION} + PACKAGE_NAME SofaPython3 + TARGETS ${PROJECT_NAME} + ) + if(SP3_BUILD_TEST) add_subdirectory(tests) endif() diff --git a/bindings/SofaTypes/Bindings.SofaTypesConfig.cmake.in b/bindings/SofaTypes/Bindings.SofaTypesConfig.cmake.in new file mode 100644 index 000000000..b602a2841 --- /dev/null +++ b/bindings/SofaTypes/Bindings.SofaTypesConfig.cmake.in @@ -0,0 +1,15 @@ +# CMake package configuration file for @PROJECT_NAME@ + +@PACKAGE_GUARD@ +@PACKAGE_INIT@ + +find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin Bindings.Sofa) + +# If we are importing this config file and the target is not yet there this is indicating that +# target is an imported one. So we include it +if(NOT TARGET @PROJECT_NAME@) + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +endif() + +# Check that the component/target is there. +check_required_components(@PROJECT_NAME@) diff --git a/bindings/SofaTypes/CMakeLists.txt b/bindings/SofaTypes/CMakeLists.txt index 452a5a46b..a7cc1cbe7 100644 --- a/bindings/SofaTypes/CMakeLists.txt +++ b/bindings/SofaTypes/CMakeLists.txt @@ -24,14 +24,20 @@ find_package(SofaFramework REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} - PACKAGE Bindings MODULE SofaTypes DESTINATION SofaTypes SOURCES ${SOURCE_FILES} HEADERS ${HEADER_FILES} - DEPENDS SofaDefaultType SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core + DEPENDS Sofa.DefaultType SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core ) +sofa_create_component_in_package_with_targets( + COMPONENT_NAME ${PROJECT_NAME} + COMPONENT_VERSION ${SofaPython3_VERSION} + PACKAGE_NAME SofaPython3 + TARGETS ${PROJECT_NAME} + ) + if(SP3_BUILD_TEST) add_subdirectory(tests) endif() From 90c92982029278eef4baff0b537080c042e7970e Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Wed, 23 Mar 2022 11:25:55 +0100 Subject: [PATCH 02/26] [CMake] FIX SP3_add_python_module DESTINATION --- CMake/SofaPython3Tools.cmake | 6 ++++++ bindings/SofaExporter/CMakeLists.txt | 1 + 2 files changed, 7 insertions(+) diff --git a/CMake/SofaPython3Tools.cmake b/CMake/SofaPython3Tools.cmake index 6360995e3..7663899a0 100644 --- a/CMake/SofaPython3Tools.cmake +++ b/CMake/SofaPython3Tools.cmake @@ -338,6 +338,12 @@ function(SP3_add_python_module) install( TARGETS ${A_TARGET} EXPORT ${A_PACKAGE}Targets + ) + endif() + + if (DESTINATION) + install( + TARGETS ${A_TARGET} RUNTIME DESTINATION "lib/${SP3_PYTHON_PACKAGES_DIRECTORY}/${DESTINATION}" COMPONENT applications LIBRARY DESTINATION "lib/${SP3_PYTHON_PACKAGES_DIRECTORY}/${DESTINATION}" COMPONENT libraries ARCHIVE DESTINATION "lib/${SP3_PYTHON_PACKAGES_DIRECTORY}/${DESTINATION}" COMPONENT libraries diff --git a/bindings/SofaExporter/CMakeLists.txt b/bindings/SofaExporter/CMakeLists.txt index 05da9aa44..880491275 100644 --- a/bindings/SofaExporter/CMakeLists.txt +++ b/bindings/SofaExporter/CMakeLists.txt @@ -18,6 +18,7 @@ find_package(SofaExporter REQUIRED) SP3_add_python_module( TARGET ${PROJECT_NAME} MODULE SofaExporter + DESTINATION . SOURCES ${SOURCE_FILES} HEADERS ${HEADER_FILES} DEPENDS SofaExporter SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core From 11df13f324a160a3f40b2bcf9151b5fbb12f603d Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Thu, 24 Mar 2022 10:33:54 +0100 Subject: [PATCH 03/26] [CI] Improve workflow --- .github/workflows/ci.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b98e746d..f5c3e8a3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -244,15 +244,27 @@ jobs: done PROJECT_NAME="${GITHUB_REPOSITORY#*/}" echo "PROJECT_NAME=$PROJECT_NAME" | tee -a $GITHUB_ENV + + RELEASE_NAME="${{ github.ref_name }}" + RELEASE_TAGNAME="release-${{ github.ref_name }}" + if [[ "${{ github.event.inputs.is_nightly }}" == "true" ]]; then + RELEASE_NAME="$RELEASE_NAME-nightly" + RELEASE_TAGNAME="$RELEASE_TAGNAME-nightly" + fi + RELEASE_DATE="$(date)" + echo "RELEASE_NAME=$RELEASE_NAME" | tee -a $GITHUB_ENV + echo "RELEASE_TAGNAME=$RELEASE_TAGNAME" | tee -a $GITHUB_ENV + echo "RELEASE_DATE=$RELEASE_DATE" | tee -a $GITHUB_ENV - name: Upload release uses: softprops/action-gh-release@v1 with: - name: ${{ github.ref_name }} - tag_name: release-${{ github.ref_name }} + name: ${{ env.RELEASE_NAME }} + tag_name: ${{ env.RELEASE_TAGNAME }} fail_on_unmatched_files: true + body: | + Last updated on ${{ env.RELEASE_DATE }} files: | artifacts/${{ env.PROJECT_NAME }}_*_Linux.zip artifacts/${{ env.PROJECT_NAME }}_*_Windows.zip artifacts/${{ env.PROJECT_NAME }}_*_macOS.zip - From 5964b1fd8dd22ac150f6092681c71db7ba9f1643 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Thu, 24 Mar 2022 10:50:52 +0100 Subject: [PATCH 04/26] [CI] Improve workflow (2) --- .github/workflows/ci.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5c3e8a3a..cda91f0f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,14 @@ jobs: with: sofa_root: ${{ github.workspace }}/sofa sofa_version: ${{ matrix.sofa_branch }} - sofa_scope: 'minimal' + sofa_scope: 'standard' + + - name: Remove SofaPython3 from SOFA binaries if any + shell: bash + run: | + if [ -d "$SOFA_ROOT/plugins/SofaPython3" ]; then + rm -rf $SOFA_ROOT/plugins/SofaPython3 + fi - name: Checkout source code uses: actions/checkout@v2 @@ -251,7 +258,7 @@ jobs: RELEASE_NAME="$RELEASE_NAME-nightly" RELEASE_TAGNAME="$RELEASE_TAGNAME-nightly" fi - RELEASE_DATE="$(date)" + RELEASE_DATE="$(date +'%Y-%m-%d (at %T)')" echo "RELEASE_NAME=$RELEASE_NAME" | tee -a $GITHUB_ENV echo "RELEASE_TAGNAME=$RELEASE_TAGNAME" | tee -a $GITHUB_ENV echo "RELEASE_DATE=$RELEASE_DATE" | tee -a $GITHUB_ENV From 85620e0ae79c28a9288c44a66f799ad515b0848a Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Thu, 24 Mar 2022 17:06:47 +0100 Subject: [PATCH 05/26] Better pybind11 install --- .github/workflows/ci.yml | 110 ++++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 53 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cda91f0f1..4d965d6f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Setup SOFA and environment id: sofa - uses: sofa-framework/sofa-setup-action@v3 + uses: guparan/sofa-setup-action@add_qt_install with: sofa_root: ${{ github.workspace }}/sofa sofa_version: ${{ matrix.sofa_branch }} @@ -55,63 +55,67 @@ jobs: ARTIFACT_NAME="${PROJECT_NAME}_${ARTIFACT_VERSION}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}" echo "ARTIFACT_NAME=$ARTIFACT_NAME" | tee -a $GITHUB_ENV - - name: Set env vars for pybind11 installation - shell: bash - run: | - # Define pybind11 specs - PYBIND11_VERSION=2.4.3 - PYBIND11_INSTALL_PATH="/tmp/deps_cache_is_for_windows_only" - if [[ "$RUNNER_OS" == "Windows" ]]; then - PYBIND11_INSTALL_PATH="C:/pybind11" - fi - echo "PYBIND11_VERSION=$PYBIND11_VERSION" | tee -a $GITHUB_ENV - echo "PYBIND11_INSTALL_PATH=$PYBIND11_INSTALL_PATH" | tee -a $GITHUB_ENV + # - name: Set env vars for pybind11 installation + # shell: bash + # run: | + # # Define pybind11 specs + # PYBIND11_VERSION=2.4.3 + # PYBIND11_INSTALL_PATH="/tmp/deps_cache_is_for_windows_only" + # if [[ "$RUNNER_OS" == "Windows" ]]; then + # PYBIND11_INSTALL_PATH="C:/pybind11" + # fi + # echo "PYBIND11_VERSION=$PYBIND11_VERSION" | tee -a $GITHUB_ENV + # echo "PYBIND11_INSTALL_PATH=$PYBIND11_INSTALL_PATH" | tee -a $GITHUB_ENV - - name: Setup cache for pybind11 files - uses: actions/cache@v2 - id: pybind11_cache - with: - path: ${{ env.PYBIND11_INSTALL_PATH }} - key: pybind11-${{ env.PYBIND11_VERSION }}_${{ runner.os }}_python-${{ steps.sofa.outputs.python_version }}_${{ hashFiles('src/.github/workflows/*.yml') }} + # - name: Setup cache for pybind11 files + # uses: actions/cache@v2 + # id: pybind11_cache + # with: + # path: ${{ env.PYBIND11_INSTALL_PATH }} + # key: pybind11-${{ env.PYBIND11_VERSION }}_${{ runner.os }}_python-${{ steps.sofa.outputs.python_version }}_${{ hashFiles('src/.github/workflows/*.yml') }} - name: Install pybind11 shell: bash run: | # Build and install pybind11 - if [[ "$RUNNER_OS" == "Windows" ]]; then - if ! ls -a "$PYBIND11_INSTALL_PATH"/* >/dev/null 2>&1; then - # directory does not exist or is empty - git clone -b v$PYBIND11_VERSION --depth 1 https://github.com/pybind/pybind11.git "${{ runner.temp }}/pybind11_tmp" - cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} && \ - cd /d ${{ runner.temp }}/pybind11_tmp && \ - cmake \ - -GNinja \ - -DCMAKE_BUILD_TYPE=Release \ - -DPYBIND11_TEST=OFF \ - -DCMAKE_INSTALL_PREFIX=$PYBIND11_INSTALL_PATH \ - -DPYTHON_ROOT=$PYTHON_ROOT \ - -DPython_ROOT=$PYTHON_ROOT \ - -DPYTHON_EXECUTABLE=$PYTHON_ROOT/python.exe \ - -DPython_EXECUTABLE=$PYTHON_ROOT/python.exe \ - . && \ - ninja install" - fi - echo "pybind11_ROOT=$PYBIND11_INSTALL_PATH" | tee -a $GITHUB_ENV - echo "$PYBIND11_INSTALL_PATH" >> $GITHUB_PATH - else - git clone -b v${PYBIND11_VERSION} --depth 1 https://github.com/pybind/pybind11.git "${{ runner.temp }}/pybind11_tmp" - cd "${{ runner.temp }}/pybind11_tmp" - cmake \ - -GNinja \ - -DCMAKE_BUILD_TYPE=Release \ - -DPYBIND11_TEST=OFF \ - -DPYTHON_ROOT=$PYTHON_ROOT \ - -DPython_ROOT=$PYTHON_ROOT \ - -DPYTHON_EXECUTABLE=$PYTHON_ROOT/python \ - -DPython_EXECUTABLE=$PYTHON_ROOT/python \ - . - sudo ninja install - fi + #if [[ "$RUNNER_OS" == "Windows" ]]; then + # if ! ls -a "$PYBIND11_INSTALL_PATH"/* >/dev/null 2>&1; then + # # directory does not exist or is empty + # git clone -b v$PYBIND11_VERSION --depth 1 https://github.com/pybind/pybind11.git "${{ runner.temp }}/pybind11_tmp" + # cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} && \ + # cd /d ${{ runner.temp }}/pybind11_tmp && \ + # cmake \ + # -GNinja \ + # -DCMAKE_BUILD_TYPE=Release \ + # -DPYBIND11_TEST=OFF \ + # -DCMAKE_INSTALL_PREFIX=$PYBIND11_INSTALL_PATH \ + # -DPYTHON_ROOT=$PYTHON_ROOT \ + # -DPython_ROOT=$PYTHON_ROOT \ + # -DPYTHON_EXECUTABLE=$PYTHON_ROOT/python.exe \ + # -DPython_EXECUTABLE=$PYTHON_ROOT/python.exe \ + # . && \ + # ninja install" + # fi + # echo "pybind11_ROOT=$PYBIND11_INSTALL_PATH" | tee -a $GITHUB_ENV + # echo "$PYBIND11_INSTALL_PATH" >> $GITHUB_PATH + #else + # git clone -b v${PYBIND11_VERSION} --depth 1 https://github.com/pybind/pybind11.git "${{ runner.temp }}/pybind11_tmp" + # cd "${{ runner.temp }}/pybind11_tmp" + # cmake \ + # -GNinja \ + # -DCMAKE_BUILD_TYPE=Release \ + # -DPYBIND11_TEST=OFF \ + # -DPYTHON_ROOT=$PYTHON_ROOT \ + # -DPython_ROOT=$PYTHON_ROOT \ + # -DPYTHON_EXECUTABLE=$PYTHON_ROOT/python \ + # -DPython_EXECUTABLE=$PYTHON_ROOT/python \ + # . + # sudo ninja install + #fi + ${{ steps.sofa.outputs.python_exe }} -m pip install pybind11==2.6.2 + which pybind11-config && pybind11_ROOT="$(pybind11-config --cmakedir)" || true + which pybind11-config-3.8 && pybind11_ROOT="$(pybind11-config-3.8 --cmakedir)" || true + echo "pybind11_ROOT=$pybind11_ROOT" | tee -a $GITHUB_ENV - name: Setup cache for ccache files if: ${{ runner.os != 'Windows' }} @@ -144,7 +148,7 @@ jobs: -GNinja \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake \ + -DCMAKE_PREFIX_PATH="$SOFA_ROOT/lib/cmake" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \ -DPYTHON_ROOT=$PYTHON_ROOT \ From 042f0cd233983be67394655682fa687df675fdde Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Thu, 24 Mar 2022 17:20:22 +0100 Subject: [PATCH 06/26] Better pybind11 install (2) --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d965d6f3..6ab3d70e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,7 @@ jobs: sofa_root: ${{ github.workspace }}/sofa sofa_version: ${{ matrix.sofa_branch }} sofa_scope: 'standard' + python_version: '3.8' - name: Remove SofaPython3 from SOFA binaries if any shell: bash From f44b7c57e2c494e55f6de00fea81b0591a4514fa Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Thu, 24 Mar 2022 17:44:04 +0100 Subject: [PATCH 07/26] Clean workflow --- .github/workflows/ci.yml | 133 +++++++++++---------------------------- 1 file changed, 37 insertions(+), 96 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ab3d70e7..73620cf4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,9 +31,10 @@ jobs: sofa_scope: 'standard' python_version: '3.8' - - name: Remove SofaPython3 from SOFA binaries if any + - name: Remove SofaPython3 from SOFA binaries (if any) shell: bash run: | + # TODO: remove this step when SOFA "standard" no longer contains SP3 if [ -d "$SOFA_ROOT/plugins/SofaPython3" ]; then rm -rf $SOFA_ROOT/plugins/SofaPython3 fi @@ -42,81 +43,18 @@ jobs: uses: actions/checkout@v2 with: path: ${{ env.WORKSPACE_SRC_PATH }} - - - name: Set env vars for artifacts naming - shell: bash - run: | - PROJECT_NAME="${GITHUB_REPOSITORY#*/}" - echo "PROJECT_NAME=$PROJECT_NAME" | tee -a $GITHUB_ENV - - ARTIFACT_VERSION="${{ steps.sofa.outputs.run_branch }}" - if [[ "${{ github.event.inputs.is_nightly }}" == "true" ]]; then - ARTIFACT_VERSION="${ARTIFACT_VERSION}-nightly" - fi - ARTIFACT_NAME="${PROJECT_NAME}_${ARTIFACT_VERSION}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}" - echo "ARTIFACT_NAME=$ARTIFACT_NAME" | tee -a $GITHUB_ENV - - # - name: Set env vars for pybind11 installation - # shell: bash - # run: | - # # Define pybind11 specs - # PYBIND11_VERSION=2.4.3 - # PYBIND11_INSTALL_PATH="/tmp/deps_cache_is_for_windows_only" - # if [[ "$RUNNER_OS" == "Windows" ]]; then - # PYBIND11_INSTALL_PATH="C:/pybind11" - # fi - # echo "PYBIND11_VERSION=$PYBIND11_VERSION" | tee -a $GITHUB_ENV - # echo "PYBIND11_INSTALL_PATH=$PYBIND11_INSTALL_PATH" | tee -a $GITHUB_ENV - - # - name: Setup cache for pybind11 files - # uses: actions/cache@v2 - # id: pybind11_cache - # with: - # path: ${{ env.PYBIND11_INSTALL_PATH }} - # key: pybind11-${{ env.PYBIND11_VERSION }}_${{ runner.os }}_python-${{ steps.sofa.outputs.python_version }}_${{ hashFiles('src/.github/workflows/*.yml') }} - + - name: Install pybind11 shell: bash run: | - # Build and install pybind11 - #if [[ "$RUNNER_OS" == "Windows" ]]; then - # if ! ls -a "$PYBIND11_INSTALL_PATH"/* >/dev/null 2>&1; then - # # directory does not exist or is empty - # git clone -b v$PYBIND11_VERSION --depth 1 https://github.com/pybind/pybind11.git "${{ runner.temp }}/pybind11_tmp" - # cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} && \ - # cd /d ${{ runner.temp }}/pybind11_tmp && \ - # cmake \ - # -GNinja \ - # -DCMAKE_BUILD_TYPE=Release \ - # -DPYBIND11_TEST=OFF \ - # -DCMAKE_INSTALL_PREFIX=$PYBIND11_INSTALL_PATH \ - # -DPYTHON_ROOT=$PYTHON_ROOT \ - # -DPython_ROOT=$PYTHON_ROOT \ - # -DPYTHON_EXECUTABLE=$PYTHON_ROOT/python.exe \ - # -DPython_EXECUTABLE=$PYTHON_ROOT/python.exe \ - # . && \ - # ninja install" - # fi - # echo "pybind11_ROOT=$PYBIND11_INSTALL_PATH" | tee -a $GITHUB_ENV - # echo "$PYBIND11_INSTALL_PATH" >> $GITHUB_PATH - #else - # git clone -b v${PYBIND11_VERSION} --depth 1 https://github.com/pybind/pybind11.git "${{ runner.temp }}/pybind11_tmp" - # cd "${{ runner.temp }}/pybind11_tmp" - # cmake \ - # -GNinja \ - # -DCMAKE_BUILD_TYPE=Release \ - # -DPYBIND11_TEST=OFF \ - # -DPYTHON_ROOT=$PYTHON_ROOT \ - # -DPython_ROOT=$PYTHON_ROOT \ - # -DPYTHON_EXECUTABLE=$PYTHON_ROOT/python \ - # -DPython_EXECUTABLE=$PYTHON_ROOT/python \ - # . - # sudo ninja install - #fi ${{ steps.sofa.outputs.python_exe }} -m pip install pybind11==2.6.2 - which pybind11-config && pybind11_ROOT="$(pybind11-config --cmakedir)" || true - which pybind11-config-3.8 && pybind11_ROOT="$(pybind11-config-3.8 --cmakedir)" || true - echo "pybind11_ROOT=$pybind11_ROOT" | tee -a $GITHUB_ENV + pybind11_DIR="pybind11-dir-not-found" + if [ -e "$(command -v pybind11-config-3.8)" ]; then + pybind11_DIR="$(pybind11-config-3.8 --cmakedir)" + elif [ -e "$(command -v pybind11-config)" ]; then + pybind11_DIR="$(pybind11-config --cmakedir)" + fi + echo "pybind11_DIR=$pybind11_DIR" | tee -a $GITHUB_ENV - name: Setup cache for ccache files if: ${{ runner.os != 'Windows' }} @@ -128,39 +66,43 @@ jobs: - name: Build and install shell: bash run: | + cmake_options="-GNinja \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \ + -DCMAKE_PREFIX_PATH="$SOFA_ROOT/lib/cmake" \ + -DPYTHON_ROOT=$PYTHON_ROOT -DPython_ROOT=$PYTHON_ROOT \ + -DPYTHON_EXECUTABLE=$PYTHON_EXE -DPython_EXECUTABLE=$PYTHON_EXE" + if [ -e "$(command -v ccache)" ]; then + cmake_options="$cmake_options -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" + fi + cmake_options="$(echo $cmake_options)" # prettify + if [[ "$RUNNER_OS" == "Windows" ]]; then cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \ && cd /d $WORKSPACE_BUILD_PATH \ - && cmake \ - -GNinja \ - -DCMAKE_PREFIX_PATH="$SOFA_ROOT/lib/cmake" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \ - -DPYTHON_ROOT=$PYTHON_ROOT \ - -DPython_ROOT=$PYTHON_ROOT \ - -DPYTHON_EXECUTABLE=$PYTHON_ROOT/python.exe \ - -DPython_EXECUTABLE=$PYTHON_ROOT/python.exe \ - ../src \ + && cmake $cmake_options ../src \ && ninja install" else cd "$WORKSPACE_BUILD_PATH" ccache -z - cmake \ - -GNinja \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_PREFIX_PATH="$SOFA_ROOT/lib/cmake" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \ - -DPYTHON_ROOT=$PYTHON_ROOT \ - -DPython_ROOT=$PYTHON_ROOT \ - -DPYTHON_EXECUTABLE=$PYTHON_ROOT/python \ - -DPython_EXECUTABLE=$PYTHON_ROOT/python \ - ../src + cmake $cmake_options ../src ninja install echo ${CCACHE_BASEDIR} ccache -s fi + + - name: Set env vars for artifacts + shell: bash + run: | + PROJECT_NAME="${GITHUB_REPOSITORY#*/}" + echo "PROJECT_NAME=$PROJECT_NAME" | tee -a $GITHUB_ENV + + ARTIFACT_VERSION="${{ steps.sofa.outputs.run_branch }}" + if [[ "${{ github.event.inputs.is_nightly }}" == "true" ]]; then + ARTIFACT_VERSION="${ARTIFACT_VERSION}-nightly" + fi + ARTIFACT_NAME="${PROJECT_NAME}_${ARTIFACT_VERSION}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}" + echo "ARTIFACT_NAME=$ARTIFACT_NAME" | tee -a $GITHUB_ENV - name: Create artifact uses: actions/upload-artifact@v2 @@ -204,8 +146,7 @@ jobs: echo "SOFA_ROOT = $SOFA_ROOT" echo "PYTHONPATH = $PYTHONPATH" echo '----------------------' - echo "which python = $(which python)" - python -c "import sys; print('sys.version = ' + str(sys.version)); print('sys.path = ' + str(sys.path))" + ${{ steps.sofa.outputs.python_exe }} -c "import sys; print('sys.version = ' + str(sys.version)); print('sys.path = ' + str(sys.path))" - name: Run test Binding.Sofa.Tests if: always() From ad0651a286a7c04e6e8deb4231f6b03c510cf473 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Thu, 24 Mar 2022 19:14:37 +0100 Subject: [PATCH 08/26] Clean workflow (2) --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 73620cf4a..e1a68c3e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,11 +38,6 @@ jobs: if [ -d "$SOFA_ROOT/plugins/SofaPython3" ]; then rm -rf $SOFA_ROOT/plugins/SofaPython3 fi - - - name: Checkout source code - uses: actions/checkout@v2 - with: - path: ${{ env.WORKSPACE_SRC_PATH }} - name: Install pybind11 shell: bash @@ -56,6 +51,11 @@ jobs: fi echo "pybind11_DIR=$pybind11_DIR" | tee -a $GITHUB_ENV + - name: Checkout source code + uses: actions/checkout@v2 + with: + path: ${{ env.WORKSPACE_SRC_PATH }} + - name: Setup cache for ccache files if: ${{ runner.os != 'Windows' }} uses: actions/cache@v2 From 565f796817fbc8fcff92b218a38a499da4984728 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Mon, 28 Mar 2022 11:11:36 +0200 Subject: [PATCH 09/26] Add python_version matrix axis --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1a68c3e2..f767e7c3e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,7 @@ jobs: matrix: os: [ubuntu-20.04, macos-10.15, windows-2019] sofa_branch: [master] + python_version: [3.7] #, 3.8, 3.9, 3.10] steps: - name: Setup SOFA and environment @@ -29,7 +30,7 @@ jobs: sofa_root: ${{ github.workspace }}/sofa sofa_version: ${{ matrix.sofa_branch }} sofa_scope: 'standard' - python_version: '3.8' + python_version: ${{ matrix.python_version }} - name: Remove SofaPython3 from SOFA binaries (if any) shell: bash From d0c139b6361af644ca113ceb271ba76afa5382f7 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Mon, 28 Mar 2022 11:35:52 +0200 Subject: [PATCH 10/26] Add python_version matrix axis (2) --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f767e7c3e..3ea2415e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,14 +13,14 @@ on: jobs: build-and-test: - name: Run on ${{ matrix.os }} with SOFA ${{ matrix.sofa_branch }} + name: Run on ${{ matrix.os }} with SOFA ${{ matrix.sofa_branch }} and python ${{ matrix.python_version }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-20.04, macos-10.15, windows-2019] sofa_branch: [master] - python_version: [3.7] #, 3.8, 3.9, 3.10] + python_version: [3.7, 3.8, 3.9, 3.10] steps: - name: Setup SOFA and environment @@ -102,7 +102,7 @@ jobs: if [[ "${{ github.event.inputs.is_nightly }}" == "true" ]]; then ARTIFACT_VERSION="${ARTIFACT_VERSION}-nightly" fi - ARTIFACT_NAME="${PROJECT_NAME}_${ARTIFACT_VERSION}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}" + ARTIFACT_NAME="${PROJECT_NAME}_${ARTIFACT_VERSION}_python-${{ matrix.python_version }}_for-SOFA-${{ matrix.sofa_branch }}_${{ runner.os }}" echo "ARTIFACT_NAME=$ARTIFACT_NAME" | tee -a $GITHUB_ENV - name: Create artifact From 400b98176f1afb98a02b1c45f74aa8b4187e6b3c Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Mon, 28 Mar 2022 11:37:35 +0200 Subject: [PATCH 11/26] Add python_version matrix axis (3) --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ea2415e4..9d30fb608 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: matrix: os: [ubuntu-20.04, macos-10.15, windows-2019] sofa_branch: [master] - python_version: [3.7, 3.8, 3.9, 3.10] + python_version: ['3.7', '3.8', '3.9', '3.10'] steps: - name: Setup SOFA and environment @@ -30,7 +30,7 @@ jobs: sofa_root: ${{ github.workspace }}/sofa sofa_version: ${{ matrix.sofa_branch }} sofa_scope: 'standard' - python_version: ${{ matrix.python_version }} + python_version: '${{ matrix.python_version }}' - name: Remove SofaPython3 from SOFA binaries (if any) shell: bash From d196a14db8b60f121ac57b0a7d591ee5ec424444 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Mon, 28 Mar 2022 12:07:31 +0200 Subject: [PATCH 12/26] Improve logs --- .github/workflows/ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d30fb608..d84794f1c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -124,6 +124,9 @@ jobs: if [[ "$RUNNER_OS" == "Windows" ]]; then echo "$(cd $WORKSPACE_ARTIFACT_PATH/lib && pwd -W)" >> $GITHUB_PATH echo "$(cd $WORKSPACE_ARTIFACT_PATH/bin && pwd -W)" >> $GITHUB_PATH + echo "$(cd $PYTHON_ROOT && pwd -W)" >> $GITHUB_PATH + echo "$(cd $PYTHON_ROOT/Lib && pwd -W)" >> $GITHUB_PATH + echo "$(cd $PYTHON_ROOT/Scripts && pwd -W)" >> $GITHUB_PATH elif [[ "$RUNNER_OS" == "macOS" ]]; then echo "DYLD_LIBRARY_PATH=$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$DYLD_LIBRARY_PATH" | tee -a $GITHUB_ENV fi @@ -147,7 +150,9 @@ jobs: echo "SOFA_ROOT = $SOFA_ROOT" echo "PYTHONPATH = $PYTHONPATH" echo '----------------------' - ${{ steps.sofa.outputs.python_exe }} -c "import sys; print('sys.version = ' + str(sys.version)); print('sys.path = ' + str(sys.path))" + echo "PATH = $PATH" + echo '----------------------' + python -c "import sys; print('sys.version = ' + str(sys.version)); print('sys.path = ' + str(sys.path))" - name: Run test Binding.Sofa.Tests if: always() From ad5b8e6e5f717ad843ce707099011e51dda19c47 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Mon, 28 Mar 2022 14:41:01 +0200 Subject: [PATCH 13/26] Clean python env vars on Windows workflow --- .github/workflows/ci.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d84794f1c..45db64a01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,11 +122,12 @@ jobs: run: | # Set env vars for tests if [[ "$RUNNER_OS" == "Windows" ]]; then - echo "$(cd $WORKSPACE_ARTIFACT_PATH/lib && pwd -W)" >> $GITHUB_PATH - echo "$(cd $WORKSPACE_ARTIFACT_PATH/bin && pwd -W)" >> $GITHUB_PATH - echo "$(cd $PYTHON_ROOT && pwd -W)" >> $GITHUB_PATH - echo "$(cd $PYTHON_ROOT/Lib && pwd -W)" >> $GITHUB_PATH - echo "$(cd $PYTHON_ROOT/Scripts && pwd -W)" >> $GITHUB_PATH + echo "$WORKSPACE_ARTIFACT_PATH/lib" >> $GITHUB_PATH + echo "$WORKSPACE_ARTIFACT_PATH/bin" >> $GITHUB_PATH + echo "$PYTHON_ROOT" >> $GITHUB_PATH + echo "$PYTHON_ROOT/Lib" >> $GITHUB_PATH + echo "$PYTHON_ROOT/Scripts" >> $GITHUB_PATH + echo "PYTHONHOME=$PYTHON_ROOT" | tee -a $GITHUB_ENV elif [[ "$RUNNER_OS" == "macOS" ]]; then echo "DYLD_LIBRARY_PATH=$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$DYLD_LIBRARY_PATH" | tee -a $GITHUB_ENV fi From 4fcff7419284a0bd700de974121e3f49badd6065 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Mon, 28 Mar 2022 17:04:44 +0200 Subject: [PATCH 14/26] Debug python version issue Windows --- .github/workflows/ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45db64a01..878dba3a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -128,6 +128,16 @@ jobs: echo "$PYTHON_ROOT/Lib" >> $GITHUB_PATH echo "$PYTHON_ROOT/Scripts" >> $GITHUB_PATH echo "PYTHONHOME=$PYTHON_ROOT" | tee -a $GITHUB_ENV + echo '----------------------' + ls -la "${{ runner.tool_cache }}/Python" + echo '----------------------' + runner_python_basedir="$(cd "${{ runner.tool_cache }}/Python" && pwd -W 2>/dev/null || pwd)" + for python_dir in "$runner_python_basedir"/*; do + if [[ "$python_dir" != */"${{ matrix.python_version }}"* ]]; then + echo "Removing (not ${{ matrix.python_version }}): $python_dir" + rm -rf "$python_dir" + fi + done elif [[ "$RUNNER_OS" == "macOS" ]]; then echo "DYLD_LIBRARY_PATH=$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$DYLD_LIBRARY_PATH" | tee -a $GITHUB_ENV fi From 40bacaa942e6cbf1bf5b8feaba46053e02c2a1e9 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Mon, 28 Mar 2022 17:57:22 +0200 Subject: [PATCH 15/26] [Plugin] Add lots of debug info --- Plugin/src/SofaPython3/PythonEnvironment.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Plugin/src/SofaPython3/PythonEnvironment.cpp b/Plugin/src/SofaPython3/PythonEnvironment.cpp index c9bee419b..d50bd6922 100644 --- a/Plugin/src/SofaPython3/PythonEnvironment.cpp +++ b/Plugin/src/SofaPython3/PythonEnvironment.cpp @@ -145,6 +145,19 @@ void PythonEnvironment::Init() std::string pythonVersion = Py_GetVersion(); msg_info("SofaPython3") << "Initializing with python version " << pythonVersion; + msg_info("SofaPython3") << "Py_GetBuildInfo = " << Py_GetBuildInfo(); + msg_info("SofaPython3") << "Py_GetCompiler = " << Py_GetCompiler(); + msg_info("SofaPython3") << "Py_GetCopyright = " << Py_GetCopyright(); + msg_info("SofaPython3") << "Py_GetPlatform = " << Py_GetPlatform(); + + msg_info("SofaPython3") << "Py_GetPrefix = " << Py_GetPrefix(); + msg_info("SofaPython3") << "Py_GetExecPrefix = " << Py_GetExecPrefix(); + msg_info("SofaPython3") << "Py_GetPath = " << Py_GetPath(); + + msg_info("SofaPython3") << "Py_GetProgramName = " << Py_GetProgramName(); + msg_info("SofaPython3") << "Py_GetPythonHome = " << Py_GetPythonHome(); + msg_info("SofaPython3") << "Py_GetProgramFullPath = " << Py_GetProgramFullPath(); + if( !SceneLoaderFactory::getInstance()->getEntryFileExtension("py3") ) { msg_info("SofaPython3") << "Registering a scene loader for [.py, .py3, .pyscn, .py3scn] files." ; From 7941e69d5e3014790e2df8f13c4035df45a6df77 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Mon, 28 Mar 2022 18:18:44 +0200 Subject: [PATCH 16/26] FIX binary SP3 removal --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 878dba3a6..bda20bea3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,8 +36,12 @@ jobs: shell: bash run: | # TODO: remove this step when SOFA "standard" no longer contains SP3 + ls -la "$SOFA_ROOT/plugins" if [ -d "$SOFA_ROOT/plugins/SofaPython3" ]; then - rm -rf $SOFA_ROOT/plugins/SofaPython3 + echo "Removing $SOFA_ROOT/plugins/SofaPython3" + rm -rf $SOFA_ROOT/plugins/SofaPython3* + rm -rf $SOFA_ROOT/bin/SofaPython3* + rm -rf $SOFA_ROOT/lib/SofaPython3* fi - name: Install pybind11 From cc2ee790849773e0850628a9c447b0785616a1a1 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Tue, 29 Mar 2022 11:35:47 +0200 Subject: [PATCH 17/26] CLEAN debug logs --- .github/workflows/ci.yml | 25 ++++---------------- Plugin/src/SofaPython3/PythonEnvironment.cpp | 13 ---------- 2 files changed, 4 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bda20bea3..ae5521bdf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,13 +36,10 @@ jobs: shell: bash run: | # TODO: remove this step when SOFA "standard" no longer contains SP3 - ls -la "$SOFA_ROOT/plugins" - if [ -d "$SOFA_ROOT/plugins/SofaPython3" ]; then - echo "Removing $SOFA_ROOT/plugins/SofaPython3" - rm -rf $SOFA_ROOT/plugins/SofaPython3* - rm -rf $SOFA_ROOT/bin/SofaPython3* - rm -rf $SOFA_ROOT/lib/SofaPython3* - fi + echo "Removing SofaPython3 from SOFA binaries (if any)" + rm -rf $SOFA_ROOT/plugins/SofaPython3* + rm -rf $SOFA_ROOT/bin/SofaPython3* + rm -rf $SOFA_ROOT/lib/SofaPython3* - name: Install pybind11 shell: bash @@ -128,20 +125,6 @@ jobs: if [[ "$RUNNER_OS" == "Windows" ]]; then echo "$WORKSPACE_ARTIFACT_PATH/lib" >> $GITHUB_PATH echo "$WORKSPACE_ARTIFACT_PATH/bin" >> $GITHUB_PATH - echo "$PYTHON_ROOT" >> $GITHUB_PATH - echo "$PYTHON_ROOT/Lib" >> $GITHUB_PATH - echo "$PYTHON_ROOT/Scripts" >> $GITHUB_PATH - echo "PYTHONHOME=$PYTHON_ROOT" | tee -a $GITHUB_ENV - echo '----------------------' - ls -la "${{ runner.tool_cache }}/Python" - echo '----------------------' - runner_python_basedir="$(cd "${{ runner.tool_cache }}/Python" && pwd -W 2>/dev/null || pwd)" - for python_dir in "$runner_python_basedir"/*; do - if [[ "$python_dir" != */"${{ matrix.python_version }}"* ]]; then - echo "Removing (not ${{ matrix.python_version }}): $python_dir" - rm -rf "$python_dir" - fi - done elif [[ "$RUNNER_OS" == "macOS" ]]; then echo "DYLD_LIBRARY_PATH=$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$DYLD_LIBRARY_PATH" | tee -a $GITHUB_ENV fi diff --git a/Plugin/src/SofaPython3/PythonEnvironment.cpp b/Plugin/src/SofaPython3/PythonEnvironment.cpp index d50bd6922..c9bee419b 100644 --- a/Plugin/src/SofaPython3/PythonEnvironment.cpp +++ b/Plugin/src/SofaPython3/PythonEnvironment.cpp @@ -145,19 +145,6 @@ void PythonEnvironment::Init() std::string pythonVersion = Py_GetVersion(); msg_info("SofaPython3") << "Initializing with python version " << pythonVersion; - msg_info("SofaPython3") << "Py_GetBuildInfo = " << Py_GetBuildInfo(); - msg_info("SofaPython3") << "Py_GetCompiler = " << Py_GetCompiler(); - msg_info("SofaPython3") << "Py_GetCopyright = " << Py_GetCopyright(); - msg_info("SofaPython3") << "Py_GetPlatform = " << Py_GetPlatform(); - - msg_info("SofaPython3") << "Py_GetPrefix = " << Py_GetPrefix(); - msg_info("SofaPython3") << "Py_GetExecPrefix = " << Py_GetExecPrefix(); - msg_info("SofaPython3") << "Py_GetPath = " << Py_GetPath(); - - msg_info("SofaPython3") << "Py_GetProgramName = " << Py_GetProgramName(); - msg_info("SofaPython3") << "Py_GetPythonHome = " << Py_GetPythonHome(); - msg_info("SofaPython3") << "Py_GetProgramFullPath = " << Py_GetProgramFullPath(); - if( !SceneLoaderFactory::getInstance()->getEntryFileExtension("py3") ) { msg_info("SofaPython3") << "Registering a scene loader for [.py, .py3, .pyscn, .py3scn] files." ; From a9166de5d24b40deffa774fa1891f01657794fa3 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Tue, 29 Mar 2022 11:46:50 +0200 Subject: [PATCH 18/26] Delete existing release before creating new one --- .github/workflows/ci.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae5521bdf..d0f36dccd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -213,7 +213,14 @@ jobs: echo "RELEASE_TAGNAME=$RELEASE_TAGNAME" | tee -a $GITHUB_ENV echo "RELEASE_DATE=$RELEASE_DATE" | tee -a $GITHUB_ENV - - name: Upload release + - name: Delete old release + uses: dev-drprasad/delete-tag-and-release@v0.2.0 + with: + tag_name: ${{ env.RELEASE_TAGNAME }} + delete_release: true + + - name: Create new release + if: success() || failure() uses: softprops/action-gh-release@v1 with: name: ${{ env.RELEASE_NAME }} From 02a43e24ce89a808bd392772f873b43b52219436 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Tue, 29 Mar 2022 12:14:42 +0200 Subject: [PATCH 19/26] Add missing token --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0f36dccd..afff5dccf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -218,6 +218,8 @@ jobs: with: tag_name: ${{ env.RELEASE_TAGNAME }} delete_release: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create new release if: success() || failure() From 3209068c0ed8570dc2f4710b1b35ca1075c19d6d Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Tue, 29 Mar 2022 13:46:49 +0200 Subject: [PATCH 20/26] Use sofa-setup-action input sofa_with_sofapython3 --- .github/workflows/ci.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afff5dccf..96162da49 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,16 +30,8 @@ jobs: sofa_root: ${{ github.workspace }}/sofa sofa_version: ${{ matrix.sofa_branch }} sofa_scope: 'standard' + sofa_with_sofapython3: 'false' python_version: '${{ matrix.python_version }}' - - - name: Remove SofaPython3 from SOFA binaries (if any) - shell: bash - run: | - # TODO: remove this step when SOFA "standard" no longer contains SP3 - echo "Removing SofaPython3 from SOFA binaries (if any)" - rm -rf $SOFA_ROOT/plugins/SofaPython3* - rm -rf $SOFA_ROOT/bin/SofaPython3* - rm -rf $SOFA_ROOT/lib/SofaPython3* - name: Install pybind11 shell: bash From 8a9ac5f4a8eccd1b68cab162ee834a37f8685674 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Tue, 29 Mar 2022 16:12:36 +0200 Subject: [PATCH 21/26] Use guparan/sofa-setup-action@ci_improve_workflow --- .github/workflows/ci.yml | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96162da49..f3837eae2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,25 +25,13 @@ jobs: steps: - name: Setup SOFA and environment id: sofa - uses: guparan/sofa-setup-action@add_qt_install + uses: guparan/sofa-setup-action@ci_improve_workflow with: sofa_root: ${{ github.workspace }}/sofa sofa_version: ${{ matrix.sofa_branch }} sofa_scope: 'standard' sofa_with_sofapython3: 'false' python_version: '${{ matrix.python_version }}' - - - name: Install pybind11 - shell: bash - run: | - ${{ steps.sofa.outputs.python_exe }} -m pip install pybind11==2.6.2 - pybind11_DIR="pybind11-dir-not-found" - if [ -e "$(command -v pybind11-config-3.8)" ]; then - pybind11_DIR="$(pybind11-config-3.8 --cmakedir)" - elif [ -e "$(command -v pybind11-config)" ]; then - pybind11_DIR="$(pybind11-config --cmakedir)" - fi - echo "pybind11_DIR=$pybind11_DIR" | tee -a $GITHUB_ENV - name: Checkout source code uses: actions/checkout@v2 @@ -200,7 +188,7 @@ jobs: RELEASE_NAME="$RELEASE_NAME-nightly" RELEASE_TAGNAME="$RELEASE_TAGNAME-nightly" fi - RELEASE_DATE="$(date +'%Y-%m-%d (at %T)')" + RELEASE_DATE="$(date +'%Y-%m-%d (at %T UTC)')" echo "RELEASE_NAME=$RELEASE_NAME" | tee -a $GITHUB_ENV echo "RELEASE_TAGNAME=$RELEASE_TAGNAME" | tee -a $GITHUB_ENV echo "RELEASE_DATE=$RELEASE_DATE" | tee -a $GITHUB_ENV From d6ac674f0270d2a18ca23d2abb188c8e01a05be2 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Wed, 30 Mar 2022 17:17:44 +0200 Subject: [PATCH 22/26] Set SOFA branch to robosoft2022 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f3837eae2..4408e4e4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, macos-10.15, windows-2019] - sofa_branch: [master] + sofa_branch: [robosoft2022] python_version: ['3.7', '3.8', '3.9', '3.10'] steps: From 0b382f7093e0c94ca11585389bc189b92f5dd00d Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Fri, 1 Apr 2022 16:44:38 +0200 Subject: [PATCH 23/26] Fix workflow for robosoft2022 branch --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4408e4e4a..2a1034488 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: steps: - name: Setup SOFA and environment id: sofa - uses: guparan/sofa-setup-action@ci_improve_workflow + uses: sofa-framework/sofa-setup-action@robosoft2022 with: sofa_root: ${{ github.workspace }}/sofa sofa_version: ${{ matrix.sofa_branch }} From 301c244a21dad924d6f591b9e422135efddb24e0 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Thu, 21 Apr 2022 16:11:03 +0200 Subject: [PATCH 24/26] Prepare merge with master --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a1034488..6ea5d6f28 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,13 +19,13 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, macos-10.15, windows-2019] - sofa_branch: [robosoft2022] - python_version: ['3.7', '3.8', '3.9', '3.10'] + sofa_branch: [master] + python_version: ['3.8'] steps: - name: Setup SOFA and environment id: sofa - uses: sofa-framework/sofa-setup-action@robosoft2022 + uses: sofa-framework/sofa-setup-action@v4 with: sofa_root: ${{ github.workspace }}/sofa sofa_version: ${{ matrix.sofa_branch }} From f8d08955394e4eb0f94b08762556827c3e8fe2c6 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Thu, 21 Apr 2022 17:37:20 +0200 Subject: [PATCH 25/26] Set python default version to 3.9 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ea5d6f28..8e99ce91d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: matrix: os: [ubuntu-20.04, macos-10.15, windows-2019] sofa_branch: [master] - python_version: ['3.8'] + python_version: ['3.9'] steps: - name: Setup SOFA and environment From 8db986bd0746d51d349eda3c4c7319a27edf36b1 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Thu, 28 Apr 2022 15:02:53 +0200 Subject: [PATCH 26/26] Revert SofaPython3Tools.cmake --- CMake/SofaPython3Tools.cmake | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CMake/SofaPython3Tools.cmake b/CMake/SofaPython3Tools.cmake index 35e9aa767..5a44ae7a1 100644 --- a/CMake/SofaPython3Tools.cmake +++ b/CMake/SofaPython3Tools.cmake @@ -338,12 +338,6 @@ function(SP3_add_python_module) install( TARGETS ${A_TARGET} EXPORT ${A_PACKAGE}Targets - ) - endif() - - if (DESTINATION) - install( - TARGETS ${A_TARGET} RUNTIME DESTINATION "lib/${SP3_PYTHON_PACKAGES_DIRECTORY}/${DESTINATION}" COMPONENT applications LIBRARY DESTINATION "lib/${SP3_PYTHON_PACKAGES_DIRECTORY}/${DESTINATION}" COMPONENT libraries ARCHIVE DESTINATION "lib/${SP3_PYTHON_PACKAGES_DIRECTORY}/${DESTINATION}" COMPONENT libraries