Merge pull request #1231 from PyO3/dont-watch-path

Don't watch PYTHON_SYS_EXECUTABLE and PATH when unnecessary
This commit is contained in:
David Hewitt 2020-10-12 18:14:47 +01:00 committed by GitHub
commit 576c6b191c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 9 deletions

View File

@ -893,17 +893,20 @@ fn main() -> Result<()> {
// TODO: Find out how we can set -undefined dynamic_lookup here (if this is possible)
}
let env_vars = [
"LD_LIBRARY_PATH",
"PATH",
"PYTHON_SYS_EXECUTABLE",
"PYO3_PYTHON",
"LIB",
];
for var in env_vars.iter() {
for var in ["LIB", "LD_LIBRARY_PATH", "PYO3_PYTHON"].iter() {
println!("cargo:rerun-if-env-changed={}", var);
}
if env::var_os("PYO3_PYTHON").is_none() {
// When PYO3_PYTHON is not used, PYTHON_SYS_EXECUTABLE has the highest priority.
// Let's watch it.
println!("cargo:rerun-if-env-changed=PYTHON_SYS_EXECUTABLE");
if env::var_os("PYTHON_SYS_EXECUTABLE").is_none() {
// When PYTHON_SYS_EXECUTABLE is also not used, then we use PATH.
// Let's watch this, too.
println!("cargo:rerun-if-env-changed=PATH");
}
}
Ok(())
}