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. 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") } }