Skip to content
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/4800.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: cross-compilation compatibility checks for Windows
16 changes: 14 additions & 2 deletions pyo3-build-config/src/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::{

pub use target_lexicon::Triple;

use target_lexicon::{Environment, OperatingSystem};
use target_lexicon::{Architecture, Environment, OperatingSystem};

use crate::{
bail, ensure,
Expand Down Expand Up @@ -931,7 +931,9 @@ impl CrossCompileConfig {

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

// Not cross-compiling to compile for x86-64 Python from macOS arm64 and vice versa
compatible |= target.operating_system == OperatingSystem::Darwin
Expand Down Expand Up @@ -2894,6 +2896,16 @@ mod tests {
.is_none());
}

#[test]
fn test_is_cross_compiling_from_to() {
assert!(cross_compiling_from_to(
&triple!("x86_64-pc-windows-msvc"),
&triple!("aarch64-pc-windows-msvc")
)
.unwrap()
.is_some());
}

#[test]
fn test_run_python_script() {
// as above, this should be okay in CI where Python is presumed installed
Expand Down
Loading