Skip to content

Commit 5c681ca

Browse files
committed
support python3-dll-a free-threaded generation (#4749)
1 parent 3cb0b87 commit 5c681ca

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

newsfragments/4749.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix failure to link on Windows free-threaded Python when using the `generate-import-lib` feature.

newsfragments/4749.packaging.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bump optional `python3-dll-a` dependency to 0.2.11.

pyo3-build-config/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ rust-version = "1.63"
1313

1414
[dependencies]
1515
once_cell = "1"
16-
python3-dll-a = { version = "0.2.6", optional = true }
16+
python3-dll-a = { version = "0.2.11", optional = true }
1717
target-lexicon = "0.12.14"
1818

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

2323
[features]

pyo3-build-config/src/impl_.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,17 @@ print("gil_disabled", get_config_var("Py_GIL_DISABLED"))
554554
if self.lib_dir.is_none() {
555555
let target = target_triple_from_env();
556556
let py_version = if self.abi3 { None } else { Some(self.version) };
557-
self.lib_dir =
558-
import_lib::generate_import_lib(&target, self.implementation, py_version)?;
557+
let abiflags = if self.is_free_threaded() {
558+
Some("t")
559+
} else {
560+
None
561+
};
562+
self.lib_dir = import_lib::generate_import_lib(
563+
&target,
564+
self.implementation,
565+
py_version,
566+
abiflags,
567+
)?;
559568
}
560569
Ok(())
561570
}
@@ -1521,6 +1530,7 @@ fn default_cross_compile(cross_compile_config: &CrossCompileConfig) -> Result<In
15211530
.implementation
15221531
.unwrap_or(PythonImplementation::CPython),
15231532
py_version,
1533+
None,
15241534
)?;
15251535
}
15261536

@@ -1889,6 +1899,7 @@ pub fn make_interpreter_config() -> Result<InterpreterConfig> {
18891899
&host,
18901900
interpreter_config.implementation,
18911901
py_version,
1902+
None,
18921903
)?;
18931904
}
18941905

pyo3-build-config/src/import_lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub(super) fn generate_import_lib(
1919
target: &Triple,
2020
py_impl: PythonImplementation,
2121
py_version: Option<PythonVersion>,
22+
abiflags: Option<&str>,
2223
) -> Result<Option<String>> {
2324
if target.operating_system != OperatingSystem::Windows {
2425
return Ok(None);
@@ -50,6 +51,7 @@ pub(super) fn generate_import_lib(
5051
ImportLibraryGenerator::new(&arch, &env)
5152
.version(py_version.map(|v| (v.major, v.minor)))
5253
.implementation(implementation)
54+
.abiflags(abiflags)
5355
.generate(&out_lib_dir)
5456
.context("failed to generate python3.dll import library")?;
5557

0 commit comments

Comments
 (0)