Skip to content

Commit f2915f5

Browse files
kahojyundavidhewitt
authored andcommitted
fix: cross-compilation compatibility checks for Windows (#4800)
* fix: cross-compilation compatibility checks for Windows * add newsfragments * add simple test
1 parent 81eabed commit f2915f5

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

newsfragments/4800.fixed.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fix: cross-compilation compatibility checks for Windows

pyo3-build-config/src/impl_.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::{
2222

2323
pub use target_lexicon::Triple;
2424

25-
use target_lexicon::{Environment, OperatingSystem};
25+
use target_lexicon::{Architecture, Environment, OperatingSystem};
2626

2727
use crate::{
2828
bail, ensure,
@@ -944,7 +944,9 @@ impl CrossCompileConfig {
944944

945945
// Not cross-compiling to compile for 32-bit Python from windows 64-bit
946946
compatible |= target.operating_system == OperatingSystem::Windows
947-
&& host.operating_system == OperatingSystem::Windows;
947+
&& host.operating_system == OperatingSystem::Windows
948+
&& matches!(target.architecture, Architecture::X86_32(_))
949+
&& host.architecture == Architecture::X86_64;
948950

949951
// Not cross-compiling to compile for x86-64 Python from macOS arm64 and vice versa
950952
compatible |= target.operating_system == OperatingSystem::Darwin
@@ -2955,6 +2957,16 @@ mod tests {
29552957
.is_none());
29562958
}
29572959

2960+
#[test]
2961+
fn test_is_cross_compiling_from_to() {
2962+
assert!(cross_compiling_from_to(
2963+
&triple!("x86_64-pc-windows-msvc"),
2964+
&triple!("aarch64-pc-windows-msvc")
2965+
)
2966+
.unwrap()
2967+
.is_some());
2968+
}
2969+
29582970
#[test]
29592971
fn test_run_python_script() {
29602972
// as above, this should be okay in CI where Python is presumed installed

0 commit comments

Comments
 (0)