fix: avoid duplicate --interpreter panic in PEP 517 backend#3175
Merged
fix: avoid duplicate --interpreter panic in PEP 517 backend#3175
--interpreter panic in PEP 517 backend#3175Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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--interpreterflags. The Rust side then trippedassert_eq!(... == 1)inPep517Command::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_wheelandprepare_metadata_for_build_wheelwhen the user-supplied args don't already contain one.src/commands/pep517.rs: defensively dedup identical interpreter paths and replace theassert_eq!with ananyhow::bail!carrying a clear message, so an actual misconfiguration is reported as an error instead of a panic.Closes #3174