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 <[email protected]>
  • Loading branch information
bors[bot] and messense authored Nov 11, 2022
2 parents 25d427f + ea26598 commit d64e1a1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
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 5 minutes
slow-timeout = { period = "60s", terminate-after = 5 }
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
1 change: 1 addition & 0 deletions tests/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ fn integration_pyo3_mixed_src_layout() {
}

#[test]
#[cfg_attr(target_os = "macos", ignore)] // Don't run it on macOS, too slow
fn integration_pyo3_pure_conda() {
// Only run on GitHub Actions for now
if std::env::var("GITHUB_ACTIONS").is_ok() {
Expand Down

0 comments on commit d64e1a1

Please sign in to comment.