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 b9803ef
Showing 1 changed file with 13 additions and 2 deletions.
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 b9803ef

Please sign in to comment.