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