Skip to content

Commit

Permalink
pyo3-build-config: fix build for windows gnu targets
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Aug 5, 2021
1 parent 49387e9 commit 96fefc9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix regression in 0.14.0 leading to incorrect code coverage being computed for `#[pyfunction]`s. [#1726](https://github.com/PyO3/pyo3/pull/1726)
- Fix incorrect FFI definition of `Py_Buffer` on PyPy. [#1737](https://github.com/PyO3/pyo3/pull/1737)
- Fix incorrect calculation of `dictoffset` on 32-bit Windows. [#1475](https://github.com/PyO3/pyo3/pull/1475)
- Fix regression in 0.13.2 leading to linking to incorrect Python library on Windows "gnu" targets. [#1759](https://github.com/PyO3/pyo3/pull/1759)

## [0.14.1] - 2021-07-04

Expand Down
15 changes: 6 additions & 9 deletions pyo3-build-config/src/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ import os.path
import platform
import struct
import sys
from sysconfig import get_config_var
from sysconfig import get_config_var, get_platform
PYPY = platform.python_implementation() == "PyPy"
Expand Down Expand Up @@ -132,6 +132,7 @@ print_if_set("libdir", get_config_var("LIBDIR"))
print_if_set("base_prefix", base_prefix)
print("executable", sys.executable)
print("calcsize_pointer", struct.calcsize("P"))
print("mingw", get_platform() == "mingw")
"#;
let output = run_python_script(interpreter.as_ref(), script)?;
let map: HashMap<String, String> = parse_script_output(&output);
Expand All @@ -150,11 +151,7 @@ print("calcsize_pointer", struct.calcsize("P"))
let implementation = map["implementation"].parse()?;

let lib_name = if cfg!(windows) {
default_lib_name_windows(
&version,
abi3,
&cargo_env_var("CARGO_CFG_TARGET_ENV").unwrap(),
)
default_lib_name_windows(&version, abi3, map["mingw"].as_str() == "True")
} else {
default_lib_name_unix(
&version,
Expand Down Expand Up @@ -895,7 +892,7 @@ fn windows_hardcoded_cross_compile(
version,
shared: true,
abi3: is_abi3(),
lib_name: Some(default_lib_name_windows(&version, false, "msvc")),
lib_name: Some(default_lib_name_windows(&version, false, false)),
lib_dir: cross_compile_config.lib_dir.to_str().map(String::from),
executable: None,
pointer_width: None,
Expand Down Expand Up @@ -932,10 +929,10 @@ fn load_cross_compile_config(
// This contains only the limited ABI symbols.
const WINDOWS_ABI3_LIB_NAME: &str = "python3";

fn default_lib_name_windows(version: &PythonVersion, abi3: bool, target_env: &str) -> String {
fn default_lib_name_windows(version: &PythonVersion, abi3: bool, mingw: bool) -> String {
if abi3 {
WINDOWS_ABI3_LIB_NAME.to_owned()
} else if target_env == "gnu" {
} else if mingw {
// https://packages.msys2.org/base/mingw-w64-python
format!("python{}.{}", version.major, version.minor)
} else {
Expand Down

0 comments on commit 96fefc9

Please sign in to comment.