Skip to content

Bundle MinGW runtime DLLs into Windows wheels (delvewheel)#151

Closed
stoiver wants to merge 1 commit into
inducer:mainfrom
stoiver:fix/bundle-windows-mingw-dlls
Closed

Bundle MinGW runtime DLLs into Windows wheels (delvewheel)#151
stoiver wants to merge 1 commit into
inducer:mainfrom
stoiver:fix/bundle-windows-mingw-dlls

Conversation

@stoiver

@stoiver stoiver commented Jun 7, 2026

Copy link
Copy Markdown

Fixes #150.

Problem

cibuildwheel repairs Linux wheels (auditwheel → manylinux) and macOS wheels (delocate) by default, but does not run a repair step on Windows. The extension is built with MinGW, so the published win_amd64 wheels ship without their runtime DLLs and fail to import on a clean Windows Python:

ImportError: DLL load failed while importing _internals: The specified module could not be found.

_internals.*.pyd imports libgcc_s_seh-1.dll and libstdc++-6.dll (confirmed via pefile), neither of which is bundled in the wheel or present on a stock Windows Python. This also breaks downstreams — e.g. pip install anuga, which depends on meshpy.

Fix

Add the documented cibuildwheel Windows repair step using delvewheel, which bundles the dependent DLLs and rewrites the load paths so the wheel is self-contained:

CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}"

The MinGW runtime DLLs are on PATH during the build (that's how meson finds gcc), so delvewheel locates and bundles them. Linux and macOS builds are unaffected.

Verifying

This PR's Build wheels run produces the Windows wheels; the repaired wheel should contain the bundled DLLs under meshpy.libs/ (e.g. delvewheel adds libstdc++-6, libgcc_s_seh-1, libwinpthread-1), and import meshpy.triangle then works in a clean venv with no MinGW on PATH.

🤖 Generated with Claude Code

cibuildwheel repairs Linux (auditwheel) and macOS (delocate) wheels by default
but does nothing on Windows, so the MinGW-built extension ships without its
runtime DLLs. _internals.pyd imports libgcc_s_seh-1.dll and libstdc++-6.dll,
which aren't bundled and aren't present on a clean Windows Python, so
`import meshpy.triangle` fails with "DLL load failed while importing
_internals". This also breaks downstreams such as `pip install anuga`.

Add the documented cibuildwheel Windows repair: install delvewheel before the
build and run `delvewheel repair` so the runtime DLLs are bundled and the wheel
is self-contained. Linux and macOS are unaffected.

Fixes inducer#150

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@inducer

inducer commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Thanks for this PR. It turns out that cibuildwheel 4 has started automatically running delvewheel:

https://cibuildwheel.pypa.io/en/stable/changelog/#v400

The bump to that went in this morning in #152. Does that make this PR redundant? (You can grab built wheels from the wheel build artifacts I think, in case that's helpful.)

@stoiver

stoiver commented Jun 9, 2026

Copy link
Copy Markdown
Author

Confirmed redundant — closing. I verified the Windows wheel built from main right after #152 (cibuildwheel 3.4.1 → 4.0.0) merged: cibuildwheel 4.0 auto-runs delvewheel, and the wheel now bundles the previously-missing MinGW runtimes in meshpy.libs/ (libstdc++-6, libgcc_s_seh-1, libwinpthread-1, hash-mangled, plus a DELVEWHEEL marker in dist-info). So cibuildwheel 4 does automatically what this PR did manually — no need for the explicit delvewheel step. Thanks for the pointer! (Note #150 isn't fully resolved for consumers until a new release carries these wheels to PyPI — the current 2025.1.1 wheels there predate the fix.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows wheels are not self-contained: _internals.pyd needs unbundled MinGW runtime DLLs (libstdc++-6, libgcc_s_seh-1)

2 participants