diff --git a/guide/src/building_and_distribution.md b/guide/src/building_and_distribution.md index 2c39f2db..b708dcf3 100644 --- a/guide/src/building_and_distribution.md +++ b/guide/src/building_and_distribution.md @@ -45,6 +45,8 @@ Caused by: suppress_build_script_link_lines=false ``` +The `PYO3_ENVIRONMENT_SIGNATURE` environment variable can be used to trigger rebuilds when its value changes, it has no other effect. + ### Advanced: config files If you save the above output config from `PYO3_PRINT_CONFIG` to a file, it is possible to manually override the contents and feed it back into PyO3 using the `PYO3_CONFIG_FILE` env var. diff --git a/newsfragments/2727.added.md b/newsfragments/2727.added.md new file mode 100644 index 00000000..bfc836d8 --- /dev/null +++ b/newsfragments/2727.added.md @@ -0,0 +1 @@ +`pyo3-build-config`: rebuild when `PYO3_ENVIRONMENT_SIGNATURE` environment variable value changed diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs index 30756585..63cf1884 100644 --- a/pyo3-build-config/src/impl_.rs +++ b/pyo3-build-config/src/impl_.rs @@ -1684,6 +1684,10 @@ fn get_env_interpreter() -> Option { /// 3. `python`, if this is functional a Python 3.x interpreter /// 4. `python3`, as above pub fn find_interpreter() -> Result { + // Trigger rebuilds when `PYO3_ENVIRONMENT_SIGNATURE` env var value changes + // See https://github.com/PyO3/pyo3/issues/2724 + println!("cargo:rerun-if-env-changed=PYO3_ENVIRONMENT_SIGNATURE"); + if let Some(exe) = env_var("PYO3_PYTHON") { Ok(exe.into()) } else if let Some(env_interpreter) = get_env_interpreter() {