Skip to content

Commit

Permalink
Merge #1263
Browse files Browse the repository at this point in the history
1263: Add support for `PYO3_ENVIRONMENT_SIGNATURE` r=messense a=messense

xref PyO3/pyo3#2727

Co-authored-by: messense <messense@icloud.com>
  • Loading branch information
bors[bot] and messense committed Nov 11, 2022
2 parents 25d427f + 5675820 commit 540d793
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[profile.default]
# Terminate slow tests after 3 minutes
slow-timeout = { period = "60s", terminate-after = 3 }
7 changes: 6 additions & 1 deletion src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,12 @@ fn compile_target(
|| (matches!(bindings_crate, BridgeModel::BindingsAbi3(_, _))
&& interpreter.interpreter_kind.is_pypy())
{
build_command.env("PYO3_PYTHON", &interpreter.executable);
build_command
.env("PYO3_PYTHON", &interpreter.executable)
.env(
"PYO3_ENVIRONMENT_SIGNATURE",
interpreter.environment_signature(),
);
}

// rust-cpython, and legacy pyo3 versions
Expand Down
10 changes: 10 additions & 0 deletions src/python_interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,16 @@ impl PythonInterpreter {
}
}
}

/// An opaque string that uniquely identifies this Python interpreter.
/// Used to trigger rebuilds for `pyo3` when the Python interpreter changes.
pub fn environment_signature(&self) -> String {
let pointer_width = self.pointer_width.unwrap_or(64);
format!(
"{}-{}.{}-{}bit",
self.implmentation_name, self.major, self.minor, pointer_width
)
}
}

impl fmt::Display for PythonInterpreter {
Expand Down

0 comments on commit 540d793

Please sign in to comment.