Skip to content

Commit

Permalink
support python3-dll-a free-threaded generation (#4749)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Dec 3, 2024
1 parent 3cb0b87 commit 5c681ca
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
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

0 comments on commit 5c681ca

Please sign in to comment.