diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c12263b..f01857b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,8 +1,10 @@ ci: autoupdate_branch: 'devel' + autofix_prs: false + autoupdate_schedule: quarterly repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-json - id: check-symlinks diff --git a/CMakeLists.txt b/CMakeLists.txt index acd52ed..5eab4ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,10 @@ SET(PROJECT_DESCRIPTION "Python bindings for CppAD and CppADCodeGen using Boost. SET(PROJECT_URL "https://github.com/simple-robotics/pycppad") SET(PROJECT_CUSTOM_HEADER_EXTENSION "hpp") SET(PROJECT_USE_CMAKE_EXPORT TRUE) +# To enable jrl-cmakemodules compatibility with workspace we must define the two +# following lines +SET(PROJECT_AUTO_RUN_FINALIZE FALSE) +SET(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}) # Project configuration @@ -17,15 +21,49 @@ SET(CMAKE_VERBOSE_MAKEFILE TRUE) SET(CXX_DISABLE_WERROR TRUE) # Check if the submodule cmake have been initialized -IF(NOT EXISTS "${CMAKE_SOURCE_DIR}/cmake/base.cmake") +SET(JRL_CMAKE_MODULES "${CMAKE_CURRENT_LIST_DIR}/cmake") +IF(NOT EXISTS "${JRL_CMAKE_MODULES}/base.cmake") MESSAGE(FATAL_ERROR "\nPlease run the following command first:\ngit submodule update --init\n") ENDIF() -INCLUDE(cmake/base.cmake) -INCLUDE(cmake/boost.cmake) -INCLUDE(cmake/ide.cmake) - -SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/find-external/CppAD/" ${CMAKE_MODULE_PATH}) +if(EXISTS "${JRL_CMAKE_MODULES}/base.cmake") + message(STATUS "JRL cmakemodules found in 'cmake/' git submodule") +else() + find_package(jrl-cmakemodules QUIET CONFIG) + if(jrl-cmakemodules_FOUND) + get_property( + JRL_CMAKE_MODULES + TARGET jrl-cmakemodules::jrl-cmakemodules + PROPERTY INTERFACE_INCLUDE_DIRECTORIES) + message(STATUS "JRL cmakemodules found on system at ${JRL_CMAKE_MODULES}") + elseif(${CMAKE_VERSION} VERSION_LESS "3.14.0") + message( + FATAL_ERROR + "\nCan't find jrl-cmakemodules. Please either:\n" + " - use git submodule: 'git submodule update --init'\n" + " - or install https://github.com/jrl-umi3218/jrl-cmakemodules\n" + " - or upgrade your CMake version to >= 3.14 to allow automatic fetching\n") + else() + message(STATUS "JRL cmakemodules not found. Let's fetch it.") + include(FetchContent) + FetchContent_Declare("jrl-cmakemodules" + GIT_REPOSITORY "https://github.com/jrl-umi3218/jrl-cmakemodules.git") + FetchContent_MakeAvailable("jrl-cmakemodules") + FetchContent_GetProperties("jrl-cmakemodules" SOURCE_DIR JRL_CMAKE_MODULES) + endif() +endif() + +# Use BoostConfig module distributed by boost library instead of using FindBoost module distributed +# by CMake +if(POLICY CMP0167) + cmake_policy(SET CMP0167 NEW) +endif() +INCLUDE(${JRL_CMAKE_MODULES}/base.cmake) +INCLUDE(${JRL_CMAKE_MODULES}/boost.cmake) +INCLUDE(${JRL_CMAKE_MODULES}/ide.cmake) +INCLUDE(${JRL_CMAKE_MODULES}/python.cmake) + +SET(CMAKE_MODULE_PATH "${JRL_CMAKE_MODULES}/find-external/CppAD/" ${CMAKE_MODULE_PATH}) # Project definition COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX) @@ -47,6 +85,8 @@ ENDIF(BUILD_WITH_CPPAD_CODEGEN_BINDINGS) ADD_PROJECT_DEPENDENCY(cppad 20180000.0 REQUIRED PKG_CONFIG_REQUIRES "cppad >= 20180000.0") ADD_PROJECT_DEPENDENCY(Eigen3 REQUIRED PKG_CONFIG_REQUIRES "eigen3 >= 3.0.5") +SET(PYTHON_COMPONENTS Interpreter Development NumPy) +FINDPYTHON(REQUIRED) ADD_PROJECT_DEPENDENCY(eigenpy 2.7.14 REQUIRED) SET(${PROJECT_NAME}_HEADERS @@ -140,3 +180,5 @@ PKG_CONFIG_APPEND_BOOST_LIBS(${BOOST_COMPONENTS}) # Install catkin package.xml INSTALL(FILES package.xml DESTINATION share/${PROJECT_NAME}) + +setup_project_finalize() diff --git a/LICENSE b/LICENSE index c383829..1e7045a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2021-2022, INRIA +Copyright (c) 2021-2024, INRIA All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index 50b78ed..f992edf 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,15 @@ PyCppAD — Python bindings for CppAD Automatic Differentiation library
-**PyCppAD** is an open source framework which provides bindings for the CppAD Automatic Differentiation([CppAD](https://coin-or.github.io/CppAD/doc/cppad.htm)) C++ library in Python. -**PyCppAD** also includes support for the CppADCodeGen ([CppADCodeGen](https://github.com/joaoleal/CppADCodeGen)) library, which exploits CppAD functionality to perform code generation. +**PyCppAD** is an open-source framework that provides bindings for the CppAD Automatic Differentiation([CppAD](https://coin-or.github.io/CppAD/doc/cppad.htm)) C++ library in Python. +**PyCppAD** also includes support for the CppADCodeGen ([CppADCodeGen](https://github.com/joaoleal/CppADCodeGen)) library, which exploits CppAD functionality to do code generation. ## Installing PyCppAD @@ -33,7 +33,7 @@ As simple as that: #### Dependencies -PyCppAD dependes on the following dependencies: +PyCppAD depends on the following dependencies: * [Boost.Python](http://boostorg.github.io/python/doc/html/index.html) * [Eigen3](https://eigen.tuxfamily.org) * [EigenPy](https://github.com/stack-of-tasks/eigenpy) @@ -56,7 +56,7 @@ make install Set up the `path_to_your_installation` and `path_to_your_development_source` based on your personal development environment. -Alternatively, in order to compile with [CppADCodeGen](https://github.com/joaoleal/CppADCodeGen) support, add `-DBUILD_WITH_CPPAD_CODEGEN_BINDINGS=ON` to the cmake command, and follow the build sequence as before: +Alternatively, to compile with [CppADCodeGen](https://github.com/joaoleal/CppADCodeGen) support, add `-DBUILD_WITH_CPPAD_CODEGEN_BINDINGS=ON` to the cmake command, and follow the build sequence as before: ``` cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=${path_to_your_installation} -DBUILD_WITH_CPPAD_CODEGEN_BINDINGS=ON @@ -68,6 +68,7 @@ The following people have been involved in the development of **PyCppAD** and ar - [Rohan Budhiraja](https://scholar.google.com/citations?user=NW9Io9AAAAAJ) (Inria): main developer - [Justin Carpentier](https://jcarpent.github.io) (Inria): main developer and manager of the project +- [Joris Vaillant](https://github.com/jorisv) (Inria): core developer and manager of the project ## Acknowledgments diff --git a/cmake b/cmake index 5275edf..91b8f5f 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 5275edfd1a8c6d45e0f90177edad93ef15b2008f +Subproject commit 91b8f5f2168b123a198da079b8e6c09fd1f60285 diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 06fd74d..358c59b 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,4 +1,4 @@ -ADD_PYTHON_UNIT_TEST("add_eq" "example/add_eq.py" "python") +ADD_PYTHON_UNIT_TEST("${PROJECT_NAME}-add_eq" "example/add_eq.py" "python") IF(BUILD_WITH_CPPAD_CODEGEN_BINDINGS) - ADD_PYTHON_UNIT_TEST("cppadcg_c_codegen" "example/cppadcg_c_codegen.py" "python") -ENDIF(BUILD_WITH_CPPAD_CODEGEN_BINDINGS) + ADD_PYTHON_UNIT_TEST("${PROJECT_NAME}-cppadcg_c_codegen" "example/cppadcg_c_codegen.py" "python") +ENDIF() diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 276b4e5..68f2197 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -8,11 +8,11 @@ SET(PYWRAP ${PYWRAP} PARENT_SCOPE) MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/python/${PROJECT_NAME}") -ADD_CUSTOM_TARGET(python) -SET_TARGET_PROPERTIES(python PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD True) +ADD_CUSTOM_TARGET(${PROJECT_NAME}_python) +SET_TARGET_PROPERTIES(${PROJECT_NAME}_python PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD True) ADD_LIBRARY(${PYWRAP} SHARED main.cpp) -ADD_DEPENDENCIES(python ${PYWRAP}) +ADD_DEPENDENCIES(${PROJECT_NAME}_python ${PYWRAP}) TARGET_LINK_LIBRARIES(${PYWRAP} PUBLIC ${PROJECT_NAME}) TARGET_LINK_BOOST_PYTHON(${PYWRAP} PUBLIC) # BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS spews conversion warnings from int to long unsigned int. @@ -35,9 +35,9 @@ SET_TARGET_PROPERTIES(${PYWRAP} PREFIX "" SUFFIX ${PYTHON_EXT_SUFFIX} OUTPUT_NAME "${PYWRAP}" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/python/${PROJECT_NAME}" + LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/python/${PROJECT_NAME}" # On Windows, shared library are treated as binary - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/python/${PROJECT_NAME}" + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/python/${PROJECT_NAME}" ) IF(UNIX AND NOT APPLE)