Skip to content

Commit

Permalink
Accept -i x.y and -i python-x.y in maturin build command
Browse files Browse the repository at this point in the history
This makes it easier to write CI configuration, for example
`setup-python` action use `pypy-3.9` as version, accepting `pypy-3.9`
as `pypy3.9` is much nicer than writing another `pypy3.9` option.
  • Loading branch information
messense committed May 18, 2022
1 parent 47824cf commit f809637
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 13 additions & 2 deletions src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down

0 comments on commit f809637

Please sign in to comment.