diff --git a/Changelog.md b/Changelog.md index 65263a8dd..970d0f1cf 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] * Don't consider compile to i686 on x86_64 Windows cross compiling in [#923](https://github.com/PyO3/maturin/pull/923) +* Accept `-i x.y` and `-i python-x.y` in `maturin build` command in [#925](https://github.com/PyO3/maturin/pull/925) ## [0.12.16] - 2022-05-16 diff --git a/src/build_options.rs b/src/build_options.rs index 56760f5f3..52a31eb13 100644 --- a/src/build_options.rs +++ b/src/build_options.rs @@ -660,9 +660,20 @@ fn find_interpreter_in_sysconfig( .context("Invalid python interpreter")? .to_string_lossy(); let (python_impl, python_ver) = if let Some(ver) = python.strip_prefix("pypy") { - (InterpreterKind::PyPy, ver) + (InterpreterKind::PyPy, ver.strip_prefix('-').unwrap_or(ver)) } else if let Some(ver) = python.strip_prefix("python") { - (InterpreterKind::CPython, ver) + ( + InterpreterKind::CPython, + ver.strip_prefix('-').unwrap_or(ver), + ) + } else if python + .chars() + .next() + .map(|c| c.is_ascii_digit()) + .unwrap_or(false) + { + // Eg: -i 3.9 without interpreter kind, assume it's CPython + (InterpreterKind::CPython, &*python) } else { bail!("Unsupported Python interpreter: {}", python); };