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 + 41298d7 commit 93bbf2b
Show file tree
Hide file tree
Showing 2 changed files with 12 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
14 changes: 11 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 All @@ -389,7 +393,11 @@ fn compile_target(
&& env::var_os("PYO3_CONFIG_FILE").is_none()
{
let pyo3_config = interpreter.pyo3_config_file();
let maturin_target_dir = context.target_dir.join("maturin");
let maturin_target_dir = context
.target_dir
.join("maturin")
.normalize()?
.into_path_buf();
let config_file = maturin_target_dir.join(format!(
"pyo3-config-{}-{}.{}.txt",
target_triple, interpreter.major, interpreter.minor
Expand Down

0 comments on commit 93bbf2b

Please sign in to comment.