From d03bdc96e2ea3441c6c568329e1c9ccff3f220a2 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Mon, 27 Oct 2025 20:09:54 +0100 Subject: [PATCH] maturin: more cygwin fixes Partly inspired from https://github.com/PyO3/maturin/pull/2765 --- maturin/0002-cygwin-support.patch | 92 +++++++++++++++++++++++++++++++ maturin/PKGBUILD | 10 +++- 2 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 maturin/0002-cygwin-support.patch diff --git a/maturin/0002-cygwin-support.patch b/maturin/0002-cygwin-support.patch new file mode 100644 index 00000000..5f8304f7 --- /dev/null +++ b/maturin/0002-cygwin-support.patch @@ -0,0 +1,92 @@ +--- maturin-1.9.6/src/target/mod.rs.orig 2025-10-07 14:34:28.000000000 +0200 ++++ maturin-1.9.6/src/target/mod.rs 2025-10-27 18:39:27.311185000 +0100 +@@ -43,6 +43,7 @@ + Wasi, + Aix, + Hurd, ++ Cygwin, + } + + impl fmt::Display for Os { +@@ -63,6 +64,7 @@ + Os::Wasi => write!(f, "Wasi"), + Os::Aix => write!(f, "AIX"), + Os::Hurd => write!(f, "Hurd"), ++ Os::Cygwin => write!(f, "Cygwin"), + } + } + } +@@ -209,6 +211,7 @@ + Os::Emscripten | Os::Wasi => vec![Arch::Wasm32], + Os::Aix => vec![Arch::Powerpc64], + Os::Hurd => vec![Arch::X86, Arch::X86_64], ++ Os::Cygwin => vec![Arch::X86, Arch::X86_64], + } + } + +@@ -283,6 +286,7 @@ + OperatingSystem::Wasi | OperatingSystem::WasiP1 | OperatingSystem::WasiP2 => Os::Wasi, + OperatingSystem::Aix => Os::Aix, + OperatingSystem::Hurd => Os::Hurd, ++ OperatingSystem::Cygwin => Os::Cygwin, + unsupported => bail!("The operating system {:?} is not supported", unsupported), + }; + +@@ -463,6 +467,7 @@ + Os::Wasi => "wasi", + Os::Aix => "aix", + Os::Hurd => "gnu", ++ Os::Cygwin => "cygwin", + } + } + +@@ -558,7 +563,8 @@ + | Os::Emscripten + | Os::Wasi + | Os::Aix +- | Os::Hurd => true, ++ | Os::Hurd ++ | Os::Cygwin => true, + } + } + +--- maturin-1.9.6/src/python_interpreter/mod.rs.orig 2025-10-07 14:34:28.000000000 +0200 ++++ maturin-1.9.6/src/python_interpreter/mod.rs 2025-10-27 18:57:13.775589900 +0100 +@@ -292,6 +292,7 @@ + if bridge != &BridgeModel::Cffi + && target.get_python_os() != message.system + && !target.cross_compiling() ++ && (target.get_python_os() == "cygwin" && !message.system.to_lowercase().starts_with("cygwin")) + { + bail!( + "platform.system() in python, {}, and the rust target, {:?}, don't match ಠ_ಠ", +--- maturin-1.9.6/src/target/mod.rs.orig 2025-10-07 14:34:28.000000000 +0200 ++++ maturin-1.9.6/src/target/mod.rs 2025-10-27 20:03:22.265265400 +0100 +@@ -610,6 +610,12 @@ + self.env == Environment::Msvc + } + ++ /// Returns true if the current platform is cygwin ++ #[inline] ++ pub fn is_cygwin(&self) -> bool { ++ self.os == Os::Cygwin ++ } ++ + /// Returns true if the current platform is illumos + #[inline] + pub fn is_illumos(&self) -> bool { +--- maturin-1.9.6/src/module_writer.rs.orig 2025-10-07 14:34:28.000000000 +0200 ++++ maturin-1.9.6/src/module_writer.rs 2025-10-27 20:04:48.501685200 +0100 +@@ -855,7 +855,11 @@ + let ext_name = &project_layout.extension_name; + let so_filename = if is_abi3 { + if target.is_unix() { +- format!("{ext_name}.abi3.so") ++ if target.is_cygwin() { ++ format!("{ext_name}.abi3.dll") ++ } else { ++ format!("{ext_name}.abi3.so") ++ } + } else { + match python_interpreter { + Some(python_interpreter) if python_interpreter.is_windows_debug() => { diff --git a/maturin/PKGBUILD b/maturin/PKGBUILD index 367252a4..18e18ed1 100644 --- a/maturin/PKGBUILD +++ b/maturin/PKGBUILD @@ -3,7 +3,7 @@ pkgbase=maturin pkgname=("python-maturin" "maturin") pkgver=1.9.6 -pkgrel=2 +pkgrel=3 pkgdesc='Build and publish crates with pyo3, rust-cpython and cffi bindings' arch=('x86_64') url='https://www.maturin.rs/' @@ -25,17 +25,21 @@ source=("https://pypi.org/packages/source/${pkgbase::1}/${pkgbase}/${pkgbase}-${ "getrandom-0.2.15.tar.gz::https://crates.io/api/v1/crates/getrandom/0.2.15/download" "maturin-update-deps.patch" "tar-rs-update-deps.patch" - "getrandom-support-cygwin.patch") + "getrandom-support-cygwin.patch" + "0002-cygwin-support.patch") sha256sums=('2c2ae37144811d365509889ed7220b0598487f1278c2441829c3abf56cc6324a' 'c65998313f8e17d0d553d28f91a0df93e4dbbbf770279c7bc21ca0f09ea1a1f6' 'c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7' '36bb5955216d19aed9a8fb2ec9440e7e3133de2e7d5ed1da2ad2204d449a2095' '2422ed08564445528695499757258aecde785bb6e95cde2d88f4b2cefe8417d8' - 'acac76aa379bc45285f067524d7c5adceb3100698d72ae150a6b626a137e947d') + 'acac76aa379bc45285f067524d7c5adceb3100698d72ae150a6b626a137e947d' + '8290bd5ee62abad58428932a739b899afa7472a959aa6629d4a54a2bf7bf59c8') prepare() { cp -r "${pkgbase}-${pkgver}" "python-build" && cd "python-build" + patch -Np1 -i ../0002-cygwin-support.patch + # support cygwin in some deps patch -d ../getrandom-0.2.15 -p1 -i ../getrandom-support-cygwin.patch # update deps to add cygwin support