diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml index 763066fb..c5228e5f 100644 --- a/.github/workflows/asan.yml +++ b/.github/workflows/asan.yml @@ -20,24 +20,20 @@ jobs: # All of these options are optional, so you can remove them if you are happy with the defaults cancel_others: 'true' build: - name: "Asan Python (Clang-10)" + name: "Asan Python (Clang-14)" needs: pre_job if: ${{ needs.pre_job.outputs.should_skip != 'true' }} - runs-on: ubuntu-latest - strategy: - fail-fast: True + runs-on: ubuntu-22.04 steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: - python-version: 3.8 - - - uses: seanmiddleditch/gha-setup-ninja@master + python-version: "3.10" - name: Print env run: | @@ -46,7 +42,7 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade cmake + python -m pip install --upgrade cmake ninja ninja --version cmake --version @@ -66,8 +62,8 @@ jobs: -DCARMA_BUILD_TESTS=ON \ -DBUILD_NATIVE_TESTS=OFF \ -DBUILD_PYTHON_TESTS=ON \ - -DCMAKE_C_COMPILER=clang-10 \ - -DCMAKE_CXX_COMPILER=clang++-10 \ + -DCMAKE_C_COMPILER=clang-14 \ + -DCMAKE_CXX_COMPILER=clang++-14 \ -DCMAKE_INSTALL_PREFIX:PATH=. \ -DPython3_EXECUTABLE=${PY_CMD} \ -DCMAKE_BUILD_TYPE=Asan \ diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 39e1bc6b..7bd487c8 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -36,8 +36,8 @@ jobs: name: "Default settings", os: ubuntu-latest, build_type: "Release", - cc: "gcc-9", - cxx: "g++-9", + cc: "gcc-11", + cxx: "g++-11", generators: "Ninja", target: "all", options: "" @@ -46,8 +46,8 @@ jobs: name: "Hard steal", os: ubuntu-latest, build_type: "Release", - cc: "gcc-9", - cxx: "g++-9", + cc: "gcc-11", + cxx: "g++-11", generators: "Ninja", target: "all", options: "-DENABLE_CARMA_HARD_STEAL=ON" @@ -56,8 +56,8 @@ jobs: name: "Soft steal", os: ubuntu-latest, build_type: "Release", - cc: "gcc-9", - cxx: "g++-9", + cc: "gcc-11", + cxx: "g++-11", generators: "Ninja", target: "all", options: "-DENABLE_CARMA_SOFT_STEAL=ON" @@ -66,23 +66,21 @@ jobs: name: "Not own data", os: ubuntu-latest, build_type: "Release", - cc: "gcc-9", - cxx: "g++-9", + cc: "gcc-11", + cxx: "g++-11", generators: "Ninja", target: "all", options: "-DENABLE_CARMA_DONT_REQUIRE_OWNDATA=ON" } steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: - python-version: 3.8 - - - uses: seanmiddleditch/gha-setup-ninja@master + python-version: '3.10' - name: Print env run: | @@ -91,7 +89,7 @@ jobs: - name: Install dependencies on ubuntu run: | - python -m pip install --upgrade cmake + python -m pip install --upgrade cmake ninja sudo apt install -y lcov ninja --version cmake --version diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index f10cee86..2599c42b 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -35,20 +35,18 @@ jobs: strategy: fail-fast: false matrix: - armadillo: ["10.6.x", "10.8.x", "11.1.x"] - pybind: ["v2.6.0", "v2.9.2"] + armadillo: ["10.8.x", "11.4.x", "12.4.x", "12.6.x", "12.8.x"] + pybind: ["v2.12.0"] steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: false - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: - python-version: 3.8 - - - uses: seanmiddleditch/gha-setup-ninja@master + python-version: '3.10' - name: Print env run: | @@ -57,7 +55,7 @@ jobs: - name: Install dependencies on ubuntu run: | - python -m pip install --upgrade cmake + python -m pip install --upgrade cmake ninja ninja --version cmake --version @@ -77,8 +75,8 @@ jobs: -DCARMA_BUILD_TESTS=ON \ -DUSE_ARMA_VERSION=${{ matrix.armadillo }} \ -DUSE_PYBIND11_VERSION=${{ matrix.pybind }} \ - -DCMAKE_C_COMPILER=clang-10 \ - -DCMAKE_CXX_COMPILER=clang++-10 \ + -DCMAKE_C_COMPILER=clang-14 \ + -DCMAKE_CXX_COMPILER=clang++-14 \ -DCMAKE_INSTALL_PREFIX:PATH=. \ -DPython3_EXECUTABLE=${PY_CMD} \ -DCMAKE_BUILD_TYPE=Release \ diff --git a/.github/workflows/install_test.yml b/.github/workflows/install_test.yml index ab31a862..88aabbeb 100644 --- a/.github/workflows/install_test.yml +++ b/.github/workflows/install_test.yml @@ -48,20 +48,20 @@ jobs: target: "ALL_BUILD" } - { - name: "Ubuntu (Clang-10)", + name: "Ubuntu (Clang-14)", os: ubuntu-latest, build_type: "Release", - cc: "clang-10", - cxx: "clang++-10", + cc: "clang-14", + cxx: "clang++-14", generators: "Ninja", target: "all" } - { - name: "Ubuntu (GCC-9)", + name: "Ubuntu (GCC-11)", os: ubuntu-latest, build_type: "Release", - cc: "gcc-9", - cxx: "g++-9", + cc: "gcc-11", + cxx: "g++-11", generators: "Ninja", target: "all" } @@ -77,15 +77,13 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: - python-version: 3.8 - - - uses: seanmiddleditch/gha-setup-ninja@master + python-version: '3.10' - name: Print env run: | @@ -95,21 +93,21 @@ jobs: - name: Install dependencies on windows if: startsWith(matrix.config.os, 'windows') run: | - choco install cmake + choco install cmake ninja ninja --version cmake --version - name: Install dependencies on ubuntu if: runner.os == 'Linux' run: | - python -m pip install --upgrade cmake + python -m pip install --upgrade cmake ninja ninja --version cmake --version - name: Install dependencies on macos if: startsWith(matrix.config.os, 'macos') run: | - python -m pip install cmake + python -m pip install cmake ninja ninja --version cmake --version @@ -119,7 +117,8 @@ jobs: python -m pip install numpy pytest - name: Install CARMA - if: runner.os == 'Linux' + # install with sudo + if: runner.os == 'Linux' || matrix.config.os == 'macos-latest' run: | mkdir build cd build @@ -138,7 +137,7 @@ jobs: sudo cmake --build . --config Release --target install - name: Install CARMA - if: runner.os != 'Linux' + if: startsWith(matrix.config.os, 'windows') run: | mkdir build cd build diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index e473fbd9..648679b0 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -37,39 +37,37 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.6", "3.7", "3.8", "3.9"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] config: - { - name: "Ubuntu (Clang-10)", + name: "Ubuntu (Clang-14)", os: ubuntu-latest, build_type: "Release", - cc: "clang-10", - cxx: "clang++-10", + cc: "clang-14", + cxx: "clang++-14", generators: "Ninja", target: "all" } - { - name: "Ubuntu (GCC-9)", + name: "Ubuntu (GCC-11)", os: ubuntu-latest, build_type: "Release", - cc: "gcc-9", - cxx: "g++-9", + cc: "gcc-11", + cxx: "g++-11", generators: "Ninja", target: "all" } steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - uses: seanmiddleditch/gha-setup-ninja@master - - name: Print env run: | echo github.event.action: ${{ github.event.action }} @@ -77,7 +75,7 @@ jobs: - name: Install dependencies on ubuntu run: | - python -m pip install --upgrade cmake + python -m pip install --upgrade cmake ninja ninja --version cmake --version diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 38701276..16c2228d 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -37,7 +37,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.6", "3.7", "3.8", "3.9"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] config: - { name: "macOS (Clang)", @@ -51,16 +51,14 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - uses: seanmiddleditch/gha-setup-ninja@master - - name: Print env run: | echo github.event.action: ${{ github.event.action }} @@ -68,7 +66,7 @@ jobs: - name: Install dependencies on macos run: | - python -m pip install cmake + python -m pip install cmake ninja ninja --version cmake --version diff --git a/.github/workflows/mre.yml b/.github/workflows/mre.yml index 5eb899a0..7940ecfc 100644 --- a/.github/workflows/mre.yml +++ b/.github/workflows/mre.yml @@ -51,29 +51,29 @@ jobs: target: "ALL_BUILD" } - { - name: "Ubuntu (Clang-10)", + name: "Ubuntu (Clang-12)", os: ubuntu-latest, build_type: "Release", - cc: "clang-10", - cxx: "clang++-10", + cc: "clang-14", + cxx: "clang++-14", generators: "Ninja", target: "all" } - { - name: "Ubuntu (Clang-11)", + name: "Ubuntu (Clang-14)", os: ubuntu-latest, build_type: "Release", - cc: "clang-11", - cxx: "clang++-11", + cc: "clang-14", + cxx: "clang++-14", generators: "Ninja", target: "all" } - { - name: "Ubuntu (GCC-9)", + name: "Ubuntu (GCC-11)", os: ubuntu-latest, build_type: "Release", - cc: "gcc-9", - cxx: "g++-9", + cc: "gcc-11", + cxx: "g++-11", generators: "Ninja", target: "all" } @@ -89,15 +89,13 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: - python-version: 3.8 - - - uses: seanmiddleditch/gha-setup-ninja@master + python-version: '3.10' - name: Print env run: | @@ -107,7 +105,7 @@ jobs: - name: Install dependencies on windows if: startsWith(matrix.config.os, 'windows') run: | - choco install cmake + choco install cmake ninja ninja --version cmake --version @@ -121,14 +119,14 @@ jobs: - name: Install dependencies on ubuntu if: runner.os == 'Linux' run: | - python -m pip install --upgrade cmake + python -m pip install --upgrade cmake ninja ninja --version cmake --version - name: Install dependencies on macos if: startsWith(matrix.config.os, 'macos') run: | - python -m pip install cmake + python -m pip install cmake ninja ninja --version cmake --version diff --git a/.github/workflows/test_matrix.yml b/.github/workflows/test_matrix.yml index 4381739d..def5bdef 100644 --- a/.github/workflows/test_matrix.yml +++ b/.github/workflows/test_matrix.yml @@ -31,29 +31,29 @@ jobs: config: - { name: "Windows (MSVC)", - os: windows-latest, + os: windows-2022, build_type: "Release", cc: "cl", cxx: "cl", - environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat", + environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat", generators: "Visual Studio 17 2022", target: "ALL_BUILD" } - { - name: "Ubuntu (Clang-10)", - os: ubuntu-latest, + name: "Ubuntu (Clang-14)", + os: ubuntu-22.04, build_type: "Release", - cc: "clang-10", - cxx: "clang++-10", + cc: "clang-14", + cxx: "clang++-14", generators: "Ninja", target: "all" } - { - name: "Ubuntu (GCC-9)", - os: ubuntu-latest, + name: "Ubuntu (GCC-11)", + os: ubuntu-22.04, build_type: "Release", - cc: "gcc-9", - cxx: "g++-9", + cc: "gcc-11", + cxx: "g++-11", generators: "Ninja", target: "all" } @@ -69,15 +69,13 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: - python-version: 3.8 - - - uses: seanmiddleditch/gha-setup-ninja@master + python-version: '3.10' - name: Print env run: | @@ -87,21 +85,21 @@ jobs: - name: Install dependencies on windows if: startsWith(matrix.config.os, 'windows') run: | - choco install cmake + choco install cmake ninja ninja --version cmake --version - name: Install dependencies on ubuntu if: runner.os == 'Linux' run: | - python -m pip install --upgrade cmake + python -m pip install --upgrade cmake ninja ninja --version cmake --version - name: Install dependencies on macos if: startsWith(matrix.config.os, 'macos') run: | - python -m pip install cmake + python -m pip install cmake ninja ninja --version cmake --version diff --git a/.github/workflows/test_numpy.yml b/.github/workflows/test_numpy.yml index 21a5a95c..c79fca7a 100644 --- a/.github/workflows/test_numpy.yml +++ b/.github/workflows/test_numpy.yml @@ -10,6 +10,7 @@ on: - unstable schedule: - cron: '0 23 * * 1' + workflow_dispatch: defaults: run: @@ -45,38 +46,49 @@ jobs: name: "Minimum Numpy version", os: ubuntu-latest, build_type: "Release", - cc: "gcc-9", - cxx: "g++-9", + cc: "gcc-11", + cxx: "g++-11", generators: "Ninja", target: "all", - numpy: "numpy==1.14.6" + numpy: "numpy==1.18.5", + python-version: "3.8" } - { name: "Latest Numpy version", os: ubuntu-latest, build_type: "Release", - cc: "gcc-9", - cxx: "g++-9", + cc: "gcc-11", + cxx: "g++-11", generators: "Ninja", target: "all", - numpy: "numpy>1.14.6" + numpy: "numpy", + python-version: "3.11" + } + - { + name: "Numpy v2", + os: ubuntu-latest, + build_type: "Release", + cc: "gcc-11", + cxx: "g++-11", + generators: "Ninja", + target: "all", + numpy: "numpy==2.0.0rc1", + python-version: "3.11" } steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: - python-version: 3.8 - - - uses: seanmiddleditch/gha-setup-ninja@master + python-version: ${{ matrix.config.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel - python -m pip install pytest cmake + python -m pip install pytest cmake ninja python -m pip install ${{ matrix.config.numpy }} sudo apt install -y libopenblas-dev ninja --version diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index a912520c..29385168 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -43,8 +43,8 @@ jobs: name: "Default settings", os: ubuntu-latest, build_type: "Debug", - cc: "gcc-9", - cxx: "g++-9", + cc: "gcc-11", + cxx: "g++-11", generators: "Ninja", target: "all", options: "" @@ -53,8 +53,8 @@ jobs: name: "Hard steal", os: ubuntu-latest, build_type: "Debug", - cc: "gcc-9", - cxx: "g++-9", + cc: "gcc-11", + cxx: "g++-11", generators: "Ninja", target: "all", options: "-DENABLE_CARMA_HARD_STEAL=ON" @@ -63,8 +63,8 @@ jobs: name: "Soft steal", os: ubuntu-latest, build_type: "Debug", - cc: "gcc-9", - cxx: "g++-9", + cc: "gcc-11", + cxx: "g++-11", generators: "Ninja", target: "all", options: "-DENABLE_CARMA_HARD_STEAL=ON" @@ -73,23 +73,21 @@ jobs: name: "Not own data", os: ubuntu-latest, build_type: "Debug", - cc: "gcc-9", - cxx: "g++-9", + cc: "gcc-11", + cxx: "g++-11", generators: "Ninja", target: "all", options: "-DENABLE_CARMA_DONT_REQUIRE_OWNDATA=ON" } steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: - python-version: 3.8 - - - uses: seanmiddleditch/gha-setup-ninja@master + python-version: '3.10' - name: Print env run: | @@ -98,7 +96,7 @@ jobs: - name: Install dependencies on ubuntu run: | - python -m pip install --upgrade cmake + python -m pip install --upgrade cmake ninja sudo apt install -y valgrind ninja --version cmake --version diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 1661ae0f..5c296531 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -37,7 +37,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.6", "3.7", "3.8", "3.9"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] config: - { name: "Windows (MSVC)", @@ -52,16 +52,14 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - uses: seanmiddleditch/gha-setup-ninja@master - - name: Print env run: | echo github.event.action: ${{ github.event.action }} @@ -69,7 +67,7 @@ jobs: - name: Install dependencies on windows run: | - choco install cmake + choco install cmake ninja ninja --version cmake --version diff --git a/.readthedocs.yml b/.readthedocs.yml index c9c61617..798ddae4 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,3 +1,13 @@ +version: 2 + +build: + os: ubuntu-22.04 + tools: + python: "3.8" + +sphinx: + configuration: docs/source/conf.py + python: - version: 3 -requirements_file: docs/requirements.txt + install: + - requirements: docs/requirements.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 460d959c..60a09dad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## [0.8.0] - 2024-06-12 + +### Changes + +* Adds support for Numpy v2 +* BREAKING Minimum Pybind11 version is 2.12.0 + +## [0.7.0] - 2024-03-27 + +### Changes + +* Update default Armadillo version to 12.8.x +* Update default Pybind11 version 2.11.1 + ## [0.6.6] - 2022-05-22 ### Changes diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 00000000..28d80d6c --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,10 @@ +cff-version: 1.2.0 +message: "If you use this software, please cite it as below." +authors: +- family-names: "Urlus" + given-names: "Ralph" +title: "CARMA: bidirectional conversions between Numpy and Armadillo" +version: 0.6.7 +doi: 10.5281/zenodo.7791193 +date-released: 2023-04-01 +url: "https://github.com/RUrlus/carma" diff --git a/CMakeLists.txt b/CMakeLists.txt index 94e768ea..51702e5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,228 +1,202 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.16) - -SET(CARMA_VERSION_MAJOR 0) -SET(CARMA_VERSION_MINOR 6) -SET(CARMA_VERSION_PATCH 6) -SET(CARMA_VERSION_INFO "${CARMA_VERSION_MAJOR}.${CARMA_VERSION_MINOR}.${CARMA_VERSION_PATCH}") - -PROJECT( - carma - VERSION ${CARMA_VERSION_INFO} - LANGUAGES CXX -) -INCLUDE(GNUInstallDirs) - -SET(CMAKE_MODULE_PATH_SAVED ${CMAKE_MODULE_PATH}) -LIST(INSERT CMAKE_MODULE_PATH 0 "${PROJECT_SOURCE_DIR}/cmake") -# ############################################################################## -# SETTINGS # -# ############################################################################## -OPTION(CARMA_INSTALL_LIB "Install CARMA headers" OFF) -SET(CARMA_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/carma") - -SET(DEFAULT_BUILD_TYPE "Release") +cmake_minimum_required(VERSION 3.16) + +set(CARMA_VERSION_MAJOR 0) +set(CARMA_VERSION_MINOR 8) +set(CARMA_VERSION_PATCH 0) +set(CARMA_VERSION_INFO + "${CARMA_VERSION_MAJOR}.${CARMA_VERSION_MINOR}.${CARMA_VERSION_PATCH}") + +project( + carma + VERSION ${CARMA_VERSION_INFO} + LANGUAGES CXX) +include(GNUInstallDirs) + +set(CMAKE_MODULE_PATH_SAVED ${CMAKE_MODULE_PATH}) +list(INSERT CMAKE_MODULE_PATH 0 "${PROJECT_SOURCE_DIR}/cmake") +# # # ############################################################################ +# SETTINGS # +# # # ############################################################################ +option(CARMA_INSTALL_LIB "Install CARMA headers" OFF) +set(CARMA_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/carma") + +set(DEFAULT_BUILD_TYPE "Release") # Set build type to Release if not specified -INCLUDE(BuildType) +include(BuildType) -IF (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - # workaround like https://github.com/nlohmann/json/issues/1408 - # to avoid error like: carma\...\include\armadillo_bits/arma_str.hpp(194): - # error C2039: '_snprintf': is not a member of 'std' - ADD_DEFINITIONS(-DHAVE_SNPRINTF) -ENDIF () +if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + # workaround like https://github.com/nlohmann/json/issues/1408 to avoid error + # like: carma\...\include\armadillo_bits/arma_str.hpp(194): error C2039: + # '_snprintf': is not a member of 'std' + add_definitions(-DHAVE_SNPRINTF) +endif() -OPTION(CARMA_DEV_MODE "Enable additional definitions for development" OFF) -OPTION(CARMA_DEV_DEBUG_MODE "Turn on all debugging definitions" OFF) -OPTION(CARMA_BUILD_TESTS "Build tests for carma" OFF) -OPTION(CARMA_BUILD_EXAMPLES "Build examples for carma" OFF) +option(CARMA_DEV_MODE "Enable additional definitions for development" OFF) +option(CARMA_DEV_DEBUG_MODE "Turn on all debugging definitions" OFF) +option(CARMA_BUILD_TESTS "Build tests for carma" OFF) +option(CARMA_BUILD_EXAMPLES "Build examples for carma" OFF) # collect user settable options -INCLUDE(${PROJECT_SOURCE_DIR}/carma_config.cmake) -INCLUDE(ParseOptions) -CONFIGURE_FILE( - ${PROJECT_SOURCE_DIR}/include/carma_bits/config.h.in - ${PROJECT_BINARY_DIR}/include/carma_bits/generated_config.h - @ONLY -) - -# ############################################################################## -# TARGET # -# ############################################################################## -ADD_LIBRARY(carma INTERFACE) -ADD_LIBRARY(carma::carma ALIAS carma) - -TARGET_COMPILE_DEFINITIONS(carma - INTERFACE - CARMA_USE_GENERATED_CONFIG=1 - CARMA_VERSION_MAJOR=${CARMA_VERSION_MAJOR} - CARMA_VERSION_MINOR=${CARMA_VERSION_MINOR} - CARMA_VERSION_PATCH=${CARMA_VERSION_PATCH} - CARMA_VERSION_NAME=${CARMA_VERSION_INFO} - "$<$:${CARMA_RELEASE_DEFINITIONS}>" -) -TARGET_COMPILE_FEATURES(carma INTERFACE cxx_std_14) - -IF(CARMA_DEV_MODE) - TARGET_COMPILE_OPTIONS(carma - INTERFACE - -Wall - -Wextra - -Wunused-variable - -Wunused-const-variable - ) -ENDIF() - -TARGET_INCLUDE_DIRECTORIES(carma - INTERFACE - $ - $ - $ -) - -TARGET_LINK_LIBRARIES(carma - INTERFACE - armadillo::armadillo - Python3::NumPy - Python3::Module - pybind11::pybind11 -) - -ADD_LIBRARY(carma_headers INTERFACE) -ADD_LIBRARY(carma::headers ALIAS carma_headers) - -TARGET_COMPILE_DEFINITIONS(carma_headers - INTERFACE - CARMA_VERSION_MAJOR=${CARMA_VERSION_MAJOR} - CARMA_VERSION_MINOR=${CARMA_VERSION_MINOR} - CARMA_VERSION_PATCH=${CARMA_VERSION_PATCH} - CARMA_VERSION_NAME=${CARMA_VERSION_INFO} -) -TARGET_COMPILE_FEATURES(carma_headers INTERFACE cxx_std_14) - -TARGET_INCLUDE_DIRECTORIES(carma_headers - INTERFACE - $ - $ - $ -) - +include(${PROJECT_SOURCE_DIR}/carma_config.cmake) +include(ParseOptions) +configure_file( + ${PROJECT_SOURCE_DIR}/include/carma_bits/config.h.in + ${PROJECT_BINARY_DIR}/include/carma_bits/generated_config.h @ONLY) + +# # # ############################################################################ +# TARGET # +# # # ############################################################################ +add_library(carma INTERFACE) +add_library(carma::carma ALIAS carma) + +target_compile_definitions( + carma + INTERFACE CARMA_USE_GENERATED_CONFIG=1 + CARMA_VERSION_MAJOR=${CARMA_VERSION_MAJOR} + CARMA_VERSION_MINOR=${CARMA_VERSION_MINOR} + CARMA_VERSION_PATCH=${CARMA_VERSION_PATCH} + CARMA_VERSION_NAME=${CARMA_VERSION_INFO} + "$<$:${CARMA_RELEASE_DEFINITIONS}>") +target_compile_features(carma INTERFACE cxx_std_14) + +if(CARMA_DEV_MODE) + target_compile_options(carma INTERFACE -Wall -Wextra -Wunused-variable + -Wunused-const-variable) +endif() + +target_include_directories( + carma + INTERFACE $ + $ + $) + +target_link_libraries(carma INTERFACE armadillo::armadillo Python3::NumPy + Python3::Module pybind11::pybind11) + +add_library(carma_headers INTERFACE) +add_library(carma::headers ALIAS carma_headers) + +target_compile_definitions( + carma_headers + INTERFACE CARMA_VERSION_MAJOR=${CARMA_VERSION_MAJOR} + CARMA_VERSION_MINOR=${CARMA_VERSION_MINOR} + CARMA_VERSION_PATCH=${CARMA_VERSION_PATCH} + CARMA_VERSION_NAME=${CARMA_VERSION_INFO}) +target_compile_features(carma_headers INTERFACE cxx_std_14) + +target_include_directories( + carma_headers + INTERFACE $ + $ + $) # Only install the headers -IF (CARMA_INSTALL_LIB) - # modified from https://dominikberner.ch/cmake-interface-lib/ - - # locations are provided by GNUInstallDirs - INSTALL( - TARGETS carma - EXPORT carma_Targets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ) - - INSTALL( - TARGETS carma_headers - EXPORT carma_Header_Targets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ) - - INCLUDE(CMakePackageConfigHelpers) - write_basic_package_version_file( - "carmaConfigVersion.cmake" - VERSION ${PROJECT_VERSION} - COMPATIBILITY SameMinorVersion - ) - - configure_package_config_file( - "${PROJECT_SOURCE_DIR}/cmake/carmaConfig.cmake.in" - "${PROJECT_BINARY_DIR}/carmaConfig.cmake" - INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/carma/cmake - ) - - INSTALL( - EXPORT carma_Targets - FILE carmaCarmaTargets.cmake - NAMESPACE carma:: - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/carma/cmake - ) - - INSTALL( - EXPORT carma_Header_Targets - FILE carmaHeaderTargets.cmake - NAMESPACE carma:: - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/carma/cmake - ) - - INSTALL( - FILES - "${PROJECT_BINARY_DIR}/carmaConfig.cmake" - "${PROJECT_BINARY_DIR}/carmaConfigVersion.cmake" - "${PROJECT_SOURCE_DIR}/cmake/carmaDependencyTargets.cmake" - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/carma/cmake - ) - - INSTALL( - FILES "${PROJECT_SOURCE_DIR}/include/carma" - DESTINATION ${CARMA_INCLUDE_INSTALL_DIR} - ) - - INSTALL( - DIRECTORY ${PROJECT_SOURCE_DIR}/include/carma_bits - DESTINATION ${CARMA_INCLUDE_INSTALL_DIR} - FILES_MATCHING - PATTERN "*.h" - ) - - INSTALL( - FILES ${PROJECT_BINARY_DIR}/include/carma_bits/generated_config.h - DESTINATION ${CARMA_INCLUDE_INSTALL_DIR}/carma_bits - ) - -ELSE() - # ############################################################################## - # REQUIREMENTS # - # ############################################################################## - FIND_PACKAGE(Python3 COMPONENTS Development NumPy QUIET) - IF (NOT Python3_FOUND) - FIND_PACKAGE(Python3 COMPONENTS Development.Module NumPy REQUIRED) - ENDIF() - - # Needed to ensure the same Python executable is found by Pybind11 - IF (NOT DEFINED PYTHON_EXECUTABLE) - SET(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) - ENDIF () - - # create armadillo and or pybind11 target if not defined - INCLUDE(ThirdPartyTargets) - - TARGET_PRECOMPILE_HEADERS(carma - INTERFACE - ${PROJECT_SOURCE_DIR}/include/carma_bits/cnalloc.h - ) -ENDIF() -# ############################################################################## -# TEST TARGETS # -# ############################################################################## - -IF(CARMA_BUILD_TESTS OR CARMA_BUILD_EXAMPLES) - SET(CMAKE_CXX_STANDARD 14) -ENDIF() - -IF(CARMA_BUILD_TESTS) - INCLUDE(CTest) - ENABLE_TESTING() - INCLUDE(GetCatch2) - ADD_SUBDIRECTORY(tests) - INCLUDE(ClangFormatTarget) - INCLUDE(CoverageTarget) -ENDIF() - -IF(CARMA_BUILD_EXAMPLES) - ADD_SUBDIRECTORY(examples) -ENDIF() -#------------------------------------------------------ -INCLUDE(ClearOptions) -SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH_SAVED}) -UNSET(CMAKE_MODULE_PATH_SAVED) +if(CARMA_INSTALL_LIB) + # modified from https://dominikberner.ch/cmake-interface-lib/ + + # locations are provided by GNUInstallDirs + install( + TARGETS carma + EXPORT carma_Targets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + install( + TARGETS carma_headers + EXPORT carma_Header_Targets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + include(CMakePackageConfigHelpers) + write_basic_package_version_file( + "carmaConfigVersion.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMinorVersion) + + configure_package_config_file( + "${PROJECT_SOURCE_DIR}/cmake/carmaConfig.cmake.in" + "${PROJECT_BINARY_DIR}/carmaConfig.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/carma/cmake) + + install( + EXPORT carma_Targets + FILE carmaCarmaTargets.cmake + NAMESPACE carma:: + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/carma/cmake) + + install( + EXPORT carma_Header_Targets + FILE carmaHeaderTargets.cmake + NAMESPACE carma:: + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/carma/cmake) + + install( + FILES "${PROJECT_BINARY_DIR}/carmaConfig.cmake" + "${PROJECT_BINARY_DIR}/carmaConfigVersion.cmake" + "${PROJECT_SOURCE_DIR}/cmake/carmaDependencyTargets.cmake" + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/carma/cmake) + + install(FILES "${PROJECT_SOURCE_DIR}/include/carma" + DESTINATION ${CARMA_INCLUDE_INSTALL_DIR}) + + install( + DIRECTORY ${PROJECT_SOURCE_DIR}/include/carma_bits + DESTINATION ${CARMA_INCLUDE_INSTALL_DIR} + FILES_MATCHING + PATTERN "*.h") + + install(FILES ${PROJECT_BINARY_DIR}/include/carma_bits/generated_config.h + DESTINATION ${CARMA_INCLUDE_INSTALL_DIR}/carma_bits) + +else() + # # # ########################################################################## + # REQUIREMENTS # + # # # ########################################################################## + find_package( + Python3 + COMPONENTS Development NumPy + QUIET) + if(NOT Python3_FOUND) + find_package( + Python3 + COMPONENTS Development.Module NumPy + REQUIRED) + endif() + + # Needed to ensure the same Python executable is found by Pybind11 + if(NOT DEFINED PYTHON_EXECUTABLE) + set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) + endif() + + # create armadillo and or pybind11 target if not defined + include(ThirdPartyTargets) + + target_precompile_headers(carma INTERFACE + ${PROJECT_SOURCE_DIR}/include/carma_bits/cnalloc.h) +endif() +# # # ############################################################################ +# TEST TARGETS # +# # # ############################################################################ + +if(CARMA_BUILD_TESTS OR CARMA_BUILD_EXAMPLES) + set(CMAKE_CXX_STANDARD 14) +endif() + +if(CARMA_BUILD_TESTS) + include(CTest) + enable_testing() + include(GetCatch2) + add_subdirectory(tests) + include(ClangFormatTarget) + include(CoverageTarget) +endif() + +if(CARMA_BUILD_EXAMPLES) + add_subdirectory(examples) +endif() +# ------------------------------------------------------ +include(ClearOptions) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH_SAVED}) +unset(CMAKE_MODULE_PATH_SAVED) diff --git a/README.md b/README.md index 6b76395b..36c9be66 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ [![Documentation Status](https://readthedocs.org/projects/carma/badge/?version=latest)](https://carma.readthedocs.io/en/latest/?badge=latest) [![License](https://img.shields.io/github/license/RUrlus/carma)](https://github.com/RUrlus/carma/blob/stable/LICENSE) [![Release](https://img.shields.io/github/v/release/rurlus/carma)](https://github.com/RUrlus/carma/releases) +[![DOI](https://zenodo.org/badge/235867993.svg)](https://zenodo.org/badge/latestdoi/235867993) + ## Introduction @@ -68,11 +70,18 @@ CARMA provides a number of configurations that can be set in the `carma_config.c ## Requirements -CARMA >= v0.5 requires a compiler with support for C++14 and supports: +Numpy v2.* is supported by CARMA >= v0.8.0 which requires a compiler with support for C++14 and supports: -* Python 3.6 -- 3.9 +* Python 3.8 -- 3.12 * Numpy >= 1.14 -* Pybind11 >= v2.6.0 +* **Pybind11 >= v2.12.0** +* Armadillo >= 10.5.2 + +CARMA <= v0.7 requires a compiler with support for C++14 and supports: + +* Python 3.8 -- 3.12 +* **Numpy >= 1.14 < 2.0** +* **Pybind11 >= v2.6.0 < v2.12.0** * Armadillo >= 10.5.2 CARMA makes use of Armadillo's `ARMA_ALIEN_MEM_ALLOC` and `ARMA_ALIEN_MEM_FREE` functionality introduced in version 10.5.2 to use Numpy's (de)allocator. diff --git a/cmake/ClearOptions.cmake b/cmake/ClearOptions.cmake index d7321a58..2427e1cd 100644 --- a/cmake/ClearOptions.cmake +++ b/cmake/ClearOptions.cmake @@ -1,3 +1,6 @@ +IF (CARMA_DEV_MODE OR CARMA_DEV_DEBUG_MODE) + UNSET(CMAKE_INSTALL_PREFIX CACHE) +ENDIF() UNSET(CARMA_DEV_DEBUG_MODE CACHE) UNSET(CARMA_BUILD_TESTS CACHE) UNSET(ENABLE_CARMA_EXTRA_DEBUG CACHE) @@ -5,7 +8,6 @@ UNSET(ENABLE_CARMA_SOFT_STEAL CACHE) UNSET(ENABLE_CARMA_HARD_STEAL CACHE) UNSET(ENABLE_CARMA_DONT_REQUIRE_OWNDATA CACHE) UNSET(ENABLE_CARMA_DONT_REQUIRE_F_CONTIGUOUS CACHE) -#UNSET(CMAKE_INSTALL_PREFIX CACHE) #SET(CMAKE_EXPORT_COMPILE_COMMANDS 0) UNSET(BUILD_NATIVE_TESTS CACHE) UNSET(BUILD_PYTHON_TESTS CACHE) diff --git a/cmake/GetArmadillo.cmake b/cmake/GetArmadillo.cmake index 218082fe..2dbb2c5b 100644 --- a/cmake/GetArmadillo.cmake +++ b/cmake/GetArmadillo.cmake @@ -1,12 +1,12 @@ include(FetchContent) -SET(DEFAULT_ARMA_VERSION 11.1.x) +SET(DEFAULT_ARMA_VERSION 12.8.x) IF (NOT USE_ARMA_VERSION) MESSAGE(STATUS "carma: Setting Armadillo version to 'v${DEFAULT_ARMA_VERSION}' as none was specified.") SET(USE_ARMA_VERSION "${DEFAULT_ARMA_VERSION}" CACHE STRING "Choose the version of Armadillo." FORCE) # Set the possible values of build type for cmake-gui SET_PROPERTY(CACHE USE_ARMA_VERSION PROPERTY STRINGS - "10.6.x" "10.8.x" "11.1.x" + "10.6.x" "10.8.x" "11.2.x" "11.4.x" "12.4.x" "12.6.x" "12.8.x" ) ENDIF () diff --git a/cmake/GetPybind11.cmake b/cmake/GetPybind11.cmake index 9df241e8..bbfb1576 100644 --- a/cmake/GetPybind11.cmake +++ b/cmake/GetPybind11.cmake @@ -1,12 +1,12 @@ include(FetchContent) -SET(DEFAULT_PYBIND11_VERSION v2.9.2) +SET(DEFAULT_PYBIND11_VERSION v2.12.0) IF (NOT USE_PYBIND11_VERSION) - MESSAGE(STATUS "carma: Setting Pybind11 version to '${DEFAULT_PYBIND11_VERSION}' as none was specified.") - SET(USE_PYBIND11_VERSION "${DEFAULT_PYBIND11_VERSION}" CACHE STRING "Choose the version of Pybind11." FORCE) + MESSAGE(STATUS "carma: Setting Pybind11 version to '${DEFAULT_PYBIND11_VERSION}' as none was specified.") + SET(USE_PYBIND11_VERSION "${DEFAULT_PYBIND11_VERSION}" CACHE STRING "Choose the version of Pybind11." FORCE) # Set the possible values of build type for cmake-gui SET_PROPERTY(CACHE USE_PYBIND11_VERSION PROPERTY STRINGS - "v2.6.0" "v2.6.1" "v2.6.2" "v2.7.1" "v2.8.1" "v2.9.0" "v2.9.1" "v2.9.2" + "v2.12.0" ) ENDIF () diff --git a/docs/source/conf.py b/docs/source/conf.py index 32226cdc..83ae9208 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -11,18 +11,19 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. import os import sys -sys.path.insert(0, os.path.abspath('../')) + +sys.path.insert(0, os.path.abspath("../")) sys.setrecursionlimit(1500) # -- Project information ----------------------------------------------------- -project = 'carma' -copyright = '2020, R. Urlus' -author = 'R. Urlus' +project = "carma" +copyright = "2020, R. Urlus" +author = "R. Urlus" # The full version, including alpha/beta/rc tags -release = '0.6.0' +release = "0.8.0" # -- General configuration --------------------------------------------------- @@ -31,16 +32,16 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.doctest', - 'sphinx.ext.coverage', - 'sphinx.ext.ifconfig', - 'sphinxcontrib.napoleon', - 'sphinx.ext.autosectionlabel', + "sphinx.ext.autodoc", + "sphinx.ext.doctest", + "sphinx.ext.coverage", + "sphinx.ext.ifconfig", + "sphinxcontrib.napoleon", + "sphinx.ext.autosectionlabel", ] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -54,11 +55,10 @@ # a list of builtin themes. # import sphinx_rtd_theme + html_theme = "sphinx_rtd_theme" html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] -html_theme_options = { - 'logo_only': True -} +html_theme_options = {"logo_only": True} html_logo = "carma_logo.png" html_show_sourcelink = True @@ -66,6 +66,6 @@ # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = [] -master_doc = 'index' +master_doc = "index" # -- Extension configuration ------------------------------------------------- diff --git a/include/carma b/include/carma index df46c33d..83341324 100644 --- a/include/carma +++ b/include/carma @@ -20,6 +20,14 @@ #include +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning( \ + disable : 4127) // warning C4127: Conditional expression is constant +#include +typedef SSIZE_T ssize_t; +#endif + #if defined(CARMA_ARMA_ALIEN_MEM_FUNCTIONS_SET) #if (defined(ARMA_ALIEN_MEM_ALLOC_FUNCTION) && !defined(ARMA_ALIEN_MEM_FREE_FUNCTION)) || (!defined(ARMA_ALIEN_MEM_ALLOC_FUNCTION) && defined(ARMA_ALIEN_MEM_FREE_FUNCTION)) #error "carma: ARMA_ALIEN_MEM_ALLOC_FUNCTION and or ARMA_ALIEN_MEM_FREE_FUNCTION not set while CARMA_ARMA_ALIEN_MEM_FUNCTIONS_SET is" @@ -33,9 +41,9 @@ #ifndef CARMA_VERSION_MAJOR #define CARMA_VERSION_MAJOR 0 - #define CARMA_VERSION_MINOR 6 - #define CARMA_VERSION_PATCH 6 - #define CARMA_VERSION_NAME "0.6.6 HO" + #define CARMA_VERSION_MINOR 8 + #define CARMA_VERSION_PATCH 0 + #define CARMA_VERSION_NAME "0.8.0 HO" #endif namespace carma { diff --git a/include/carma_bits/converters.h b/include/carma_bits/converters.h index b8a865c6..dea7d377 100644 --- a/include/carma_bits/converters.h +++ b/include/carma_bits/converters.h @@ -685,6 +685,31 @@ inline py::array_t to_numpy(armaT* src, int copy = 0) { return details::construct_array(data); } /* to_numpy */ +template = 4> +inline py::array_t to_numpy(armaT& src, int copy = 0) { + // if not copy we steal + armaT* data; + if (!copy) { + data = new armaT(std::move(src)); + } else { + data = new armaT(src.memptr()); + } + return details::construct_array(data); +} /* to_numpy */ + +template = 4> +inline py::array_t to_numpy(armaT* src, int copy = 0) { + // if not copy we steal + armaT* data; + if (!copy) { + data = new armaT(std::move(*src)); + } else { + data = new armaT(src->memptr()); + } + return details::construct_array(data); +} /* to_numpy */ + + /* ---------------------------------- to_numpy_view ---------------------------------- */ template inline py::array_t to_numpy_view(const armaT& src) { diff --git a/include/carma_bits/numpyapi.h b/include/carma_bits/numpyapi.h index 01c74cd7..c3be0d96 100644 --- a/include/carma_bits/numpyapi.h +++ b/include/carma_bits/numpyapi.h @@ -58,32 +58,41 @@ struct npy_api { API_PyArray_Free = 165, API_PyArray_Size = 59, API_PyArray_NewCopy = 85, - API_PyArray_CopyInto = 82, + // PyArray_CopyInto moved in the numpy C-API table between the 1.x and 2.x + // ABI (82 -> 50); the two other functions kept their slot. + API_PyArray_CopyInto_v1 = 82, + API_PyArray_CopyInto_v2 = 50, API_PyArray_NewLikeArray = 277, API_PyArray_NewFromDescr = 94, API_PyDataMem_NEW = 288, API_PyDataMem_FREE = 289, }; + static int copy_into_index() { + py::str version_str = py::module_::import("numpy").attr("__version__"); + int major = std::atoi(std::string(version_str).c_str()); + return major >= 2 ? API_PyArray_CopyInto_v2 : API_PyArray_CopyInto_v1; + } + static npy_api lookup() { - py::module m = py::module::import("numpy.core.multiarray"); + pybind11::module_ m = pybind11::detail::import_numpy_core_submodule("multiarray"); auto c = m.attr("_ARRAY_API"); -#if PY_MAJOR_VERSION >= 3 - void **api_ptr = reinterpret_cast(PyCapsule_GetPointer(c.ptr(), nullptr)); -#else - void **api_ptr = reinterpret_cast(PyCObject_AsVoidPtr(c.ptr())); -#endif + void** api_ptr = (void**)PyCapsule_GetPointer(c.ptr(), nullptr); + if (api_ptr == nullptr) { + pybind11::raise_from(PyExc_SystemError, "FAILURE obtaining numpy _ARRAY_API pointer."); + throw pybind11::error_already_set(); + } npy_api api; #define DECL_NPY_API(Func) api.Func##_ = (decltype(api.Func##_)) api_ptr[API_##Func]; DECL_NPY_API(PyArray_Free); DECL_NPY_API(PyArray_Size); DECL_NPY_API(PyArray_NewCopy); - DECL_NPY_API(PyArray_CopyInto); DECL_NPY_API(PyArray_NewLikeArray); DECL_NPY_API(PyArray_NewFromDescr); DECL_NPY_API(PyDataMem_NEW); DECL_NPY_API(PyDataMem_FREE); #undef DECL_NPY_API + api.PyArray_CopyInto_ = (decltype(api.PyArray_CopyInto_)) api_ptr[copy_into_index()]; return api; } }; diff --git a/include/carma_bits/typecheck.h b/include/carma_bits/typecheck.h index a0b63e5b..0807c0db 100644 --- a/include/carma_bits/typecheck.h +++ b/include/carma_bits/typecheck.h @@ -34,7 +34,10 @@ using is_Vec = std::enable_if_t::value, int>; template using is_Mat = std::enable_if_t::value, int>; template -using is_Mat_only = std::enable_if_t::value, int>; +using is_Mat_only = std::enable_if_t< arma::is_Mat_only::value && + !arma::is_Mat_fixed_only::value, int>; +template +using is_Mat_fixed_only = std::enable_if_t::value, int>; template struct is_mat : std::false_type {}; diff --git a/integration_test/CMakeLists.txt b/integration_test/CMakeLists.txt index 665d96b4..0698e7f5 100644 --- a/integration_test/CMakeLists.txt +++ b/integration_test/CMakeLists.txt @@ -11,7 +11,7 @@ SET(MODNAME "integration_test_carma") # -- EXTERNAL INCLUDE(FetchContent) -SET(USE_PYBIND11_VERSION "v2.6.2") +SET(USE_PYBIND11_VERSION v2.12.0) # Pybind11 FetchContent_Declare( @@ -25,14 +25,14 @@ FetchContent_GetProperties(Pybind11Repo) STRING(TOLOWER "Pybind11Repo" lcName) IF (NOT ${lcName}_POPULATED) - MESSAGE(STATUS "carma: collecting Pybind11 ${USE_PYBIND11_VERSION}") - # Fetch the content using previously declared details - FetchContent_Populate(Pybind11Repo) + MESSAGE(STATUS "carma: collecting Pybind11 ${USE_PYBIND11_VERSION}") + # Fetch the content using previously declared details + FetchContent_Populate(Pybind11Repo) ENDIF () ADD_SUBDIRECTORY(extern/pybind11) -SET(USE_ARMA_VERSION 10.6.x) +SET(USE_ARMA_VERSION 12.8.x) FetchContent_Declare( CarmaArmadillo GIT_REPOSITORY https://gitlab.com/conradsnicta/armadillo-code.git