python-cryptography: patch pyo3 for cygwin support
and remove the MSYSTEM hack since maturin now works without it.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
From be3b2f227a6cc60e27f2b74e9f301bcc136183e6 Mon Sep 17 00:00:00 2001
|
||||
From: Christoph Reiter <reiter.christoph@gmail.com>
|
||||
Date: Wed, 29 Oct 2025 08:26:50 +0100
|
||||
Subject: [PATCH 1/2] Explicitely link with libpython on Cygwin
|
||||
|
||||
Like with Windows Python, under Cygwin we need to explicitely
|
||||
link with libpython.
|
||||
|
||||
Thix fixes the build under Cygwin.
|
||||
---
|
||||
pyo3-build-config/src/impl_.rs | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs
|
||||
index cca9393d..b977ac79 100644
|
||||
--- a/pyo3-build-config/src/impl_.rs
|
||||
+++ b/pyo3-build-config/src/impl_.rs
|
||||
@@ -890,6 +890,7 @@ pub fn is_linking_libpython_for_target(target: &Triple) -> bool {
|
||||
|| target.operating_system == OperatingSystem::Aix
|
||||
|| target.environment == Environment::Android
|
||||
|| target.environment == Environment::Androideabi
|
||||
+ || target.operating_system == OperatingSystem::Cygwin
|
||||
|| !is_extension_module()
|
||||
}
|
||||
|
||||
--
|
||||
2.51.2
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
From 3fe4e71b229a0c9d01ab3df500b2ca4779e48ee5 Mon Sep 17 00:00:00 2001
|
||||
From: Christoph Reiter <reiter.christoph@gmail.com>
|
||||
Date: Wed, 29 Oct 2025 08:28:46 +0100
|
||||
Subject: [PATCH 2/2] Link against limited API DLL under Cygwin when abi3 is
|
||||
used
|
||||
|
||||
Like with Windows Python, we need to link to a different
|
||||
DLL which exports the limited API when using abi3.
|
||||
|
||||
This makes pyo3 link against python3.dll instead of
|
||||
python3.XY.dll when abi3 is enabled.
|
||||
|
||||
Note: The limited API DLL is currently not provided in
|
||||
cygwin upstream, but only in MSYS2 for now:
|
||||
https://github.com/msys2/MSYS2-packages/pull/5751
|
||||
---
|
||||
pyo3-build-config/src/impl_.rs | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs
|
||||
index b977ac79..90a79e35 100644
|
||||
--- a/pyo3-build-config/src/impl_.rs
|
||||
+++ b/pyo3-build-config/src/impl_.rs
|
||||
@@ -263,6 +263,7 @@ print_if_set("base_prefix", base_prefix)
|
||||
print("executable", sys.executable)
|
||||
print("calcsize_pointer", struct.calcsize("P"))
|
||||
print("mingw", get_platform().startswith("mingw"))
|
||||
+print("cygwin", get_platform().startswith("cygwin"))
|
||||
print("ext_suffix", get_config_var("EXT_SUFFIX"))
|
||||
print("gil_disabled", get_config_var("Py_GIL_DISABLED"))
|
||||
"#;
|
||||
@@ -315,6 +316,8 @@ print("gil_disabled", get_config_var("Py_GIL_DISABLED"))
|
||||
_ => panic!("Unknown Py_GIL_DISABLED value"),
|
||||
};
|
||||
|
||||
+ let cygwin = map["cygwin"].as_str() == "True";
|
||||
+
|
||||
let lib_name = if cfg!(windows) {
|
||||
default_lib_name_windows(
|
||||
version,
|
||||
@@ -327,6 +330,8 @@ print("gil_disabled", get_config_var("Py_GIL_DISABLED"))
|
||||
map["ext_suffix"].starts_with("_d."),
|
||||
gil_disabled,
|
||||
)?
|
||||
+ } else if cygwin && abi3 {
|
||||
+ "python3".to_string()
|
||||
} else {
|
||||
default_lib_name_unix(
|
||||
version,
|
||||
--
|
||||
2.51.2
|
||||
|
||||
@@ -22,18 +22,32 @@ makedepends=(
|
||||
'openssl-devel'
|
||||
'pkgconf'
|
||||
)
|
||||
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
|
||||
sha256sums=('a8b17438104fed022ce745b362294d9ce35b4c2e45c1d958ad4a4b019285f4a1')
|
||||
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz"
|
||||
"https://github.com/PyO3/pyo3/archive/refs/tags/v0.26.0.tar.gz"
|
||||
"0001-Explicitely-link-with-libpython-on-Cygwin.patch"
|
||||
"0002-Link-against-limited-API-DLL-under-Cygwin-when-abi3-.patch")
|
||||
sha256sums=('a8b17438104fed022ce745b362294d9ce35b4c2e45c1d958ad4a4b019285f4a1'
|
||||
'8b6ed2db5038ad30cd6e408bbfa514182e9ae30c50aa34c3184a4e98df1603cf'
|
||||
'2c2eddb7793eed07bdc389be4e853b63897475f93cc59e64b298c73919ff6337'
|
||||
'177e197e4f54c1300d5bf29472080c0c3e2c13f5501968ae8678b83b32750485')
|
||||
|
||||
prepare() {
|
||||
cd "pyo3-0.26.0"
|
||||
patch -p1 -i ../0001-Explicitely-link-with-libpython-on-Cygwin.patch
|
||||
patch -p1 -i ../0002-Link-against-limited-API-DLL-under-Cygwin-when-abi3-.patch
|
||||
|
||||
cd "${srcdir}/${_realname}-${pkgver}"
|
||||
cat >> Cargo.toml <<END
|
||||
|
||||
[patch.crates-io]
|
||||
pyo3-build-config = { path = "../pyo3-0.26.0/pyo3-build-config" }
|
||||
END
|
||||
cargo update -p pyo3-build-config
|
||||
}
|
||||
|
||||
build() {
|
||||
cd "${_realname}-${pkgver}"
|
||||
|
||||
# XXX: to fix maturin OS detection
|
||||
export MSYSTEM=CYGWIN
|
||||
|
||||
# XXX: this should be handled by maturin/pyo3 somehow
|
||||
export RUSTFLAGS="-C link-arg=-lpython3"
|
||||
|
||||
python -m build --wheel --no-isolation
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user