Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.20251204.0
0.20260210.0
2 changes: 1 addition & 1 deletion extern/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

- [GoogleTest](https://github.com/google/googletest) [1.17.0](https://github.com/google/googletest/releases/tag/v1.17.0)
- [modp_b64](https://chromium.googlesource.com/chromium/src/third_party/modp_b64/) at commit [5068510](https://chromium.googlesource.com/chromium/src/third_party/modp_b64/+/50685101d51ef9aabbd60c94f52d9e026d39c509)
- [nanobind](https://github.com/wjakob/nanobind) [2.9.2](https://github.com/wjakob/nanobind/releases/tag/v2.9.2)
- [nanobind](https://github.com/wjakob/nanobind) [2.11.0](https://github.com/wjakob/nanobind/releases/tag/v2.11.0)
190 changes: 136 additions & 54 deletions extern/nanobind/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-2022', 'macos-13']
python: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14.0-rc.2', 'pypy3.9-v7.3.16', 'pypy3.10-v7.3.17']
os: ['ubuntu-latest', 'windows-2022', 'macos-15']
python: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14', 'pypy3.10-v7.3.19', 'pypy3.11-v7.3.20']

name: "Python ${{ matrix.python }} / ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -107,98 +107,180 @@ jobs:
cd build;
python3 -m pytest

old-compilers:
if: false # Disable for now, the CI is glitchy
strategy:
fail-fast: false
matrix:
include:
- cc: gcc-8
cxx: g++-8
apt: gcc-8 g++-8
- cc: gcc-9
cxx: g++-9
apt: gcc-9
- cc: clang-8
cxx: clang++-8
apt: clang-8
- cc: clang-9
cxx: clang++-9
apt: clang-9
- cc: clang-10
cxx: clang++-10
apt: clang-10

free-threaded:
name: "Python 3.14-dev / ubuntu.latest [free-threaded]"
runs-on: ubuntu-latest
container: ubuntu:20.04
name: "${{matrix.cc}} on Ubuntu 20.04"
env:
CC: ${{matrix.cc}}
CXX: ${{matrix.cxx}}
DEBIAN_FRONTEND: noninteractive

steps:
- name: Install dependencies
run: |
apt-get update
apt-get install -y python3-numpy python3-pip python3-pytest libeigen3-dev cmake git ${{matrix.apt}}
python3 -m pip install typing_extensions

- uses: actions/checkout@v4
with:
submodules: true

- uses: deadsnakes/action@v3.1.0
with:
python-version: 3.14-dev
nogil: true

- name: Install the latest CMake
uses: lukka/get-cmake@latest

- name: Install PyTest
run: |
python -m pip install pytest pytest-github-actions-annotate-failures

- name: Configure
run: cmake -S . -B build
run: >
cmake -S . -B build -DNB_TEST_FREE_THREADED=ON

- name: Build C++
run: cmake --build build -j 2
run: >
cmake --build build -j 2

- name: Check ABI tag
run: >
cd build/tests;
python3 -c 'import test_functions_ext as t; print(f"ABI tag is \"{ t.abi_tag() }\"")'
python -c 'import test_functions_ext as t; print(f"ABI tag is \"{ t.abi_tag() }\"")'

- name: Run tests
run: >
cd build;
python3 -m pytest
python -m pytest

free-threaded:
name: "Python 3.14-dev / ubuntu.latest [free-threaded]"
runs-on: ubuntu-latest
mingw:
runs-on: windows-2022
name: "Python ${{ matrix.python }} / MinGW-w64"
strategy:
fail-fast: false
matrix:
python: ['3.12']

steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: deadsnakes/action@v3.1.0
- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: 3.14-dev
nogil: true
python-version: ${{ matrix.python }}
cache: 'pip'

- name: Setup MSYS2 (MINGW64)
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
install: >-
mingw-w64-x86_64-gcc
mingw-w64-x86_64-cmake
mingw-w64-x86_64-ninja
mingw-w64-x86_64-python
mingw-w64-x86_64-python-pip
mingw-w64-x86_64-python-pytest

- name: Install Python packages
shell: msys2 {0}
run: |
python -m pip install pytest-github-actions-annotate-failures typing_extensions

- name: Configure
shell: msys2 {0}
run: |
export PATH=/mingw64/bin:$PATH
export CC=gcc
export CXX=g++
PYEXE=/mingw64/bin/python3.exe
cmake -S . -B build -G Ninja \
-DPython_EXECUTABLE="$(cygpath -w "$PYEXE")" \
-DNB_TEST_FREE_THREADED=OFF

- name: Build C++
shell: msys2 {0}
run: cmake --build build -j 2

- name: Check ABI tag
shell: msys2 {0}
run: |
cd build/tests
python -c 'import test_functions_ext as t; print(f"ABI tag is \"{t.abi_tag()}\"")'

- name: Run tests
shell: msys2 {0}
run: |
cd build
python -m pytest

intel:
runs-on: ubuntu-22.04
name: "Python ${{ matrix.python }} / Intel ICX"
strategy:
fail-fast: false
matrix:
python: ['3.12']

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: 'pip'

- name: Cache Intel oneAPI
id: cache-oneapi
uses: actions/cache@v4
with:
path: /opt/intel/oneapi
key: install-${{ runner.os }}-intel-oneapi-compiler-2025.2

- name: Add Intel repository
if: steps.cache-oneapi.outputs.cache-hit != 'true'
run: |
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update

- name: Install Intel oneAPI compilers
if: steps.cache-oneapi.outputs.cache-hit != 'true'
run: |
sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp

- name: Cleanup Intel oneAPI cache
if: steps.cache-oneapi.outputs.cache-hit != 'true'
run: |
sudo rm -rf /opt/intel/oneapi/compiler/*/linux/lib/ia32
sudo rm -rf /opt/intel/oneapi/compiler/*/linux/lib/emu
sudo rm -rf /opt/intel/oneapi/compiler/*/linux/lib/oclfpga

- name: Install the latest CMake
uses: lukka/get-cmake@latest

- name: Install PyTest
run: |
python -m pip install pytest pytest-github-actions-annotate-failures
python -m pip install pytest pytest-github-actions-annotate-failures typing_extensions

- name: Configure
run: >
cmake -S . -B build -DNB_TEST_FREE_THREADED=ON
run: |
source /opt/intel/oneapi/setvars.sh
export CC=icx
export CXX=icpx
cmake -S . -B build

- name: Build C++
run: >
run: |
source /opt/intel/oneapi/setvars.sh
cmake --build build -j 2

- name: Check ABI tag
run: >
cd build/tests;
run: |
source /opt/intel/oneapi/setvars.sh
cd build/tests
python -c 'import test_functions_ext as t; print(f"ABI tag is \"{ t.abi_tag() }\"")'

- name: Run tests
run: >
cd build;
run: |
source /opt/intel/oneapi/setvars.sh
cd build
python -m pytest
2 changes: 1 addition & 1 deletion extern/nanobind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ if (NOT TARGET Python::Module OR NOT TARGET Python::Interpreter)
set(NB_PYTHON_DEV_MODULE Development.Module)
endif()

find_package(Python 3.8
find_package(Python 3.9
REQUIRED COMPONENTS Interpreter ${NB_PYTHON_DEV_MODULE}
OPTIONAL_COMPONENTS Development.SABIModule)
endif()
Expand Down
58 changes: 58 additions & 0 deletions extern/nanobind/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,64 @@ runtime overheads compared to pybind11. nanobind also outperforms Cython in
important metrics (**3-12×** binary size reduction, **1.6-4×** compilation time
reduction, similar runtime performance).

## Testimonials

A selection of testimonials from projects that migrated from pybind11 to nanobind.

<table>
<tr><td>

**IREE** · [LLVM Discourse](https://discourse.llvm.org/t/nanobind-for-mlir-python-bindings/83511/5)

> *"IREE and its derivatives switched 1.5 years ago. It has been one of the single best dep decisions I've made. Not only is it much-much faster to compile, it produces smaller binaries and has a much more lean interface to the underlying Python machinery that all adds up to significant performance improvements. Worked exactly like it said on the tin."*

— **Stella Laurenzo**, Google

</td></tr>
<tr><td>

**XLA/MLIR** · [GitHub PR](https://github.com/llvm/llvm-project/pull/118583)

> *"For a complicated Google-internal LLM model in JAX, this change improves the MLIR lowering time by around 5s (out of around 30s), which is a significant speedup for simply switching binding frameworks."*

— **Peter Hawkins**, Google

</td></tr>
<tr><td>

**Apple MLX** · [X](https://x.com/awnihannun/status/1890495434021326974)

> *"MLX uses nanobind to bind C++ to Python. It's a critical piece of MLX infra and is why running Python code is nearly the same speed as running C++ directly. Also makes it super easy to move arrays between frameworks."*

— **Awni Hannun**, Apple

</td></tr>
<tr><td>

**JAX** · [GitHub](https://github.com/jax-ml/jax/commit/70b7d501816c6e9f131a0a8b3e4a527e53eeebd7)

> *"nanobind has a number of [advantages](https://nanobind.readthedocs.io/en/latest/why.html), notably speed of compilation and dispatch, but the main reason to do this for these bindings is because nanobind can target the Python Stable ABI starting with Python 3.12. This means that we will not need to ship per-Python version CUDA plugins starting with Python 3.12."*

— **Peter Hawkins**, Google

</td></tr>
<tr><td>

**FEniCS / DOLFINx** · [GitHub](https://github.com/FEniCS/dolfinx/pull/2820)

> *"nanobind is smaller than pybind11, the wrappers build faster and it has significantly improved support for wrapping multi-dimensional arrays, which we use heavily. The nanobind docs are easier to follow on the low-level details, which makes understanding the memory management in the wrapper layer easier."*

— **Garth N. Wells**
</td></tr>
<tr><td>

**PennyLane** · [Release notes](https://docs.pennylane.ai/projects/catalyst/en/stable/dev/release_notes.html)

> *"Nanobind has been developed as a natural successor to the pybind11 library and offers a number of advantages like its ability to target Python's Stable ABI."*

</td></tr>
</table>

## Documentation

Please see the following links for tutorial and reference documentation in
Expand Down
5 changes: 3 additions & 2 deletions extern/nanobind/cmake/collect-symbols-pypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
funcs: "set[str]" = set()

files = [
('https://downloads.python.org/pypy/pypy3.9-v7.3.11-macos_arm64.tar.bz2', 'pypy3.9-v7.3.11-macos_arm64/bin/libpypy3.9-c.dylib')
('https://downloads.python.org/pypy/pypy3.9-v7.3.11-macos_arm64.tar.bz2', 'pypy3.9-v7.3.11-macos_arm64/bin/libpypy3.9-c.dylib'),
('https://downloads.python.org/pypy/pypy3.11-v7.3.20-macos_arm64.tar.bz2', 'pypy3.11-v7.3.20-macos_arm64/bin/libpypy3.11-c.dylib'),
]

for f in files:
Expand All @@ -25,4 +26,4 @@

with open("darwin-ld-pypy.sym", "w") as f:
for func in sorted(list(funcs)):
f.write(f'-U _{func}\n')
f.write(f'-U {func}\n')
4 changes: 2 additions & 2 deletions extern/nanobind/cmake/collect-symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

funcs: "set[str]" = set()

for ver in ['3.7', '3.8', '3.9']:
for ver in ['3.9']:
url = f'https://raw.githubusercontent.com/python/cpython/{ver}/PC/python3.def'
output = urlopen(url).read().decode('utf-8')
for match in re.findall(r" (.*)=.*", output):
funcs.add(match)

for ver in ['3.10', '3.11', 'main']:
for ver in ['3.10', '3.11', '3.12', '3.13', '3.14', 'main']:
url = f'https://raw.githubusercontent.com/python/cpython/{ver}/PC/python3dll.c'
output = urlopen(url).read().decode('utf-8')
for match in re.findall(r"EXPORT_FUNC\((.*)\)", output):
Expand Down
Loading
Loading