Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyo3-build-config: rebuild when PYO3_ENVIRONMENT_SIGNATURE value changed #2727

Merged
merged 1 commit into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions guide/src/building_and_distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions newsfragments/2727.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`pyo3-build-config`: rebuild when `PYO3_ENVIRONMENT_SIGNATURE` environment variable value changed
4 changes: 4 additions & 0 deletions pyo3-build-config/src/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,10 @@ fn get_env_interpreter() -> Option<PathBuf> {
/// 3. `python`, if this is functional a Python 3.x interpreter
/// 4. `python3`, as above
pub fn find_interpreter() -> Result<PathBuf> {
// 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() {
Expand Down