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

support python3-dll-a free-threaded generation #4749

Merged
merged 1 commit into from
Dec 2, 2024
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
1 change: 1 addition & 0 deletions newsfragments/4749.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix failure to link on Windows free-threaded Python when using the `generate-import-lib` feature.
1 change: 1 addition & 0 deletions newsfragments/4749.packaging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bump optional `python3-dll-a` dependency to 0.2.11.
4 changes: 2 additions & 2 deletions pyo3-build-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ rust-version = "1.63"

[dependencies]
once_cell = "1"
python3-dll-a = { version = "0.2.6", optional = true }
python3-dll-a = { version = "0.2.11", optional = true }
target-lexicon = "0.12.14"

[build-dependencies]
python3-dll-a = { version = "0.2.6", optional = true }
python3-dll-a = { version = "0.2.11", optional = true }
target-lexicon = "0.12.14"

[features]
Expand Down
15 changes: 13 additions & 2 deletions pyo3-build-config/src/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,17 @@ print("gil_disabled", get_config_var("Py_GIL_DISABLED"))
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 =
import_lib::generate_import_lib(&target, self.implementation, py_version)?;
let abiflags = if self.is_free_threaded() {
Some("t")
} else {
None
};
self.lib_dir = import_lib::generate_import_lib(
&target,
self.implementation,
py_version,
abiflags,
)?;
}
Ok(())
}
Expand Down Expand Up @@ -1521,6 +1530,7 @@ fn default_cross_compile(cross_compile_config: &CrossCompileConfig) -> Result<In
.implementation
.unwrap_or(PythonImplementation::CPython),
py_version,
None,
)?;
}

Expand Down Expand Up @@ -1889,6 +1899,7 @@ pub fn make_interpreter_config() -> Result<InterpreterConfig> {
&host,
interpreter_config.implementation,
py_version,
None,
)?;
}

Expand Down
2 changes: 2 additions & 0 deletions pyo3-build-config/src/import_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub(super) fn generate_import_lib(
target: &Triple,
py_impl: PythonImplementation,
py_version: Option<PythonVersion>,
abiflags: Option<&str>,
) -> Result<Option<String>> {
if target.operating_system != OperatingSystem::Windows {
return Ok(None);
Expand Down Expand Up @@ -50,6 +51,7 @@ pub(super) fn generate_import_lib(
ImportLibraryGenerator::new(&arch, &env)
.version(py_version.map(|v| (v.major, v.minor)))
.implementation(implementation)
.abiflags(abiflags)
.generate(&out_lib_dir)
.context("failed to generate python3.dll import library")?;

Expand Down
Loading