Skip to content

fix: avoid duplicate --interpreter panic in PEP 517 backend#3175

Merged
messense merged 1 commit intoPyO3:mainfrom
messense:fix/pep517-duplicate-interpreter
May 7, 2026
Merged

fix: avoid duplicate --interpreter panic in PEP 517 backend#3175
messense merged 1 commit intoPyO3:mainfrom
messense:fix/pep517-duplicate-interpreter

Conversation

@messense
Copy link
Copy Markdown
Member

@messense messense commented May 7, 2026

When users set MATURIN_PEP517_ARGS=--interpreter <python> (common on Termux/Android where the auto-detected interpreter path may need to be overridden), the Python PEP 517 shim still appended its own --interpreter $(sys.executable), producing two --interpreter flags. The Rust side then tripped assert_eq!(... == 1) in Pep517Command::WriteDistInfo, surfacing as a 'this is a bug in maturin' panic to end users (see #3174).

Two changes:

  • maturin/__init__.py: introduce _has_interpreter_arg() and only auto-inject --interpreter <sys.executable> in _build_wheel and prepare_metadata_for_build_wheel when the user-supplied args don't already contain one.
  • src/commands/pep517.rs: defensively dedup identical interpreter paths and replace the assert_eq! with an anyhow::bail! carrying a clear message, so an actual misconfiguration is reported as an error instead of a panic.

Closes #3174

When users set `MATURIN_PEP517_ARGS=--interpreter <python>` (common on
Termux/Android where the auto-detected interpreter path may need to be
overridden), the Python PEP 517 shim still appended its own
`--interpreter $(sys.executable)`, producing two `--interpreter` flags.
The Rust side then tripped `assert_eq!(... == 1)` in
`Pep517Command::WriteDistInfo`, surfacing as a 'this is a bug in maturin'
panic to end users (see PyO3#3174).

Two changes:

* `maturin/__init__.py`: introduce `_has_interpreter_arg()` and only
  auto-inject `--interpreter <sys.executable>` in `_build_wheel` and
  `prepare_metadata_for_build_wheel` when the user-supplied args don't
  already contain one.
* `src/commands/pep517.rs`: defensively dedup identical interpreter
  paths and replace the `assert_eq!` with an `anyhow::bail!` carrying a
  clear message, so an actual misconfiguration is reported as an error
  instead of a panic.

Closes PyO3#3174
@messense messense merged commit e6d39af into PyO3:main May 7, 2026
44 checks passed
@messense messense deleted the fix/pep517-duplicate-interpreter branch May 7, 2026 11:39
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.

Panicked

1 participant