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

Fixup lib_name when using PYO3_CONFIG_FILE #2404

Merged
merged 4 commits into from May 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 20 additions & 9 deletions pyo3-build-config/src/impl_.rs
Expand Up @@ -440,6 +440,25 @@ print("mingw", get_platform().startswith("mingw"))
let version = version.ok_or("missing value for version")?;
let implementation = implementation.unwrap_or(PythonImplementation::CPython);
let abi3 = abi3.unwrap_or(false);
// Fixup lib_name if it's not set
let lib_name = lib_name.or_else(|| {
if let Ok(Ok(target)) = env::var("TARGET").map(|target| target.parse::<Triple>()) {
if target.operating_system == OperatingSystem::Windows {
messense marked this conversation as resolved.
Show resolved Hide resolved
Some(default_lib_name_windows(
version,
implementation,
abi3,
false,
))
} else if is_linking_libpython_for_target(&target) {
Some(default_lib_name_unix(version, implementation, None))
} else {
None
}
} else {
None
}
});

Ok(InterpreterConfig {
implementation,
Expand All @@ -458,19 +477,11 @@ print("mingw", get_platform().startswith("mingw"))

#[allow(clippy::unnecessary_wraps)]
pub fn fixup_import_libs(&mut self) -> Result<()> {
adamreichold marked this conversation as resolved.
Show resolved Hide resolved
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 target = target_triple_from_env();
let py_version = if self.abi3 { None } else { Some(self.version) };
self.lib_dir = self::import_lib::generate_import_lib(&target, py_version)?;
}
Expand Down