Merge pull request #2372 from messense/interpreter-config-import-lib
Auto generate Windows import libraries when using a pyo3 config file
This commit is contained in:
commit
a8b74a7f33
|
@ -456,6 +456,28 @@ print("mingw", get_platform().startswith("mingw"))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::unnecessary_wraps)]
|
||||||
|
pub fn fixup_import_libs(&mut self) -> Result<()> {
|
||||||
|
let target = target_triple_from_env();
|
||||||
|
if self.lib_name.is_none() && target.operating_system == OperatingSystem::Windows {
|
||||||
|
self.lib_name = Some(default_lib_name_windows(
|
||||||
|
self.version,
|
||||||
|
self.implementation,
|
||||||
|
self.abi3,
|
||||||
|
false,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
// Auto generate python3.dll import libraries for Windows targets.
|
||||||
|
#[cfg(feature = "python3-dll-a")]
|
||||||
|
{
|
||||||
|
if self.lib_dir.is_none() {
|
||||||
|
let py_version = if self.abi3 { None } else { Some(self.version) };
|
||||||
|
self.lib_dir = self::import_lib::generate_import_lib(&target, py_version)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
/// Serialize the `InterpreterConfig` and print it to the environment for Cargo to pass along
|
/// Serialize the `InterpreterConfig` and print it to the environment for Cargo to pass along
|
||||||
/// to dependent packages during build time.
|
/// to dependent packages during build time.
|
||||||
|
|
|
@ -177,7 +177,9 @@ pub mod pyo3_build_script_impl {
|
||||||
#[cfg(feature = "resolve-config")]
|
#[cfg(feature = "resolve-config")]
|
||||||
pub fn resolve_interpreter_config() -> Result<InterpreterConfig> {
|
pub fn resolve_interpreter_config() -> Result<InterpreterConfig> {
|
||||||
if !CONFIG_FILE.is_empty() {
|
if !CONFIG_FILE.is_empty() {
|
||||||
InterpreterConfig::from_reader(Cursor::new(CONFIG_FILE))
|
let mut interperter_config = InterpreterConfig::from_reader(Cursor::new(CONFIG_FILE))?;
|
||||||
|
interperter_config.fixup_import_libs()?;
|
||||||
|
Ok(interperter_config)
|
||||||
} else if let Some(interpreter_config) = make_cross_compile_config()? {
|
} else if let Some(interpreter_config) = make_cross_compile_config()? {
|
||||||
// This is a cross compile and need to write the config file.
|
// This is a cross compile and need to write the config file.
|
||||||
let path = resolve_cross_compile_config_path()
|
let path = resolve_cross_compile_config_path()
|
||||||
|
|
Loading…
Reference in New Issue