|
|
71f264 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
71f264 |
From: Lumir Balhar <lbalhar@redhat.com>
|
|
|
71f264 |
Date: Tue, 4 Aug 2020 12:04:03 +0200
|
|
|
71f264 |
Subject: [PATCH] 00353: Original names for architectures with different names
|
|
|
71f264 |
downstream
|
|
|
71f264 |
MIME-Version: 1.0
|
|
|
71f264 |
Content-Type: text/plain; charset=UTF-8
|
|
|
71f264 |
Content-Transfer-Encoding: 8bit
|
|
|
71f264 |
|
|
|
71f264 |
https://fedoraproject.org/wiki/Changes/Python_Upstream_Architecture_Names
|
|
|
71f264 |
|
|
|
71f264 |
Pythons in RHEL/Fedora used different names for some architectures
|
|
|
71f264 |
than upstream and other distros (for example ppc64 vs. powerpc64).
|
|
|
71f264 |
This was patched in patch 274, now it is sedded if %with legacy_archnames.
|
|
|
71f264 |
|
|
|
71f264 |
That meant that an extension built with the default upstream settings
|
|
|
71f264 |
(on other distro or as an manylinux wheel) could not been found by Python
|
|
|
71f264 |
on RHEL/Fedora because it had a different suffix.
|
|
|
71f264 |
This patch adds the legacy names to importlib so Python is able
|
|
|
71f264 |
to import extensions with a legacy architecture name in its
|
|
|
71f264 |
file name.
|
|
|
71f264 |
It work both ways, so it support both %with and %without legacy_archnames.
|
|
|
71f264 |
|
|
|
71f264 |
WARNING: This patch has no effect on Python built with bootstrap
|
|
|
71f264 |
enabled because Python/importlib_external.h is not regenerated
|
|
|
71f264 |
and therefore Python during bootstrap contains importlib from
|
|
|
71f264 |
upstream without this feature. It's possible to include
|
|
|
71f264 |
Python/importlib_external.h to this patch but it'd make rebasing
|
|
|
71f264 |
a nightmare because it's basically a binary file.
|
|
|
71f264 |
|
|
|
71f264 |
Co-authored-by: Miro HronĨok <miro@hroncok.cz>
|
|
|
71f264 |
---
|
|
|
71f264 |
Lib/importlib/_bootstrap_external.py | 40 ++++++++++++++++++++++++++--
|
|
|
71f264 |
1 file changed, 38 insertions(+), 2 deletions(-)
|
|
|
71f264 |
|
|
|
71f264 |
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
|
|
|
71f264 |
index 9feec50842..5bb2454a5c 100644
|
|
|
71f264 |
--- a/Lib/importlib/_bootstrap_external.py
|
|
|
71f264 |
+++ b/Lib/importlib/_bootstrap_external.py
|
|
|
71f264 |
@@ -1361,7 +1361,7 @@ def _get_supported_file_loaders():
|
|
|
71f264 |
|
|
|
71f264 |
Each item is a tuple (loader, suffixes).
|
|
|
71f264 |
"""
|
|
|
71f264 |
- extensions = ExtensionFileLoader, _imp.extension_suffixes()
|
|
|
71f264 |
+ extensions = ExtensionFileLoader, _alternative_architectures(_imp.extension_suffixes())
|
|
|
71f264 |
source = SourceFileLoader, SOURCE_SUFFIXES
|
|
|
71f264 |
bytecode = SourcelessFileLoader, BYTECODE_SUFFIXES
|
|
|
71f264 |
return [extensions, source, bytecode]
|
|
|
71f264 |
@@ -1428,7 +1428,7 @@ def _setup(_bootstrap_module):
|
|
|
71f264 |
|
|
|
71f264 |
# Constants
|
|
|
71f264 |
setattr(self_module, '_relax_case', _make_relax_case())
|
|
|
71f264 |
- EXTENSION_SUFFIXES.extend(_imp.extension_suffixes())
|
|
|
71f264 |
+ EXTENSION_SUFFIXES.extend(_alternative_architectures(_imp.extension_suffixes()))
|
|
|
71f264 |
if builtin_os == 'nt':
|
|
|
71f264 |
SOURCE_SUFFIXES.append('.pyw')
|
|
|
71f264 |
if '_d.pyd' in EXTENSION_SUFFIXES:
|
|
|
71f264 |
@@ -1441,3 +1441,39 @@ def _install(_bootstrap_module):
|
|
|
71f264 |
supported_loaders = _get_supported_file_loaders()
|
|
|
71f264 |
sys.path_hooks.extend([FileFinder.path_hook(*supported_loaders)])
|
|
|
71f264 |
sys.meta_path.append(PathFinder)
|
|
|
71f264 |
+
|
|
|
71f264 |
+
|
|
|
71f264 |
+_ARCH_MAP = {
|
|
|
71f264 |
+ "-arm-linux-gnueabi.": "-arm-linux-gnueabihf.",
|
|
|
71f264 |
+ "-armeb-linux-gnueabi.": "-armeb-linux-gnueabihf.",
|
|
|
71f264 |
+ "-mips64-linux-gnu.": "-mips64-linux-gnuabi64.",
|
|
|
71f264 |
+ "-mips64el-linux-gnu.": "-mips64el-linux-gnuabi64.",
|
|
|
71f264 |
+ "-ppc-linux-gnu.": "-powerpc-linux-gnu.",
|
|
|
71f264 |
+ "-ppc-linux-gnuspe.": "-powerpc-linux-gnuspe.",
|
|
|
71f264 |
+ "-ppc64-linux-gnu.": "-powerpc64-linux-gnu.",
|
|
|
71f264 |
+ "-ppc64le-linux-gnu.": "-powerpc64le-linux-gnu.",
|
|
|
71f264 |
+ # The above, but the other way around:
|
|
|
71f264 |
+ "-arm-linux-gnueabihf.": "-arm-linux-gnueabi.",
|
|
|
71f264 |
+ "-armeb-linux-gnueabihf.": "-armeb-linux-gnueabi.",
|
|
|
71f264 |
+ "-mips64-linux-gnuabi64.": "-mips64-linux-gnu.",
|
|
|
71f264 |
+ "-mips64el-linux-gnuabi64.": "-mips64el-linux-gnu.",
|
|
|
71f264 |
+ "-powerpc-linux-gnu.": "-ppc-linux-gnu.",
|
|
|
71f264 |
+ "-powerpc-linux-gnuspe.": "-ppc-linux-gnuspe.",
|
|
|
71f264 |
+ "-powerpc64-linux-gnu.": "-ppc64-linux-gnu.",
|
|
|
71f264 |
+ "-powerpc64le-linux-gnu.": "-ppc64le-linux-gnu.",
|
|
|
71f264 |
+}
|
|
|
71f264 |
+
|
|
|
71f264 |
+
|
|
|
71f264 |
+def _alternative_architectures(suffixes):
|
|
|
71f264 |
+ """Add a suffix with an alternative architecture name
|
|
|
71f264 |
+ to the list of suffixes so an extension built with
|
|
|
71f264 |
+ the default (upstream) setting is loadable with our Pythons
|
|
|
71f264 |
+ """
|
|
|
71f264 |
+
|
|
|
71f264 |
+ for suffix in suffixes:
|
|
|
71f264 |
+ for original, alternative in _ARCH_MAP.items():
|
|
|
71f264 |
+ if original in suffix:
|
|
|
71f264 |
+ suffixes.append(suffix.replace(original, alternative))
|
|
|
71f264 |
+ return suffixes
|
|
|
71f264 |
+
|
|
|
71f264 |
+ return suffixes
|