Skip to content

Commit

Permalink
Fix abi3 wheel build when no Python interpreters found
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Aug 31, 2022
1 parent 3dbbe05 commit 22f2c4b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Allow user to override default Emscripten settings in [#1059](https://github.com/PyO3/maturin/pull/1059)
* Enable `--crate-type cdylib` on Rust 1.64.0 in [#1060](https://github.com/PyO3/maturin/pull/1060)
* Update MSRV to 1.59.0 in [#1071](https://github.com/PyO3/maturin/pull/1071)
* Fix abi3 wheel build when no Python interpreters found in [#1072](https://github.com/PyO3/maturin/pull/1072)

## [0.13.2] - 2022-08-14

Expand Down
30 changes: 20 additions & 10 deletions src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,18 +403,28 @@ impl BuildOptions {
bail!("Failed to find a python interpreter");
}
} else {
let interpreters = find_interpreter_in_host(
let found_interpreters = find_interpreter_in_host(
bridge,
interpreter,
target,
Some(*minor as usize),
)
.unwrap_or_else(|_| {
find_interpreter_in_sysconfig(interpreter, target, Some(*minor as usize))
.unwrap_or_default()
});
.or_else(|err| {
let interps = find_interpreter_in_sysconfig(
interpreter,
target,
Some(*minor as usize),
)
.unwrap_or_default();
if interps.is_empty() && !self.interpreter.is_empty() {
// Print error when user supplied `--interpreter` option
Err(err)
} else {
Ok(interps)
}
})?;
println!("🐍 Not using a specific python interpreter");
if interpreter.is_empty() {
if self.interpreter.is_empty() {
// Fake one to make `BuildContext::build_wheels` happy for abi3 when no cpython/pypy found on host
// The python interpreter config doesn't matter, as it's not used for anything
Ok(vec![PythonInterpreter {
Expand All @@ -432,9 +442,9 @@ impl BuildOptions {
runnable: false,
}])
} else if target.cross_compiling() {
let mut interps = Vec::with_capacity(interpreters.len());
let mut interps = Vec::with_capacity(found_interpreters.len());
let mut pypys = Vec::new();
for interp in interpreters {
for interp in found_interpreters {
if interp.interpreter_kind.is_pypy() {
pypys.push(PathBuf::from(format!(
"pypy{}.{}",
Expand All @@ -458,10 +468,10 @@ impl BuildOptions {
}
Ok(interps)
} else {
if interpreters.is_empty() {
if found_interpreters.is_empty() {
bail!("Failed to find any python interpreter");
}
Ok(interpreters)
Ok(found_interpreters)
}
}
}
Expand Down

0 comments on commit 22f2c4b

Please sign in to comment.