From 330a8b78694c3824503f30b2499eab43ad5c97e0 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Thu, 30 Apr 2026 14:13:07 +0100 Subject: [PATCH 1/2] trigger rebuilds when virtualenv changes --- pyo3-build-config/src/impl_.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs index 3d64cb34e4c..9d6a4666eb5 100644 --- a/pyo3-build-config/src/impl_.rs +++ b/pyo3-build-config/src/impl_.rs @@ -1818,10 +1818,16 @@ where } fn venv_interpreter(virtual_env: &OsStr, windows: bool) -> PathBuf { + let venv = Path::new(virtual_env); + // Rebuild if the virtual environment configuration changes + println!( + "cargo:rerun-if-changed={}", + venv.join("pyvenv.cfg").display() + ); if windows { - Path::new(virtual_env).join("Scripts").join("python.exe") + venv.join("Scripts").join("python.exe") } else { - Path::new(virtual_env).join("bin").join("python") + venv.join("bin").join("python") } } From 9b42f6aa71bfff5a1b9510f2d2f765a7ed9091fe Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Thu, 30 Apr 2026 14:29:50 +0100 Subject: [PATCH 2/2] newsfragment --- newsfragments/6008.changed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/6008.changed.md diff --git a/newsfragments/6008.changed.md b/newsfragments/6008.changed.md new file mode 100644 index 00000000000..88acca63f4a --- /dev/null +++ b/newsfragments/6008.changed.md @@ -0,0 +1 @@ +`pyo3-ffi` will now rebuild when the Python virtual environment changes in-place.