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