diff --git a/src/compile.rs b/src/compile.rs index c574eb8e4..0e8c8ab6b 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -454,10 +454,6 @@ fn cargo_build_command( } } - if let Some(lib_dir) = env::var_os("MATURIN_PYTHON_SYSCONFIGDATA_DIR") { - build_command.env("PYO3_CROSS_LIB_DIR", lib_dir); - } - // Set default macOS deployment target version for non-editable builds if !context.editable && target.is_macos() && env::var_os("MACOSX_DEPLOYMENT_TARGET").is_none() { use crate::build_context::rustc_macosx_target_version; diff --git a/src/python_interpreter/config.rs b/src/python_interpreter/config.rs index 6400fa954..7f42d2519 100644 --- a/src/python_interpreter/config.rs +++ b/src/python_interpreter/config.rs @@ -454,6 +454,9 @@ suppress_build_script_link_lines=false"#, if let Some(pointer_width) = self.pointer_width { write!(content, "\npointer_width={pointer_width}").unwrap(); } + if let Ok(lib_dir) = std::env::var("PYO3_CROSS_LIB_DIR") { + write!(content, "\nlib_dir={}", lib_dir).unwrap(); + } content } }