diff --git a/.github/workflows/ci-ubuntu-macos.yml b/.github/workflows/ci-ubuntu-macos.yml index cf13f65..3d115cc 100644 --- a/.github/workflows/ci-ubuntu-macos.yml +++ b/.github/workflows/ci-ubuntu-macos.yml @@ -28,11 +28,12 @@ jobs: - uses: conda-incubator/setup-miniconda@v3 with: + miniforge-version: latest activate-environment: pycppad - auto-update-conda: true environment-file: .github/workflows/conda/conda-env.yml - python-version: 3.8 + auto-update-conda: true auto-activate-base: false + conda-remove-defaults: true - name: Build PyCppAD shell: bash -el {0} @@ -50,7 +51,7 @@ jobs: -DPYTHON_EXECUTABLE=$(which python3) \ -DBUILD_WITH_CPPAD_CODEGEN_BINDINGS=ON ninja -j1 - ctest --output-on-failure -C Release -V + ctest --output-on-failure ninja install - name: Uninstall PyCppAD diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 537d0a6..0ba9ea4 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -9,16 +9,19 @@ env: jobs: build: + name: build (${{ matrix.os }}, ${{ matrix.compiler.name }}, ${{ matrix.compiler.cppad_codegen }}) runs-on: ${{ matrix.os }} strategy: - fail-fast: true + fail-fast: false matrix: os: [windows-latest] compiler: - - cmd: cl + - name: cl + cmd: cl cppad_codegen: OFF - - cmd: clang-cl + - name: clang-cl + cmd: '%CONDA_PREFIX%\\Library\\bin\\clang-cl' cppad_codegen: ON steps: @@ -28,11 +31,12 @@ jobs: - uses: conda-incubator/setup-miniconda@v3 with: + miniforge-version: latest activate-environment: pycppad - auto-update-conda: true environment-file: .github/workflows/conda/conda-env.yml - python-version: 3.8 + auto-update-conda: true auto-activate-base: false + conda-remove-defaults: true - name: Build PyCppAD shell: cmd /C CALL {0} @@ -62,7 +66,7 @@ jobs: ninja -j1 :: Testing - ctest --output-on-failure -C Release -V + ctest --output-on-failure :: Test Python import ninja install diff --git a/.github/workflows/conda/conda-env.yml b/.github/workflows/conda/conda-env.yml index 1f0cbde..5a8ad82 100644 --- a/.github/workflows/conda/conda-env.yml +++ b/.github/workflows/conda/conda-env.yml @@ -2,13 +2,15 @@ name: pycppad channels: - conda-forge dependencies: - - boost + - libboost-devel + - libboost-python-devel - eigenpy - python - cppad - cppadcodegen - - ninja - cmake - pkg-config - ninja - cxx-compiler + - clangxx + - doxygen diff --git a/CMakeLists.txt b/CMakeLists.txt index 5eab4ef..07f0d47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # Copyright (c) 2021-2023 INRIA # -CMAKE_MINIMUM_REQUIRED(VERSION 3.10) +CMAKE_MINIMUM_REQUIRED(VERSION 3.22) SET(PROJECT_NAME pycppad) SET(PROJECT_DESCRIPTION "Python bindings for CppAD and CppADCodeGen using Boost.Python") @@ -21,11 +21,7 @@ SET(CMAKE_VERBOSE_MAKEFILE TRUE) SET(CXX_DISABLE_WERROR TRUE) # Check if the submodule cmake have been initialized -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() - +set(JRL_CMAKE_MODULES "${CMAKE_CURRENT_LIST_DIR}/cmake") if(EXISTS "${JRL_CMAKE_MODULES}/base.cmake") message(STATUS "JRL cmakemodules found in 'cmake/' git submodule") else() @@ -36,13 +32,6 @@ else() 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) @@ -63,8 +52,6 @@ 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) PROJECT(${PROJECT_NAME} ${PROJECT_ARGS}) @@ -79,11 +66,11 @@ ADD_PROJECT_DEPENDENCY(Boost REQUIRED) EXPORT_BOOST_DEFAULT_OPTIONS() IF(BUILD_WITH_CPPAD_CODEGEN_BINDINGS) - ADD_PROJECT_DEPENDENCY(cppadcg 2.4.1 REQUIRED PKG_CONFIG_REQUIRES "cppadcg >= 2.4.1") # CppADCodeGen 2.4.1 is the first version to check the minimal version of CppAD + ADD_PROJECT_DEPENDENCY(cppadcg 2.4.1 REQUIRED PKG_CONFIG_REQUIRES "cppadcg >= 2.4.1" FIND_EXTERNAL "CppAD") # CppADCodeGen 2.4.1 is the first version to check the minimal version of CppAD ADD_DEFINITIONS(-DPYCPPAD_WITH_CPPAD_CODEGEN_BINDINGS) ENDIF(BUILD_WITH_CPPAD_CODEGEN_BINDINGS) -ADD_PROJECT_DEPENDENCY(cppad 20180000.0 REQUIRED PKG_CONFIG_REQUIRES "cppad >= 20180000.0") +ADD_PROJECT_DEPENDENCY(cppad 20180000.0 REQUIRED PKG_CONFIG_REQUIRES "cppad >= 20180000.0" FIND_EXTERNAL "CppAD") ADD_PROJECT_DEPENDENCY(Eigen3 REQUIRED PKG_CONFIG_REQUIRES "eigen3 >= 3.0.5") SET(PYTHON_COMPONENTS Interpreter Development NumPy) FINDPYTHON(REQUIRED) @@ -178,7 +165,4 @@ PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME}) PKG_CONFIG_APPEND_CFLAGS("-I${PYTHON_INCLUDE_DIRS}") 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/cmake b/cmake index 91b8f5f..c815b3b 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 91b8f5f2168b123a198da079b8e6c09fd1f60285 +Subproject commit c815b3ba45fa8b7cf4b7a21b69b26ad0bc04fd5c diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 358c59b..15c8170 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,4 +1,15 @@ +function(ADD_WINDOWS_DLL_PATH_TO_TEST TEST_NAME) + if(WIN32) + get_test_property(${TEST_NAME} ENVIRONMENT ENV_VARIABLES) + list(APPEND ENV_VARIABLES + "PYCPPAD_WINDOWS_DLL_PATH=$") + set_tests_properties(${TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARIABLES}") + endif() +endfunction() + ADD_PYTHON_UNIT_TEST("${PROJECT_NAME}-add_eq" "example/add_eq.py" "python") +ADD_WINDOWS_DLL_PATH_TO_TEST(${PROJECT_NAME}-add_eq) IF(BUILD_WITH_CPPAD_CODEGEN_BINDINGS) ADD_PYTHON_UNIT_TEST("${PROJECT_NAME}-cppadcg_c_codegen" "example/cppadcg_c_codegen.py" "python") + ADD_WINDOWS_DLL_PATH_TO_TEST(${PROJECT_NAME}-cppadcg_c_codegen) ENDIF() diff --git a/package.xml b/package.xml index 3011b41..23f6bdf 100644 --- a/package.xml +++ b/package.xml @@ -6,18 +6,16 @@ Rohan Budhiraja Rohan Budhiraja Justin Carpentier - BSD + BSD-3-Clause https://github.com/simple-robotics/pycppad git + jrl_cmakemodules doxygen - catkin ament_cmake - python python3 - python-numpy python3-numpy eigen boost diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 68f2197..d3f965a 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -40,8 +40,15 @@ SET_TARGET_PROPERTIES(${PYWRAP} RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/python/${PROJECT_NAME}" ) -IF(UNIX AND NOT APPLE) - SET_TARGET_PROPERTIES(${PYWRAP} PROPERTIES INSTALL_RPATH "\$ORIGIN/../../..") +IF(UNIX) + GET_RELATIVE_RPATH( + ${${PYWRAP}_INSTALL_DIR} + ${PYWRAP}_INSTALL_RPATH + ) + set_target_properties( + ${PYWRAP} + PROPERTIES INSTALL_RPATH "${${PYWRAP}_INSTALL_RPATH}" + ) ENDIF() INSTALL(TARGETS ${PYWRAP} DESTINATION ${${PYWRAP}_INSTALL_DIR}) diff --git a/python/pycppad/__init__.py b/python/pycppad/__init__.py index 7d76833..5f2598a 100644 --- a/python/pycppad/__init__.py +++ b/python/pycppad/__init__.py @@ -2,9 +2,6 @@ # Copyright 2021 INRIA # -from .pycppad_pywrap import * -from .pycppad_pywrap import __version__, __raw_version__ - # On Windows, if pycppad.dll is not in the same directory than # the .pyd, it will not be loaded. # We first try to load pycppad, then, if it fail and we are on Windows: