Skip to content

Migrate from pybind11 to nanobind #2302

Migrate from pybind11 to nanobind

Migrate from pybind11 to nanobind #2302

Workflow file for this run

name: Python package
on:
push:
branches: [ "main" ]
paths: &python-paths
- "include/**"
- "**/CMakeLists.txt"
- "**/*.cmake"
- "cmake/**"
- "CLUEstering/**"
pull_request:
branches: [ "main" ]
paths: *python-paths
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- name: linux-clang-15
os: ubuntu-latest
container: fedora:42
compiler: clang-15
- name: linux-clang-17
os: ubuntu-latest
container: fedora:42
compiler: clang-17
- name: linux-clang-18
os: ubuntu-latest
container: fedora:42
compiler: clang-18
- name: linux-clang-19
os: ubuntu-latest
container: fedora:42
compiler: clang-19
- name: macos-clang
os: macos-latest
- name: windows-msvc
os: windows-latest
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- name: Cache dnf packages
if: matrix.container != ''
uses: actions/cache@v6
with:
path: /var/cache/dnf
key: dnf-${{ matrix.name }}
- name: Install dependencies
if: matrix.container == 'fedora:42'
run: |
dnf install -y ${{ matrix.compiler }}
dnf install -y git cmake boost-devel tbb libomp.x86_64 python3-devel python3-pip
- name: Cache Homebrew downloads
if: matrix.os == 'macos-latest'
uses: actions/cache@v6
with:
path: ~/Library/Caches/Homebrew/downloads
key: brew-${{ runner.os }}-boost-tbb-libomp
- name: Install dependencies
if: matrix.os == 'macos-latest'
run: |
brew update
# brew upgrade python
brew install boost tbb libomp
- uses: actions/checkout@v7
with:
submodules: recursive
- name: Export GitHub Actions cache environment variables
if: matrix.os == 'windows-latest'
uses: actions/github-script@v9
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Set up vcpkg
if: matrix.os == 'windows-latest'
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
run: |
echo "VCPKG_ROOT=C:/vcpkg" >> $env:GITHUB_ENV
echo "CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" >> $env:GITHUB_ENV
cd C:/vcpkg
./vcpkg install boost-atomic:x64-windows alpaka:x64-windows
- name: Set up Python ${{ matrix.python-version }}
if: matrix.os == 'macos-latest'
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
if: matrix.os != 'windows-latest'
uses: actions/cache@v6
with:
path: ~/.cache/pip
key: pip-${{ matrix.name }}-pytest-sklearn-pandas-matplotlib
- name: Cache pip packages (Windows)
if: matrix.os == 'windows-latest'
uses: actions/cache@v6
with:
path: ~\AppData\Local\pip\Cache
key: pip-${{ matrix.name }}-pytest-sklearn-pandas-matplotlib
- name: Install Python dependencies
if: matrix.os != 'windows-latest'
run: |
python3 -m pip install pytest scikit-learn pandas matplotlib --break-system-packages
- name: Install Python dependencies
if: matrix.os == 'windows-latest'
run: |
python -m pip install --upgrade pip
python -m pip install pytest scikit-learn pandas matplotlib
- name: Compile CLUEstering modules
if: matrix.os != 'windows-latest'
working-directory: ${{ github.workspace }}
run: |
cmake -S . -B build -DBUILD_PYTHON=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
- name: Compile CLUEstering modules
if: matrix.os == 'windows-latest'
working-directory: ${{ github.workspace }}
run: |
cmake -S . -B build -DBUILD_PYTHON=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$env:CMAKE_TOOLCHAIN_FILE" -DVCPKG_TARGET_TRIPLET=x64-windows -DVCPKG_MANIFEST_DIR="${{ github.workspace }}"
cmake --build build --parallel --config Release
- name: Run tests of the Python library
if: matrix.os != 'windows-latest'
working-directory: ${{github.workspace}}/tests
run: |
python3 -m pytest .
- name: Run tests of the Python library
if: matrix.os == 'windows-latest'
working-directory: ${{github.workspace}}/tests
run: |
python -m pytest .