Skip to content

Commit

Permalink
Merge #1592
Browse files Browse the repository at this point in the history
1592: Always set `PYO3_PYTHON` if interpreter is runnable regardless of abi3 r=messense a=messense

It can be useful in build scripts, like pyca/cryptography#8815 (comment)

Co-authored-by: messense <[email protected]>
  • Loading branch information
bors[bot] and messense authored May 6, 2023
2 parents ea793e8 + 084111f commit 8af9efe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,7 @@ pub fn find_bridge(cargo_metadata: &Metadata, bridge: Option<&str>) -> Result<Br

if !(bridge.is_bindings("pyo3") || bridge.is_bindings("pyo3-ffi")) {
eprintln!("🔗 Found {bridge} bindings");
return Ok(bridge);
}

for &lib in PYO3_BINDING_CRATES.iter() {
Expand Down
11 changes: 8 additions & 3 deletions src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{BuildContext, PythonInterpreter, Target};
use anyhow::{anyhow, bail, Context, Result};
use fat_macho::FatWriter;
use fs_err::{self as fs, File};
use normpath::PathExt;
use std::collections::HashMap;
use std::env;
use std::io::{BufReader, Read};
Expand Down Expand Up @@ -369,9 +370,12 @@ fn compile_target(
if interpreter.runnable {
if bridge_model.is_bindings("pyo3")
|| bridge_model.is_bindings("pyo3-ffi")
|| (matches!(bridge_model, BridgeModel::BindingsAbi3(_, _))
&& interpreter.interpreter_kind.is_pypy())
|| matches!(bridge_model, BridgeModel::BindingsAbi3(_, _))
{
debug!(
"Setting PYO3_PYTHON to {}",
interpreter.executable.display()
);
build_command
.env("PYO3_PYTHON", &interpreter.executable)
.env(
Expand Down Expand Up @@ -401,7 +405,8 @@ fn compile_target(
config_file.display()
)
})?;
build_command.env("PYO3_CONFIG_FILE", config_file);
let abs_config_file = config_file.normalize()?.into_path_buf();
build_command.env("PYO3_CONFIG_FILE", abs_config_file);
}
}

Expand Down

0 comments on commit 8af9efe

Please sign in to comment.