Skip to content

Commit 64635fc

Browse files
Merge branch 'wjakob:master' into master
2 parents f921468 + dc35d69 commit 64635fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1572
-519
lines changed

.github/workflows/ci.yml

Lines changed: 135 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
os: ['ubuntu-latest', 'windows-2022', 'macos-13']
24-
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']
24+
python: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14', 'pypy3.9-v7.3.16', 'pypy3.10-v7.3.17']
2525

2626
name: "Python ${{ matrix.python }} / ${{ matrix.os }}"
2727
runs-on: ${{ matrix.os }}
@@ -107,98 +107,180 @@ jobs:
107107
cd build;
108108
python3 -m pytest
109109
110-
old-compilers:
111-
if: false # Disable for now, the CI is glitchy
112-
strategy:
113-
fail-fast: false
114-
matrix:
115-
include:
116-
- cc: gcc-8
117-
cxx: g++-8
118-
apt: gcc-8 g++-8
119-
- cc: gcc-9
120-
cxx: g++-9
121-
apt: gcc-9
122-
- cc: clang-8
123-
cxx: clang++-8
124-
apt: clang-8
125-
- cc: clang-9
126-
cxx: clang++-9
127-
apt: clang-9
128-
- cc: clang-10
129-
cxx: clang++-10
130-
apt: clang-10
131-
110+
free-threaded:
111+
name: "Python 3.14-dev / ubuntu.latest [free-threaded]"
132112
runs-on: ubuntu-latest
133-
container: ubuntu:20.04
134-
name: "${{matrix.cc}} on Ubuntu 20.04"
135-
env:
136-
CC: ${{matrix.cc}}
137-
CXX: ${{matrix.cxx}}
138-
DEBIAN_FRONTEND: noninteractive
139113

140114
steps:
141-
- name: Install dependencies
142-
run: |
143-
apt-get update
144-
apt-get install -y python3-numpy python3-pip python3-pytest libeigen3-dev cmake git ${{matrix.apt}}
145-
python3 -m pip install typing_extensions
146-
147115
- uses: actions/checkout@v4
148116
with:
149117
submodules: true
150118

119+
- uses: deadsnakes/action@v3.1.0
120+
with:
121+
python-version: 3.14-dev
122+
nogil: true
123+
124+
- name: Install the latest CMake
125+
uses: lukka/get-cmake@latest
126+
127+
- name: Install PyTest
128+
run: |
129+
python -m pip install pytest pytest-github-actions-annotate-failures
130+
151131
- name: Configure
152-
run: cmake -S . -B build
132+
run: >
133+
cmake -S . -B build -DNB_TEST_FREE_THREADED=ON
153134
154135
- name: Build C++
155-
run: cmake --build build -j 2
136+
run: >
137+
cmake --build build -j 2
156138
157139
- name: Check ABI tag
158140
run: >
159141
cd build/tests;
160-
python3 -c 'import test_functions_ext as t; print(f"ABI tag is \"{ t.abi_tag() }\"")'
142+
python -c 'import test_functions_ext as t; print(f"ABI tag is \"{ t.abi_tag() }\"")'
161143
162144
- name: Run tests
163145
run: >
164146
cd build;
165-
python3 -m pytest
147+
python -m pytest
166148
167-
free-threaded:
168-
name: "Python 3.14-dev / ubuntu.latest [free-threaded]"
169-
runs-on: ubuntu-latest
149+
mingw:
150+
runs-on: windows-2022
151+
name: "Python ${{ matrix.python }} / MinGW-w64"
152+
strategy:
153+
fail-fast: false
154+
matrix:
155+
python: ['3.12']
170156

171157
steps:
172158
- uses: actions/checkout@v4
173159
with:
174160
submodules: true
175161

