Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for using bundled python sysconfigs for PyPy when abi3 feature is enabled #958

Merged
merged 1 commit into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Don't require `pip` error messages to be utf-8 encoding in [#953](https://github.com/PyO3/maturin/pull/953)
* Compare minimum python version requirement between `requires-python` and bindings crate in [#954](https://github.com/PyO3/maturin/pull/954)
* Add a `--target` option to `maturin list-python` command in [#957](https://github.com/PyO3/maturin/pull/957)
* Add support for using bundled python sysconfigs for PyPy when abi3 feature is enabled in [#958](https://github.com/PyO3/maturin/pull/958)

## [0.12.19] - 2022-06-05

Expand Down
22 changes: 15 additions & 7 deletions src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,11 +908,19 @@ pub fn find_interpreter(
}
BridgeModel::Bin(None) => Ok(vec![]),
BridgeModel::BindingsAbi3(major, minor) => {
let interpreter = if !interpreter.is_empty() {
PythonInterpreter::check_executables(interpreter, target, bridge)
.unwrap_or_default()
let interpreters = if !interpreter.is_empty() {
match find_interpreter_in_host(bridge, interpreter, target, Some(*minor as usize)) {
Ok(host_interps) => host_interps,
Err(err) => {
if !interpreter.is_empty() {
find_interpreter_in_sysconfig(interpreter, target).map_err(|_| err)?
} else {
Vec::new()
}
}
}
} else {
PythonInterpreter::find_all(target, bridge, Some(*minor as usize))
find_interpreter_in_host(bridge, interpreter, target, Some(*minor as usize))
.unwrap_or_default()
};
// Ideally, we wouldn't want to use any python interpreter without abi3 at all.
Expand All @@ -937,9 +945,9 @@ pub fn find_interpreter(
platform: None,
runnable: false,
}])
} else if let Some(interp) = interpreter.get(0) {
} else if let Some(interp) = interpreters.get(0) {
println!("🐍 Using {} to generate to link bindings (With abi3, an interpreter is only required on windows)", interp);
Ok(interpreter)
Ok(interpreters)
} else if generate_import_lib {
println!("🐍 Not using a specific python interpreter (Automatically generating windows import library)");
// fake a python interpreter
Expand Down Expand Up @@ -980,7 +988,7 @@ pub fn find_interpreter(
runnable: false,
}])
} else {
Ok(interpreter)
Ok(interpreters)
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ fn compile_target(

// rust-cpython, and legacy pyo3 versions
build_command.env("PYTHON_SYS_EXECUTABLE", &interpreter.executable);
} else if (bindings_crate.is_bindings("pyo3") || bindings_crate.is_bindings("pyo3-ffi"))
} else if (bindings_crate.is_bindings("pyo3")
|| bindings_crate.is_bindings("pyo3-ffi")
|| (matches!(bindings_crate, BridgeModel::BindingsAbi3(_, _))
&& matches!(interpreter.interpreter_kind, InterpreterKind::PyPy)))
&& env::var_os("PYO3_CONFIG_FILE").is_none()
{
let pyo3_config = interpreter.pyo3_config_file();
Expand Down