Skip to content

Python: replace pybind11 with nanobind #2372

Python: replace pybind11 with nanobind

Python: replace pybind11 with nanobind #2372

Workflow file for this run

name: CI
on:
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
ci:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# - name: 'Windows static library'
# os: windows-latest
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: OFF
# python_unit_testing: OFF
# shared_libs: OFF
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# - name: 'Windows shared library'
# os: windows-latest
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: OFF
# python_unit_testing: OFF
# shared_libs: ON
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# - name: 'Linux static library'
# os: ubuntu-latest
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: OFF
# python_unit_testing: OFF
# shared_libs: OFF
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# - name: 'Linux shared library'
# os: ubuntu-latest
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: OFF
# python_unit_testing: OFF
# shared_libs: ON
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# - name: 'macOS static library (Intel)'
# os: macos-13
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: OFF
# python_unit_testing: OFF
# shared_libs: OFF
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# - name: 'macOS shared library (Intel)'
# os: macos-13
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: OFF
# python_unit_testing: OFF
# shared_libs: ON
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# - name: 'macOS static library (ARM)'
# os: macos-latest
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: OFF
# python_unit_testing: OFF
# shared_libs: OFF
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# - name: 'macOS shared library (ARM)'
# os: macos-latest
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: OFF
# python_unit_testing: OFF
# shared_libs: ON
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# - name: 'JavaScript bindings'
# os: macos-latest
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: ON
# javascript_unit_testing: ON
# memory_checks: OFF
# python_bindings: OFF
# python_unit_testing: OFF
# shared_libs: OFF
# unit_testing: OFF
# target: javascript_unit_testing
# - name: 'Windows Python bindings'
# os: windows-latest
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: ON
# python_unit_testing: ON
# shared_libs: OFF
# unit_testing: OFF
# target: python_unit_testing
# pip_install_test_and_uninstall: ON
- name: 'Linux Python bindings'
os: ubuntu-latest
build_type: Release
code_analysis: OFF
code_coverage: OFF
documentation: OFF
javascript_bindings: OFF
javascript_unit_testing: OFF
memory_checks: OFF
python_bindings: ON
python_unit_testing: ON
shared_libs: OFF
unit_testing: OFF
target: python_unit_testing
pip_install_test_and_uninstall: ON
# - name: 'macOS Python bindings (Intel)'
# os: macos-13
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: ON
# python_unit_testing: ON
# shared_libs: OFF
# unit_testing: OFF
# context: PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH
# target: python_unit_testing
# pip_install_prerequisites: sudo pip3 install cmake scikit-build
# pip_install_test_and_uninstall: ON
# - name: 'macOS Python bindings (ARM)'
# os: macos-latest
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: ON
# python_unit_testing: ON
# shared_libs: OFF
# unit_testing: OFF
# context: PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH
# target: python_unit_testing
# pip_install_prerequisites: sudo pip3 install cmake scikit-build
# pip_install_test_and_uninstall: ON
# - name: 'Code formatting'
# os: ubuntu-latest
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: OFF
# python_unit_testing: OFF
# shared_libs: OFF
# unit_testing: OFF
# context: PATH=$GITHUB_WORKSPACE:$PATH
# target: check_code_formatting
# - name: 'JavaScript code formatting'
# os: macos-latest
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: OFF
# python_unit_testing: OFF
# shared_libs: OFF
# unit_testing: OFF
# target: javascript_check_code_formatting
# - name: 'Python code formatting'
# os: ubuntu-latest
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: OFF
# python_unit_testing: OFF
# shared_libs: OFF
# unit_testing: OFF
# target: python_check_code_formatting
# - name: 'Code analysis'
# os: ubuntu-latest
# build_type: Release
# code_analysis: ON
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: OFF
# python_unit_testing: OFF
# shared_libs: OFF
# unit_testing: ON
# context: PATH=$GITHUB_WORKSPACE:$PATH CC=/usr/local/bin/clang CXX=/usr/local/bin/clang++
# - name: 'Code coverage'
# os: macos-latest
# build_type: Release
# code_analysis: OFF
# code_coverage: ON
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: OFF
# python_unit_testing: OFF
# shared_libs: ON
# unit_testing: ON
# context: PATH=/opt/homebrew/opt/llvm/bin:$PATH CC=/opt/homebrew/opt/llvm/bin/clang CXX=/opt/homebrew/opt/llvm/bin/clang++
# target: code_coverage
# - name: 'Memory checks'
# os: ubuntu-latest
# build_type: Debug
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: ON
# python_bindings: OFF
# python_unit_testing: OFF
# shared_libs: ON
# unit_testing: ON
# target: memory_checks
# - name: 'Documentation'
# os: ubuntu-latest
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: ON
# javascript_bindings: OFF
# javascript_unit_testing: OFF
# memory_checks: OFF
# python_bindings: OFF
# python_unit_testing: OFF
# shared_libs: OFF
# unit_testing: OFF
# target: documentation
env:
BUILDCACHE_ACCURACY: STRICT
BUILDCACHE_COMPRESS_FORMAT: ZSTD
BUILDCACHE_DEBUG: -1
BUILDCACHE_LOG_FILE: ""
DOXYGEN_VERSION: 1.9.3
LLVMCLANG_VERSION: 18.1.8
steps:
- name: Check out libOpenCOR
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install CMake and Ninja
uses: lukka/get-cmake@latest
- name: Install buildcache
uses: cscouto/buildcache-action@v1
with:
cache_key: ${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.code_analysis }}-${{ matrix.code_coverage }}-${{ matrix.documentation }}-${{ matrix.javascript_bindings }}-${{ matrix.javascript_unit_testing }}-${{ matrix.memory_checks }}-${{ matrix.python_bindings }}-${{ matrix.python_unit_testing }}-${{ matrix.shared_libs }}-${{ matrix.unit_testing }}-${{ matrix.target }}
- name: Configure MSVC
if: ${{ runner.os == 'Windows' }}
uses: ilammy/msvc-dev-cmd@v1
- name: Install LLVM
if: ${{ matrix.code_coverage == 'ON' }}
run: |
brew install --overwrite llvm
brew info llvm
- name: Install Clang
if: ${{ matrix.code_analysis == 'ON' }}
run: |
wget https://github.com/opencor/gha/releases/download/gha/clang.${LLVMCLANG_VERSION}.linux.tar.gz -O - | tar -xz
sudo mv clang /usr/local/bin
sudo cp /usr/local/bin/clang /usr/local/bin/clang++
wget https://github.com/opencor/gha/releases/download/gha/clang-include.${LLVMCLANG_VERSION}.linux.tar.gz -O - | tar -xz
sudo mv include/* /usr/local/include
- name: Install ClangFormat
if: ${{ matrix.target == 'check_code_formatting' }}
run: |
wget https://github.com/opencor/gha/releases/download/gha/clang-format.${LLVMCLANG_VERSION}.linux.tar.gz -O - | tar -xz
sudo mv clang-format /usr/local/bin
- name: Install Clang-Tidy
if: ${{ matrix.name == 'Code analysis' }}
run: |
wget https://github.com/opencor/gha/releases/download/gha/clang-tidy.${LLVMCLANG_VERSION}.linux.tar.gz -O - | tar -xz
sudo mv clang-tidy /usr/local/bin
- name: Install Emscripten
if: ${{ matrix.javascript_unit_testing == 'ON' }}
run: brew install --overwrite emscripten
- name: Install Prettier
if: ${{ matrix.target == 'javascript_check_code_formatting' }}
run: brew install --overwrite prettier
- name: Install Black
if: ${{ matrix.target == 'python_check_code_formatting' }}
run: pip3 install black
- name: Install Valgrind
if: ${{ matrix.memory_checks == 'ON' }}
run: |
sudo apt update
sudo apt install valgrind
- name: Install pytest and pytest-html
if: ${{ matrix.python_unit_testing == 'ON' }}
run: pip3 install pytest pytest-html
- name: Install Sphinx and some Sphinx packages
if: ${{ matrix.documentation == 'ON' }}
run: pip3 install sphinx sphinx-copybutton sphinx-inline-tabs
- name: Install Doxygen
if: ${{ matrix.documentation == 'ON' }}
run: |
wget https://github.com/opencor/gha/releases/download/gha/doxygen.${DOXYGEN_VERSION}.linux.tar.gz -O - | tar -xz
sudo mv doxygen /usr/local/bin
- name: Configure libOpenCOR
run: |
mkdir build
cd build
${{ matrix.context }} cmake -G Ninja -DBUILD_TYPE=${{ matrix.build_type }} -DCODE_ANALYSIS=${{ matrix.code_analysis }} -DCODE_COVERAGE=${{ matrix.code_coverage }} -DDOCUMENTATION=${{ matrix.documentation }} -DINSTALL_PREFIX=${{ github.workspace }}/install -DJAVASCRIPT_BINDINGS=${{ matrix.javascript_bindings }} -DJAVASCRIPT_UNIT_TESTING=${{ matrix.javascript_unit_testing }} -DMEMORY_CHECKS=${{ matrix.memory_checks }} -DPYTHON_BINDINGS=${{ matrix.python_bindings }} -DPYTHON_UNIT_TESTING=${{ matrix.python_unit_testing }} -DSHARED_LIBS=${{ matrix.shared_libs }} -DUNIT_TESTING=${{ matrix.unit_testing }} ..
- name: Build libOpenCOR
if: ${{ (matrix.unit_testing == 'ON') || (matrix.javascript_unit_testing == 'ON') || (matrix.code_analysis == 'OFF') || (matrix.code_coverage == 'OFF') || (matrix.memory_checks == 'OFF') }}
run: |
cd build
ninja
- name: Unit testing
if: ${{ (matrix.unit_testing == 'ON') && (matrix.code_analysis == 'OFF') && (matrix.code_coverage == 'OFF') && (matrix.memory_checks == 'OFF') }}
run: |
cd build
ninja ${{ matrix.target }}
- name: JavaScript unit testing
if: ${{ matrix.javascript_unit_testing == 'ON' }}
run: |
cd build
ninja ${{ matrix.target }}
- name: Python unit testing
if: ${{ matrix.python_unit_testing == 'ON' }}
run: |
cd build
ninja ${{ matrix.target }}
- name: Python unit testing report
if: ${{ matrix.python_unit_testing == 'ON' }}
run: |
cd build
ninja ${{ matrix.target }}_report
- name: Code formatting
if: ${{ matrix.target == 'check_code_formatting' }}
run: |
cd build
ninja ${{ matrix.target }}
- name: JavaScript code formatting
if: ${{ matrix.target == 'javascript_check_code_formatting' }}
run: |
cd build
ninja ${{ matrix.target }}
- name: Python code formatting
if: ${{ matrix.target == 'python_check_code_formatting' }}
run: |
cd build
ninja ${{ matrix.target }}
- name: Code analysis
if: ${{ matrix.name == 'Code analysis' }}
run: |
cd build
ninja
- name: Coverage
if: ${{ matrix.code_coverage == 'ON' }}
run: |
cd build
ninja ${{ matrix.target }}
if [ `ninja ${{ matrix.target }} | grep TOTAL | sed 's/ /\n/g' | grep "100.00%" | wc -l | sed 's/ //g'` -eq 4 ]; then exit 0; else exit 1; fi
- name: Coverage report
if: ${{ matrix.code_coverage == 'ON' }}
run: |
cd build
ninja ${{ matrix.target }}_report
- name: Memory checks
if: ${{ matrix.memory_checks == 'ON' }}
run: |
cd build
ninja ${{ matrix.target }}
- name: Documentation
if: ${{ matrix.documentation == 'ON' }}
run: |
cd build
ninja ${{ matrix.target }}
- name: Install libOpenCOR
if: ${{ matrix.install_uninstall_and_package == 'ON' }}
run: |
cd build
ninja install
- name: Uninstall libOpenCOR
if: ${{ matrix.install_uninstall_and_package == 'ON' }}
run: |
cd build
ninja uninstall
- name: Package libOpenCOR
if: ${{ matrix.install_uninstall_and_package == 'ON' }}
run: |
cd build
cpack
- name: pip install libOpenCOR
if: ${{ matrix.pip_install_test_and_uninstall == 'ON' }}
run: |
${{ matrix.pip_install_prerequisites }}
pip3 install .
- name: Test libOpenCOR Python
if: ${{ matrix.pip_install_test_and_uninstall == 'ON' }}
run: python3 -c "import libopencor as oc; print(f'This is libOpenCOR version {oc.version_string()}.')"
- name: pip uninstall libOpenCOR
if: ${{ matrix.pip_install_test_and_uninstall == 'ON' }}
run: pip3 uninstall -y libopencor
# spell_check:
# name: Spell check
# runs-on: ubuntu-latest
# steps:
# - name: Check out libOpenCOR
# uses: actions/checkout@v4
# - name: Spell check
# uses: codespell-project/actions-codespell@v2
# with:
# check_filenames: true
# skip: ./extern
# exclude_file: .codespellexclude