Skip to content

fix: prevent panic when no interpreters match abi3 minimum version#3108

Merged
messense merged 1 commit into
PyO3:mainfrom
messense:fix/abi3-incompatible-interpreter-panic
Mar 30, 2026
Merged

fix: prevent panic when no interpreters match abi3 minimum version#3108
messense merged 1 commit into
PyO3:mainfrom
messense:fix/abi3-incompatible-interpreter-panic

Conversation

@messense

Copy link
Copy Markdown
Member

When the default Python interpreter (first on PATH) doesn't meet the abi3 minimum version and no interpreter is explicitly specified, maturin panicked with assertion failed: !wheels.is_empty().

This happened because find_specified_interpreters didn't filter by requires-python, so an incompatible interpreter (e.g. CPython 3.9) was selected. Then in build_abi3_wheels, it was excluded from both abi3_interps (version too low) and non_abi3_interps (has stable API), resulting in an empty wheels vector.

Fix both layers:

  • Filter default interpreters by requires-python in find_specified_interpreters, so the abi3 sysconfig fallback can find compatible interpreters instead.
  • Replace the assert! in build_abi3_wheels and build() with proper error messages as defense in depth.

Closes #3107

@messense messense enabled auto-merge (squash) March 30, 2026 11:52
When the default Python interpreter (first on PATH) doesn't meet the
abi3 minimum version and no interpreter is explicitly specified, maturin
panicked with `assertion failed: !wheels.is_empty()`.

This happened because `find_specified_interpreters` didn't filter by
`requires-python`, so an incompatible interpreter (e.g. CPython 3.9)
was selected. Then in `build_abi3_wheels`, it was excluded from both
`abi3_interps` (version too low) and `non_abi3_interps` (has stable
API), resulting in an empty wheels vector.

Fix both layers:
- Filter default interpreters by `requires-python` in
  `find_specified_interpreters`, so the abi3 sysconfig fallback can
  find compatible interpreters instead.
- Replace the `assert!` in `build_abi3_wheels` and `build()` with
  proper error messages as defense in depth.
@messense messense force-pushed the fix/abi3-incompatible-interpreter-panic branch from c4357eb to 69a7068 Compare March 30, 2026 12:03
@messense messense merged commit 81b5cf6 into PyO3:main Mar 30, 2026
44 of 45 checks passed
@messense messense deleted the fix/abi3-incompatible-interpreter-panic branch March 30, 2026 12:41
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.

ghcr.io/pyo3/maturin:main panics when building

1 participant