|
|
445d243 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
445d243 |
From: Lumir Balhar <lbalhar@redhat.com>
|
|
|
445d243 |
Date: Tue, 4 Aug 2020 12:04:03 +0200
|
|
|
445d243 |
Subject: [PATCH] 00353: Original names for architectures with different names
|
|
|
445d243 |
downstream
|
|
|
445d243 |
|
|
|
445d243 |
Pythons in RHEL/Fedora use different names for some architectures
|
|
|
445d243 |
than upstream and other distros (for example ppc64 vs. powerpc64).
|
|
|
445d243 |
See patch 274.
|
|
|
445d243 |
That means that an extension built with the default upstream settings
|
|
|
445d243 |
(on other distro or as an manylinux wheel) cannot be found by Python
|
|
|
445d243 |
on RHEL/Fedora because it has a different suffix.
|
|
|
445d243 |
This patch adds the original names to importlib so Python is able
|
|
|
445d243 |
to import extensions with an original architecture name in its
|
|
|
445d243 |
file name.
|
|
|
445d243 |
|
|
|
445d243 |
WARNING: This patch has no effect on Python built with bootstrap
|
|
|
445d243 |
enabled because Python/importlib_external.h is not regenerated
|
|
|
445d243 |
and therefore Python during bootstrap contains importlib from
|
|
|
445d243 |
upstream without this feature. It's possible to include
|
|
|
445d243 |
Python/importlib_external.h to this patch but it'd make rebasing
|
|
|
445d243 |
a nightmare because it's basically a binary file.
|
|
|
445d243 |
---
|
|
|
445d243 |
Lib/importlib/_bootstrap_external.py | 31 ++++++++++++++++++++++++++--
|
|
|
445d243 |
1 file changed, 29 insertions(+), 2 deletions(-)
|
|
|
445d243 |
|
|
|
445d243 |
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
|
|
|
b32dcc3 |
index b8ac482994..3a97be9dcb 100644
|
|
|
445d243 |
--- a/Lib/importlib/_bootstrap_external.py
|
|
|
445d243 |
+++ b/Lib/importlib/_bootstrap_external.py
|
|
|
b32dcc3 |
@@ -1559,7 +1559,7 @@ def _get_supported_file_loaders():
|
|
|
445d243 |
|
|
|
445d243 |
Each item is a tuple (loader, suffixes).
|
|
|
445d243 |
"""
|
|
|
445d243 |
- extensions = ExtensionFileLoader, _imp.extension_suffixes()
|
|
|
445d243 |
+ extensions = ExtensionFileLoader, _alternative_architectures(_imp.extension_suffixes())
|
|
|
445d243 |
source = SourceFileLoader, SOURCE_SUFFIXES
|
|
|
445d243 |
bytecode = SourcelessFileLoader, BYTECODE_SUFFIXES
|
|
|
445d243 |
return [extensions, source, bytecode]
|
|
|
b32dcc3 |
@@ -1623,7 +1623,7 @@ def _setup(_bootstrap_module):
|
|
|
445d243 |
|
|
|
445d243 |
# Constants
|
|
|
445d243 |
setattr(self_module, '_relax_case', _make_relax_case())
|
|
|
445d243 |
- EXTENSION_SUFFIXES.extend(_imp.extension_suffixes())
|
|
|
445d243 |
+ EXTENSION_SUFFIXES.extend(_alternative_architectures(_imp.extension_suffixes()))
|
|
|
445d243 |
if builtin_os == 'nt':
|
|
|
445d243 |
SOURCE_SUFFIXES.append('.pyw')
|
|
|
445d243 |
if '_d.pyd' in EXTENSION_SUFFIXES:
|
|
|
b32dcc3 |
@@ -1636,3 +1636,30 @@ def _install(_bootstrap_module):
|
|
|
445d243 |
supported_loaders = _get_supported_file_loaders()
|
|
|
445d243 |
sys.path_hooks.extend([FileFinder.path_hook(*supported_loaders)])
|
|
|
445d243 |
sys.meta_path.append(PathFinder)
|
|
|
445d243 |
+
|
|
|
445d243 |
+
|
|
|
445d243 |
+_ARCH_MAP = {
|
|
|
445d243 |
+ "-arm-linux-gnueabi.": "-arm-linux-gnueabihf.",
|
|
|
445d243 |
+ "-armeb-linux-gnueabi.": "-armeb-linux-gnueabihf.",
|
|
|
445d243 |
+ "-mips64-linux-gnu.": "-mips64-linux-gnuabi64.",
|
|
|
445d243 |
+ "-mips64el-linux-gnu.": "-mips64el-linux-gnuabi64.",
|
|
|
445d243 |
+ "-ppc-linux-gnu.": "-powerpc-linux-gnu.",
|
|
|
445d243 |
+ "-ppc-linux-gnuspe.": "-powerpc-linux-gnuspe.",
|
|
|
445d243 |
+ "-ppc64-linux-gnu.": "-powerpc64-linux-gnu.",
|
|
|
445d243 |
+ "-ppc64le-linux-gnu.": "-powerpc64le-linux-gnu.",
|
|
|
445d243 |
+}
|
|
|
445d243 |
+
|
|
|
445d243 |
+
|
|
|
445d243 |
+def _alternative_architectures(suffixes):
|
|
|
445d243 |
+ """Add a suffix with an alternative architecture name
|
|
|
445d243 |
+ to the list of suffixes so an extension built with
|
|
|
445d243 |
+ the default (upstream) setting is loadable with our Pythons
|
|
|
445d243 |
+ """
|
|
|
445d243 |
+
|
|
|
445d243 |
+ for suffix in suffixes:
|
|
|
445d243 |
+ for original, alternative in _ARCH_MAP.items():
|
|
|
445d243 |
+ if original in suffix:
|
|
|
445d243 |
+ suffixes.append(suffix.replace(original, alternative))
|
|
|
445d243 |
+ return suffixes
|
|
|
445d243 |
+
|
|
|
445d243 |
+ return suffixes
|