From 9a432c9ae7fdf7856ed4f0bb5ff85c697fde9e0e Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Tue, 21 Jan 2025 17:51:38 +0100 Subject: [PATCH] dartsim: init at 6.15.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: GaƩtan Lepage <33058747+GaetanLepage@users.noreply.github.com> --- .../da/dartsim/disable-failing-tests.patch | 78 +++++++++ pkgs/by-name/da/dartsim/package.nix | 154 ++++++++++++++++++ pkgs/top-level/python-packages.nix | 7 + 3 files changed, 239 insertions(+) create mode 100644 pkgs/by-name/da/dartsim/disable-failing-tests.patch create mode 100644 pkgs/by-name/da/dartsim/package.nix diff --git a/pkgs/by-name/da/dartsim/disable-failing-tests.patch b/pkgs/by-name/da/dartsim/disable-failing-tests.patch new file mode 100644 index 000000000000..d808dc837246 --- /dev/null +++ b/pkgs/by-name/da/dartsim/disable-failing-tests.patch @@ -0,0 +1,78 @@ +diff --git a/tests/integration/CMakeLists.txt b/tests/integration/CMakeLists.txt +index 623102952bfa..c193d6e405fa 100644 +--- a/tests/integration/CMakeLists.txt ++++ b/tests/integration/CMakeLists.txt +@@ -74,11 +74,6 @@ if(TARGET dart-utils) + endif() + + if(TARGET dart-utils-urdf) +- if(NOT MSVC) +- dart_add_test("integration" test_DartLoader) +- target_link_libraries(test_DartLoader dart-utils-urdf) +- endif() +- + dart_add_library(SharedLibraryWamIkFast SharedLibraryWamIkFast.hpp SharedLibraryWamIkFast.cpp) + target_link_libraries(SharedLibraryWamIkFast PUBLIC dart) + target_compile_definitions(SharedLibraryWamIkFast PUBLIC IKFAST_NO_MAIN IKFAST_CLIBRARY) +@@ -88,12 +83,6 @@ if(TARGET dart-utils-urdf) + target_link_libraries(GeneratedWamIkFast PUBLIC dart) + target_compile_definitions(GeneratedWamIkFast PUBLIC IKFAST_NO_MAIN IKFAST_CLIBRARY) + target_compile_options(GeneratedWamIkFast PRIVATE -w) +- +- if(BUILD_SHARED_LIBS) +- dart_add_test("integration" test_IkFast) +- target_link_libraries(test_IkFast dart-utils-urdf) +- add_dependencies(test_IkFast GeneratedWamIkFast SharedLibraryWamIkFast) +- endif() + endif() + + dart_format_add( +@@ -117,24 +106,8 @@ if(TARGET dart-collision-bullet) + target_link_libraries(test_Raycast dart-collision-bullet) + endif() + +-if(TARGET dart-collision-ode) +- # This test doesn't work with FCL because it converts simple shapes to meshes, which makes +- # it difficult to come up with correct test expectations. +- dart_add_test("integration" test_ForceDependentSlip) +- target_link_libraries(test_ForceDependentSlip dart-collision-ode) +-endif() +- + if(TARGET dart-utils) + +- dart_add_test("integration" test_Collision) +- target_link_libraries(test_Collision dart-utils) +- if(TARGET dart-collision-bullet) +- target_link_libraries(test_Collision dart-collision-bullet) +- endif() +- if(TARGET dart-collision-ode) +- target_link_libraries(test_Collision dart-collision-ode) +- endif() +- + dart_add_test("integration" test_Dynamics) + target_link_libraries(test_Dynamics dart-utils) + +@@ -159,9 +132,4 @@ if(TARGET dart-utils) + target_link_libraries(test_World dart-collision-bullet) + endif() + +- if(TARGET dart-utils-urdf) +- dart_add_test("integration" test_ForwardKinematics) +- target_link_libraries(test_ForwardKinematics dart-utils-urdf) +- endif() +- + endif() +diff --git a/tests/regression/CMakeLists.txt b/tests/regression/CMakeLists.txt +index e0dd73c6a461..fa3f7c61c7b0 100644 +--- a/tests/regression/CMakeLists.txt ++++ b/tests/regression/CMakeLists.txt +@@ -12,9 +12,6 @@ endif() + + if(TARGET dart-utils-urdf) + +- dart_add_test("regression" test_Issue838) +- target_link_libraries(test_Issue838 dart-utils-urdf) +- + dart_add_test("regression" test_Issue892) + + dart_add_test("regression" test_Issue895) diff --git a/pkgs/by-name/da/dartsim/package.nix b/pkgs/by-name/da/dartsim/package.nix new file mode 100644 index 000000000000..7345cee85d4a --- /dev/null +++ b/pkgs/by-name/da/dartsim/package.nix @@ -0,0 +1,154 @@ +{ + lib, + stdenv, + fetchFromGitHub, + + pythonSupport ? false, + python3Packages, + + # nativeBuildInputs + cmake, + pkg-config, + + # propagatedBuildInputs + assimp, + blas, + boost, + bullet, + eigen, + fcl, + fmt, + libglut, + nlopt, + imgui, + ipopt, + lapack, + libGL, + libGLU, + ode, + openscenegraph, + pagmo2, + tinyxml-2, + urdfdom, + + # checkInputs + gbenchmark, + gtest, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "dartsim"; + version = "6.15.0"; + + src = fetchFromGitHub { + owner = "dartsim"; + repo = "dart"; + tag = "v${finalAttrs.version}"; + hash = "sha256-ik6FwrN5Ta1LinrXpZZc7AmzdFPoLjG07/zo1IZdmgI="; + }; + + # disable failing tests. CMAKE_CTEST_ARGUMENTS does not work. + patches = [ ./disable-failing-tests.patch ]; + + postPatch = '' + # https://github.com/dartsim/dart/pull/1904, merged upstream + substituteInPlace tests/benchmark/CMakeLists.txt \ + --replace-fail \ + "FetchContent_MakeAvailable(benchmark)" \ + "find_package(benchmark REQUIRED)" + + # https://github.com/dartsim/dart/pull/1907, merged upstream + substituteInPlace python/CMakeLists.txt \ + --replace-fail \ + "FetchContent_MakeAvailable(pybind11)" \ + "find_package(pybind11 CONFIG REQUIRED)" + + # fix use of absolute CMake paths in .pc + substituteInPlace CMakeLists.txt \ + --replace-fail \ + "$""{CMAKE_INSTALL_PREFIX}/$""{CMAKE_INSTALL_LIBDIR}" \ + "$""{CMAKE_INSTALL_LIBDIR}" + substituteInPlace cmake/dart.pc.in \ + --replace-fail \ + "libdir=$""{prefix}/" \ + "libdir=" \ + --replace-fail \ + "includedir=$""{prefix}/" \ + "includedir=" + + # install python bindings + substituteInPlace python/dartpy/CMakeLists.txt \ + --replace-fail \ + "EXCLUDE_FROM_ALL" \ + "" + echo "install(TARGETS $""{pybind_module} DESTINATION ${python3Packages.python.sitePackages})" \ + >> python/dartpy/CMakeLists.txt + ''; + + nativeBuildInputs = + [ + cmake + pkg-config + ] + ++ lib.optionals pythonSupport [ + python3Packages.python + python3Packages.pybind11 + ]; + + propagatedBuildInputs = + [ + blas + boost + assimp + bullet + eigen + fcl + fmt + libglut + gbenchmark + nlopt + # requires imgui_impl_opengl2.h + (imgui.override { IMGUI_BUILD_OPENGL2_BINDING = true; }) + ipopt + lapack + libGL + libGLU + ode + openscenegraph + pagmo2 + tinyxml-2 + urdfdom + ] + ++ lib.optionals pythonSupport [ + python3Packages.numpy + ]; + + checkInputs = [ + gbenchmark + gtest + ]; + nativeCheckInputs = lib.optionals pythonSupport [ + python3Packages.pytest + python3Packages.pythonImportsCheckHook + ]; + doCheck = true; + # build unit tests + preCheck = "make tests"; + pythonImportsCheck = [ "dartpy" ]; + + cmakeFlags = [ + (lib.cmakeBool "DART_BUILD_DARTPY" pythonSupport) + (lib.cmakeBool "DART_USE_SYSTEM_IMGUI" true) + (lib.cmakeBool "DART_USE_SYSTEM_GOOGLEBENCHMARK" true) + (lib.cmakeBool "DART_USE_SYSTEM_GOOGLETEST" true) + ]; + + meta = { + description = "DART: Dynamic Animation and Robotics Toolkit"; + homepage = "https://github.com/dartsim/dart"; + changelog = "https://github.com/dartsim/dart/blob/v${finalAttrs.version}/CHANGELOG.md"; + license = lib.licenses.bsd2; + maintainers = with lib.maintainers; [ nim65s ]; + platforms = lib.platforms.unix ++ lib.platforms.windows; + }; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 9abac7174fad..fb43bc0e43cc 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -3075,6 +3075,13 @@ self: super: with self; { darkdetect = callPackage ../development/python-modules/darkdetect { }; + dartsim = toPythonModule ( + pkgs.dartsim.override { + pythonSupport = true; + python3Packages = self; + } + ); + dasbus = callPackage ../development/python-modules/dasbus { }; dash = callPackage ../development/python-modules/dash { };