diff --git a/.config/nextest.toml b/.config/nextest.toml new file mode 100644 index 000000000..5b3871d63 --- /dev/null +++ b/.config/nextest.toml @@ -0,0 +1,3 @@ +[profile.default] +# Terminate slow tests after 5 minutes +slow-timeout = { period = "60s", terminate-after = 5 } diff --git a/src/compile.rs b/src/compile.rs index 1dd593613..80b01d348 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -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 diff --git a/src/python_interpreter/mod.rs b/src/python_interpreter/mod.rs index d46a45d58..f44a33dbc 100644 --- a/src/python_interpreter/mod.rs +++ b/src/python_interpreter/mod.rs @@ -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 {