176-
- uses: deadsnakes/action@v3.1.0
162+
- name: Setup Python ${{ matrix.python }}
163+
uses: actions/setup-python@v5
177164
with:
178-
python-version: 3.14-dev
179-
nogil: true
165+
python-version: ${{ matrix.python }}
166+
cache: 'pip'
167+
168+
- name: Setup MSYS2 (MINGW64)
169+
uses: msys2/setup-msys2@v2
170+
with:
171+
msystem: MINGW64
172+
install: >-
173+
mingw-w64-x86_64-gcc
174+
mingw-w64-x86_64-cmake
175+
mingw-w64-x86_64-ninja
176+
mingw-w64-x86_64-python
177+
mingw-w64-x86_64-python-pip
178+
mingw-w64-x86_64-python-pytest
179+
180+
- name: Install Python packages
181+
shell: msys2 {0}
182+
run: |
183+
python -m pip install pytest-github-actions-annotate-failures typing_extensions
184+
185+
- name: Configure
186+
shell: msys2 {0}
187+
run: |
188+
export PATH=/mingw64/bin:$PATH
189+
export CC=gcc
190+
export CXX=g++
191+
PYEXE=/mingw64/bin/python3.exe
192+
cmake -S . -B build -G Ninja \
193+
-DPython_EXECUTABLE="$(cygpath -w "$PYEXE")" \
194+
-DNB_TEST_FREE_THREADED=OFF
195+
196+
- name: Build C++
197+
shell: msys2 {0}
198+
run: cmake --build build -j 2
199+
200+
- name: Check ABI tag
201+
shell: msys2 {0}
202+
run: |
203+
cd build/tests
204+
python -c 'import test_functions_ext as t; print(f"ABI tag is \"{t.abi_tag()}\"")'
205+
206+
- name: Run tests
207+
shell: msys2 {0}
208+
run: |
209+
cd build
210+
python -m pytest
211+
212+
intel:
213+
runs-on: ubuntu-22.04
214+
name: "Python ${{ matrix.python }} / Intel ICX"
215+
strategy:
216+
fail-fast: false
217+
matrix:
218+
python: ['3.12']
219+
220+
steps:
221+
- uses: actions/checkout@v4
222+
with:
223+
submodules: true
224+
225+
- name: Setup Python ${{ matrix.python }}
226+
uses: actions/setup-python@v5
227+
with:
228+
python-version: ${{ matrix.python }}
229+
cache: 'pip'
230+
231+
- name: Cache Intel oneAPI
232+
id: cache-oneapi
233+
uses: actions/cache@v4
234+
with:
235+
path: /opt/intel/oneapi
236+
key: install-${{ runner.os }}-intel-oneapi-compiler-2025.2
237+
238+
- name: Add Intel repository
239+
if: steps.cache-oneapi.outputs.cache-hit != 'true'
240+
run: |
241+
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
242+
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
243+
sudo apt-get update
244+
245+
- name: Install Intel oneAPI compilers
246+
if: steps.cache-oneapi.outputs.cache-hit != 'true'
247+
run: |
248+
sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp
249+
250+
- name: Cleanup Intel oneAPI cache
251+
if: steps.cache-oneapi.outputs.cache-hit != 'true'
252+
run: |
253+
sudo rm -rf /opt/intel/oneapi/compiler/*/linux/lib/ia32
254+
sudo rm -rf /opt/intel/oneapi/compiler/*/linux/lib/emu
255+
sudo rm -rf /opt/intel/oneapi/compiler/*/linux/lib/oclfpga
180256
181257
- name: Install the latest CMake
182258
uses: lukka/get-cmake@latest
183259

184260
- name: Install PyTest
185261
run: |
186-
python -m pip install pytest pytest-github-actions-annotate-failures
262+
python -m pip install pytest pytest-github-actions-annotate-failures typing_extensions
187263
188264
- name: Configure
189-
run: >
190-
cmake -S . -B build -DNB_TEST_FREE_THREADED=ON
265+
run: |
266+
source /opt/intel/oneapi/setvars.sh
267+
export CC=icx
268+
export CXX=icpx
269+
cmake -S . -B build
191270
192271
- name: Build C++
193-
run: >
272+
run: |
273+
source /opt/intel/oneapi/setvars.sh
194274
cmake --build build -j 2
195275
196276
- name: Check ABI tag
197-
run: >
198-
cd build/tests;
277+
run: |
278+
source /opt/intel/oneapi/setvars.sh
279+
cd build/tests
199280
python -c 'import test_functions_ext as t; print(f"ABI tag is \"{ t.abi_tag() }\"")'
200281
201282
- name: Run tests
202-
run: >
203-
cd build;
283+
run: |
284+
source /opt/intel/oneapi/setvars.sh
285+
cd build
204286
python -m pytest

cmake/nanobind-config.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ endfunction()
590590
# ---------------------------------------------------------------------------
591591

592592
function (nanobind_add_stub name)
593-
cmake_parse_arguments(PARSE_ARGV 1 ARG "VERBOSE;INCLUDE_PRIVATE;EXCLUDE_DOCSTRINGS;INSTALL_TIME;RECURSIVE;EXCLUDE_FROM_ALL" "MODULE;COMPONENT;PATTERN_FILE;OUTPUT_PATH" "PYTHON_PATH;DEPENDS;MARKER_FILE;OUTPUT")
593+
cmake_parse_arguments(PARSE_ARGV 1 ARG "VERBOSE;INCLUDE_PRIVATE;EXCLUDE_DOCSTRINGS;EXCLUDE_VALUES;INSTALL_TIME;RECURSIVE;EXCLUDE_FROM_ALL" "MODULE;COMPONENT;PATTERN_FILE;OUTPUT_PATH" "PYTHON_PATH;DEPENDS;MARKER_FILE;OUTPUT")
594594

595595
if (EXISTS ${NB_DIR}/src/stubgen.py)
596596
set(NB_STUBGEN "${NB_DIR}/src/stubgen.py")
@@ -614,6 +614,10 @@ function (nanobind_add_stub name)
614614
list(APPEND NB_STUBGEN_ARGS -D)
615615
endif()
616616

617+
if (ARG_EXCLUDE_VALUES)
618+
list(APPEND NB_STUBGEN_ARGS --exclude-values)
619+
endif()
620+
617621
if (ARG_RECURSIVE)
618622
list(APPEND NB_STUBGEN_ARGS -r)
619623
endif()

docs/api_extra.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,11 @@ convert into an equivalent representation in one of the following frameworks:
11081108

11091109
Builtin Python ``memoryview`` for CPU-resident data.
11101110

1111+
.. cpp:class:: array_api
1112+
1113+
An object that both implements the buffer protocol and also has the
1114+
``__dlpack__`` and ``__dlpack_device__`` attributes.
1115+
11111116
Eigen convenience type aliases
11121117
------------------------------
11131118

@@ -1561,6 +1566,16 @@ include directive:
15611566
<https://docs.python.org/3/library/typing.html#typing.TypeVarTuple>`__
15621567
(i.e., an instance of ``typing.TypeVarTuple``).
15631568

1569+
.. cpp:function:: template <typename... Args> object param_spec(Args&&... args)
1570+
1571+
Analogous to :cpp:func:`type_var`, create a `parameter specification variable
1572+
<https://docs.python.org/3/library/typing.html#typing.ParamSpec>`__
1573+
(i.e., an instance of ``typing.ParamSpec``).
1574+
1575+
.. code-block:: cpp
1576+
1577+
m.attr("P") = nb::param_spec("P");
1578+
15641579
.. cpp:function:: object any_type()
15651580

15661581
Convenience wrapper, which returns ``typing.Any``.

docs/changelog.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@ case, both modules must use the same nanobind ABI version, or they will be
1515
isolated from each other. Releases that don't explicitly mention an ABI version
1616
below inherit that of the preceding release.
1717

18+
Version TBD (not yet released)
19+
------------------------------
20+
21+
- ABI version 17. The layout of the `nb_inst` class was changed to fix a data race
22+
between `clear_keep_alive` and other bitfields in the same struct (PR `#1191
23+
<https://github.com/wjakob/nanobind/pull/1191>`__)
24+
25+
- Nanobind now officially supports **MinGW-w64** and **Intel ICX** (the modern
26+
Clang-based Intel compiler). Continuous integration tests have been added to
27+
ensure compatibility with these compilers on an ongoing basis.
28+
29+
- The framework ``nb::array_api`` is now available to return an nd-array from
30+
C++ to Python as an object that supports both the Python buffer protocol as
31+
well as the DLPack methods ``__dlpack__`` and ``_dlpack_device__``.
32+
Nanobind now supports importing and exporting nd-arrays via capsules that
33+
contain the ``DLManagedTensorVersioned`` struct, which has a flag bit
34+
indicating the nd-array is read-only.
35+
(PR `#1175 <https://github.com/wjakob/nanobind/pull/1175>`__).
36+
1837
Version 2.9.2 (Sep 4, 2025)
1938
---------------------------
2039

docs/index.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ nanobinds depends on
5757
- **Python 3.8+** or **PyPy 7.3.10+** (the *3.8* and *3.9* PyPy flavors are
5858
supported, though there are :ref:`some limitations <pypy_issues>`).
5959
- **CMake 3.15+**.
60-
- **A C++17 compiler**: Clang 8+, GCC 8+, MSVC2019+, and the CUDA NVCC compiler
61-
are officially supported. Others (MinGW, Cygwin, Intel, ..) may work as well
62-
but will not receive support.
60+
- **A C++17 compiler**: Clang 8+, GCC 8+, MSVC2019+, MinGW-w64, Intel ICX
61+
(the modern Clang-based Intel compiler), and the CUDA NVCC compiler are
62+
officially supported. Others (Cygwin, older Intel compilers, ..) may work
63+
as well but will not receive support.
6364

6465
.. only:: not latex
6566

0 commit comments

Comments
 (0)