1 From 42a97ee7100ad158d4b1ba6133ea13cc864a567f Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Vesa=20J=C3=A4=C3=A4skel=C3=A4inen?=
3 <vesa.jaaskelainen@vaisala.com>
4 Date: Sun, 1 Sep 2024 09:23:10 +0300
5 Subject: [PATCH 1/5] Extract extension architecture name resolvation code as
8 Content-Type: text/plain; charset=UTF-8
9 Content-Transfer-Encoding: 8bit
11 This commit introduces helper InterpreterConfig.get_python_ext_arch() that
12 can be used to determine the extension architecture name python uses in
13 `ext_suffix` for this architecture.
15 Upstream-Status: Backport [https://github.com/PyO3/maturin/commit/42a97ee7100ad158d4b1ba6133ea13cc864a567f]
17 Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com>
19 src/python_interpreter/config.rs | 18 ++++++------------
20 src/target.rs | 16 ++++++++++++++++
21 2 files changed, 22 insertions(+), 12 deletions(-)
23 diff --git a/src/python_interpreter/config.rs b/src/python_interpreter/config.rs
24 index 912f9218..d76606f2 100644
25 --- a/src/python_interpreter/config.rs
26 +++ b/src/python_interpreter/config.rs
27 @@ -47,15 +47,7 @@ impl InterpreterConfig {
28 // Python 2 is not supported
31 - let python_arch = if matches!(target.target_arch(), Arch::Armv6L | Arch::Armv7L) {
33 - } else if matches!(target.target_arch(), Arch::Powerpc64Le) && python_impl == PyPy {
35 - } else if matches!(target.target_arch(), Arch::X86) && python_impl == PyPy {
38 - target.get_python_arch()
40 + let python_ext_arch = target.get_python_ext_arch(python_impl);
41 // See https://github.com/pypa/auditwheel/issues/349
42 let target_env = match python_impl {
44 @@ -77,7 +69,7 @@ impl InterpreterConfig {
45 let ldversion = format!("{}{}{}", major, minor, abiflags);
46 let ext_suffix = format!(
47 ".cpython-{}-{}-linux-{}.so",
48 - ldversion, python_arch, target_env
49 + ldversion, python_ext_arch, target_env
53 @@ -90,7 +82,8 @@ impl InterpreterConfig {
55 (Os::Linux, PyPy) => {
56 let abi_tag = format!("pypy{}{}-{}", major, minor, PYPY_ABI_TAG);
57 - let ext_suffix = format!(".{}-{}-linux-{}.so", abi_tag, python_arch, target_env);
59 + format!(".{}-{}-linux-{}.so", abi_tag, python_ext_arch, target_env);
63 @@ -204,7 +197,8 @@ impl InterpreterConfig {
65 (Os::Emscripten, CPython) => {
66 let ldversion = format!("{}{}", major, minor);
67 - let ext_suffix = format!(".cpython-{}-{}-emscripten.so", ldversion, python_arch);
69 + format!(".cpython-{}-{}-emscripten.so", ldversion, python_ext_arch);
73 diff --git a/src/target.rs b/src/target.rs
74 index dc7df0cf..84bae559 100644
78 use crate::cross_compile::is_cross_compiling;
79 +use crate::python_interpreter::InterpreterKind;
80 use crate::PlatformTag;
81 use anyhow::{anyhow, bail, format_err, Result};
83 @@ -368,6 +369,21 @@ impl Target {
87 + /// Returns the extension architecture name python uses in `ext_suffix` for this architecture.
88 + pub fn get_python_ext_arch(&self, python_impl: InterpreterKind) -> &str {
89 + if matches!(self.target_arch(), Arch::Armv6L | Arch::Armv7L) {
91 + } else if matches!(self.target_arch(), Arch::Powerpc64Le)
92 + && python_impl == InterpreterKind::PyPy
95 + } else if matches!(self.target_arch(), Arch::X86) && python_impl == InterpreterKind::PyPy {
98 + self.get_python_arch()
102 /// Returns the name python uses in `sys.platform` for this os
103 pub fn get_python_os(&self) -> &str {