Skip to content

Commit f2499d4

Browse files
authored
Add CI support for MinGW-w64 and Intel ICX compilers (#1188)
This commit adds continuous integration testing for two additional compiler toolchains: - MinGW-w64: Tests with Python 3.12 on Windows using MSYS2 - Intel ICX: Tests with Python 3.12 on Ubuntu using the modern Clang-based Intel oneAPI compiler (with caching to reduce install time) Additional changes: - Update Python 3.14.0-rc.2 to 3.14 (official release) - Remove disabled old-compilers job for Ubuntu 20.04 - Fix format string warning in scoped_pymalloc for MinGW (%zu -> %llu) - Update documentation to list MinGW-w64 and Intel ICX as officially supported compilers
1 parent dd350fe commit f2499d4

File tree

4 files changed

+148
-57
lines changed

4 files changed

+148
-57
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/[email protected]
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/[email protected]
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

docs/changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ 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+
- Nanobind now officially supports **MinGW-w64** and **Intel ICX** (the modern
22+
Clang-based Intel compiler). Continuous integration tests have been added to
23+
ensure compatibility with these compilers on an ongoing basis.
24+
1825
Version 2.9.2 (Sep 4, 2025)
1926
---------------------------
2027

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

src/nb_internals.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ template <typename T> struct scoped_pymalloc {
493493
scoped_pymalloc(size_t size = 1) {
494494
ptr = (T *) PyMem_Malloc(size * sizeof(T));
495495
if (!ptr)
496-
fail("scoped_pymalloc(): could not allocate %zu bytes of memory!", size);
496+
fail("scoped_pymalloc(): could not allocate %llu bytes of memory!",
497+
(unsigned long long) size);
497498
}
498499
~scoped_pymalloc() { PyMem_Free(ptr); }
499500
T *release() {

0 commit comments

Comments
 (0)