#199 F31: Use upstream architecture names on Fedora 34+
Merged 3 years ago by churchyard. Opened 3 years ago by churchyard.
rpms/ churchyard/python3 f31-auto-churchyard-archnames  into  f31

@@ -1,83 +0,0 @@ 

- From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001

- From: Petr Viktorin <pviktori@redhat.com>

- Date: Mon, 28 Aug 2017 17:16:46 +0200

- Subject: [PATCH] 00274: Upstream uses Debian-style architecture naming, change

-  to match Fedora

- MIME-Version: 1.0

- Content-Type: text/plain; charset=UTF-8

- Content-Transfer-Encoding: 8bit

- 

- Co-authored-by: Petr Viktorin <pviktori@redhat.com>

- Co-authored-by: Miro Hrončok <miro@hroncok.cz>

- Co-authored-by: Tomas Orsava <torsava@redhat.com>

- ---

-  config.sub   |  2 +-

-  configure.ac | 16 ++++++++--------

-  2 files changed, 9 insertions(+), 9 deletions(-)

- 

- diff --git a/config.sub b/config.sub

- index ba37cf99e2..52a9ec6662 100755

- --- a/config.sub

- +++ b/config.sub

- @@ -1042,7 +1042,7 @@ case $basic_machine in

-  		;;

-  	ppc64)	basic_machine=powerpc64-unknown

-  		;;

- -	ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'`

- +	ppc64-* | ppc64p7-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'`

-  		;;

-  	ppc64le | powerpc64little)

-  		basic_machine=powerpc64le-unknown

- diff --git a/configure.ac b/configure.ac

- index 4c78a515a8..98d0a1ef65 100644

- --- a/configure.ac

- +++ b/configure.ac

- @@ -765,9 +765,9 @@ cat >> conftest.c <<EOF

-          alpha-linux-gnu

-  # elif defined(__ARM_EABI__) && defined(__ARM_PCS_VFP)

-  #  if defined(__ARMEL__)

- -        arm-linux-gnueabihf

- +        arm-linux-gnueabi

-  #  else

- -        armeb-linux-gnueabihf

- +        armeb-linux-gnueabi

-  #  endif

-  # elif defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP)

-  #  if defined(__ARMEL__)

- @@ -807,7 +807,7 @@ cat >> conftest.c <<EOF

-  #  elif _MIPS_SIM == _ABIN32

-          mips64el-linux-gnuabin32

-  #  elif _MIPS_SIM == _ABI64

- -        mips64el-linux-gnuabi64

- +        mips64el-linux-gnu

-  #  else

-  #   error unknown platform triplet

-  #  endif

- @@ -817,22 +817,22 @@ cat >> conftest.c <<EOF

-  #  elif _MIPS_SIM == _ABIN32

-          mips64-linux-gnuabin32

-  #  elif _MIPS_SIM == _ABI64

- -        mips64-linux-gnuabi64

- +        mips64-linux-gnu

-  #  else

-  #   error unknown platform triplet

-  #  endif

-  # elif defined(__or1k__)

-          or1k-linux-gnu

-  # elif defined(__powerpc__) && defined(__SPE__)

- -        powerpc-linux-gnuspe

- +        ppc-linux-gnuspe

-  # elif defined(__powerpc64__)

-  #  if defined(__LITTLE_ENDIAN__)

- -        powerpc64le-linux-gnu

- +        ppc64le-linux-gnu

-  #  else

- -        powerpc64-linux-gnu

- +        ppc64-linux-gnu

-  #  endif

-  # elif defined(__powerpc__)

- -        powerpc-linux-gnu

- +        ppc-linux-gnu

-  # elif defined(__s390x__)

-          s390x-linux-gnu

-  # elif defined(__s390__)

00353-architecture-names-upstream-downstream.patch 00353-Original-names-for-architectures-with-different-name.patch
file renamed
+29 -11
@@ -3,16 +3,23 @@ 

  Date: Tue, 4 Aug 2020 12:04:03 +0200

  Subject: [PATCH] 00353: Original names for architectures with different names

   downstream

+ MIME-Version: 1.0

+ Content-Type: text/plain; charset=UTF-8

+ Content-Transfer-Encoding: 8bit

  

- Pythons in RHEL/Fedora use different names for some architectures

+ https://fedoraproject.org/wiki/Changes/Python_Upstream_Architecture_Names

+ 

+ Pythons in RHEL/Fedora used different names for some architectures

  than upstream and other distros (for example ppc64 vs. powerpc64).

- See patch 274.

- That means that an extension built with the default upstream settings

- (on other distro or as an manylinux wheel) cannot be found by Python

- on RHEL/Fedora because it has a different suffix.

- This patch adds the original names to importlib so Python is able

- to import extensions with an original architecture name in its

+ This was patched in patch 274, now it is sedded if %with legacy_archnames.

+ 

+ That meant that an extension built with the default upstream settings

+ (on other distro or as an manylinux wheel) could not been found by Python

+ on RHEL/Fedora because it had a different suffix.

+ This patch adds the legacy names to importlib so Python is able

+ to import extensions with a legacy architecture name in its

  file name.

+ It work both ways, so it support both %with and %without legacy_archnames.

  

  WARNING: This patch has no effect on Python built with bootstrap

  enabled because Python/importlib_external.h is not regenerated
@@ -20,12 +27,14 @@ 

  upstream without this feature. It's possible to include

  Python/importlib_external.h to this patch but it'd make rebasing

  a nightmare because it's basically a binary file.

+ 

+ Co-authored-by: Miro Hrončok <miro@hroncok.cz>

  ---

-  Lib/importlib/_bootstrap_external.py | 31 ++++++++++++++++++++++++++--

-  1 file changed, 29 insertions(+), 2 deletions(-)

+  Lib/importlib/_bootstrap_external.py | 40 ++++++++++++++++++++++++++--

+  1 file changed, 38 insertions(+), 2 deletions(-)

  

  diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py

- index 66a16a6839..7d7a9fb25d 100644

+ index 66a16a6839..880c560ce9 100644

  --- a/Lib/importlib/_bootstrap_external.py

  +++ b/Lib/importlib/_bootstrap_external.py

  @@ -1484,7 +1484,7 @@ def _get_supported_file_loaders():
@@ -46,7 +55,7 @@ 

       if builtin_os == 'nt':

           SOURCE_SUFFIXES.append('.pyw')

           if '_d.pyd' in EXTENSION_SUFFIXES:

- @@ -1560,3 +1560,30 @@ def _install(_bootstrap_module):

+ @@ -1560,3 +1560,39 @@ def _install(_bootstrap_module):

       supported_loaders = _get_supported_file_loaders()

       sys.path_hooks.extend([FileFinder.path_hook(*supported_loaders)])

       sys.meta_path.append(PathFinder)
@@ -61,6 +70,15 @@ 

  +    "-ppc-linux-gnuspe.": "-powerpc-linux-gnuspe.",

  +    "-ppc64-linux-gnu.": "-powerpc64-linux-gnu.",

  +    "-ppc64le-linux-gnu.": "-powerpc64le-linux-gnu.",

+ +    # The above, but the other way around:

+ +    "-arm-linux-gnueabihf.": "-arm-linux-gnueabi.",

+ +    "-armeb-linux-gnueabihf.": "-armeb-linux-gnueabi.",

+ +    "-mips64-linux-gnuabi64.": "-mips64-linux-gnu.",

+ +    "-mips64el-linux-gnuabi64.": "-mips64el-linux-gnu.",

+ +    "-powerpc-linux-gnu.": "-ppc-linux-gnu.",

+ +    "-powerpc-linux-gnuspe.": "-ppc-linux-gnuspe.",

+ +    "-powerpc64-linux-gnu.": "-ppc64-linux-gnu.",

+ +    "-powerpc64le-linux-gnu.": "-ppc64le-linux-gnu.",

  +}

  +

  +

file modified
+61 -21
@@ -17,7 +17,7 @@ 

  #global prerel rc1

  %global upstream_version %{general_version}%{?prerel}

  Version: %{general_version}%{?prerel:~%{prerel}}

- Release: 1%{?dist}

+ Release: 3%{?dist}

  License: Python

  

  
@@ -76,6 +76,19 @@ 

  %bcond_with valgrind

  %endif

  

+ # https://fedoraproject.org/wiki/Changes/Python_Upstream_Architecture_Names

+ # For a very long time we have converted "upstream architecture names" to "Fedora names".

+ # This made sense at the time, see https://github.com/pypa/manylinux/issues/687#issuecomment-666362947

+ # However, with manylinux wheels popularity growth, this is now a problem.

+ # Wheels built on a Linux that doesn't do this were not compatible with ours and vice versa.

+ # We now have a compatibility layer to workaround a problem,

+ # but we also no longer use the legacy arch names in Fedora 34+.

+ # This bcond controls the behavior. The defaults should be good for anybody.

+ %if 0%{?fedora} >= 34 || 0%{?rhel} >= 9

+ %bcond_with legacy_archnames

+ %else

+ %bcond_without legacy_archnames

+ %endif

  

  # Notes from bootstraping Python 3.7:

  # https://fedoraproject.org/wiki/SIGs/Python/UpgradingPython
@@ -96,8 +109,21 @@ 

  %global LDVERSION_optimized %{pybasever}%{ABIFLAGS_optimized}

  %global LDVERSION_debug     %{pybasever}%{ABIFLAGS_debug}

  

- %global SOABI_optimized cpython-%{pyshortver}%{ABIFLAGS_optimized}-%{_arch}-linux%{_gnu}

- %global SOABI_debug     cpython-%{pyshortver}%{ABIFLAGS_debug}-%{_arch}-linux%{_gnu}

+ # When we use the upstream arch triplets, we convert them from the legacy ones

+ # This is reversed in prep when %%with legacy_archnames, so we keep both macros

+ %global platform_triplet_legacy %{_arch}-linux%{_gnu}

+ %global platform_triplet_upstream %{expand:%(echo %{platform_triplet_legacy} | sed -E \\

+     -e 's/^arm(eb)?-linux-gnueabi$/arm\\1-linux-gnueabihf/' \\

+     -e 's/^mips64(el)?-linux-gnu$/mips64\\1-linux-gnuabi64/' \\

+     -e 's/^ppc(64)?(le)?-linux-gnu$/powerpc\\1\\2-linux-gnu/')}

+ %if %{with legacy_archnames}

+ %global platform_triplet %{platform_triplet_legacy}

+ %else

+ %global platform_triplet %{platform_triplet_upstream}

+ %endif

+ 

+ %global SOABI_optimized cpython-%{pyshortver}%{ABIFLAGS_optimized}-%{platform_triplet}

+ %global SOABI_debug     cpython-%{pyshortver}%{ABIFLAGS_debug}-%{platform_triplet}

  

  # All bytecode files are in a __pycache__ subdirectory, with a name

  # reflecting the version of the bytecode.
@@ -281,10 +307,6 @@ 

  # Fedora Change: https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe

  Patch251: 00251-change-user-install-location.patch

  

- # 00274 # 1e9258f6e8f70e86d5130113d3eed22993cf3da9

- # Upstream uses Debian-style architecture naming, change to match Fedora

- Patch274: 00274-fix-arch-names.patch

- 

  # 00316 # 4fd732b55b7d8a38c25aef566884665ce925eacb

  # Mark bdist_wininst unsupported

  #
@@ -312,18 +334,22 @@ 

  # In upstream since 3.8: https://bugs.python.org/issue38347

  Patch335: 00335-backport-pathfix-change.patch

  

- # 00353 # f3c11e227c715450b3c1e945a5004e84cce41a58

+ # 00353 # ab4cc97b643cfe99f567e3a03e5617b507183771

  # Original names for architectures with different names downstream

  #

- # Pythons in RHEL/Fedora use different names for some architectures

+ # https://fedoraproject.org/wiki/Changes/Python_Upstream_Architecture_Names

+ #

+ # Pythons in RHEL/Fedora used different names for some architectures

  # than upstream and other distros (for example ppc64 vs. powerpc64).

- # See patch 274.

- # That means that an extension built with the default upstream settings

- # (on other distro or as an manylinux wheel) cannot be found by Python

- # on RHEL/Fedora because it has a different suffix.

- # This patch adds the original names to importlib so Python is able

- # to import extensions with an original architecture name in its

+ # This was patched in patch 274, now it is sedded if %%with legacy_archnames.

+ #

+ # That meant that an extension built with the default upstream settings

+ # (on other distro or as an manylinux wheel) could not been found by Python

+ # on RHEL/Fedora because it had a different suffix.

+ # This patch adds the legacy names to importlib so Python is able

+ # to import extensions with a legacy architecture name in its

  # file name.

+ # It work both ways, so it support both %%with and %%without legacy_archnames.

  #

  # WARNING: This patch has no effect on Python built with bootstrap

  # enabled because Python/importlib_external.h is not regenerated
@@ -331,7 +357,7 @@ 

  # upstream without this feature. It's possible to include

  # Python/importlib_external.h to this patch but it'd make rebasing

  # a nightmare because it's basically a binary file.

- Patch353: 00353-Original-names-for-architectures-with-different-name.patch

+ Patch353: 00353-architecture-names-upstream-downstream.patch

  

  # (New patches go here ^^^)

  #
@@ -672,6 +698,12 @@ 

  # (This is after patching, so that we can use patches directly from upstream)

  rm configure pyconfig.h.in

  

+ # When we use the legacy arch names, we need to change them in configure.ac

+ %if %{with legacy_archnames}

+ sed -i configure.ac \

+     -e 's/\b%{platform_triplet_upstream}\b/%{platform_triplet_legacy}/'

+ %endif

+ 

  

  # ======================================================

  # Configuring and building the code:
@@ -1341,8 +1373,8 @@ 

  # "Makefile" and the config-32/64.h file are needed by

  # distutils/sysconfig.py:_init_posix(), so we include them in the core

  # package, along with their parent directories (bug 531901):

- %dir %{pylibdir}/config-%{LDVERSION_optimized}-%{_arch}-linux%{_gnu}/

- %{pylibdir}/config-%{LDVERSION_optimized}-%{_arch}-linux%{_gnu}/Makefile

+ %dir %{pylibdir}/config-%{LDVERSION_optimized}-%{platform_triplet}/

+ %{pylibdir}/config-%{LDVERSION_optimized}-%{platform_triplet}/Makefile

  %dir %{_includedir}/python%{LDVERSION_optimized}/

  %{_includedir}/python%{LDVERSION_optimized}/%{_pyconfig_h}

  
@@ -1357,9 +1389,9 @@ 

  %{_bindir}/2to3

  %endif

  

- %{pylibdir}/config-%{LDVERSION_optimized}-%{_arch}-linux%{_gnu}/*

+ %{pylibdir}/config-%{LDVERSION_optimized}-%{platform_triplet}/*

  %if %{without flatpackage}

- %exclude %{pylibdir}/config-%{LDVERSION_optimized}-%{_arch}-linux%{_gnu}/Makefile

+ %exclude %{pylibdir}/config-%{LDVERSION_optimized}-%{platform_triplet}/Makefile

  %exclude %{_includedir}/python%{LDVERSION_optimized}/%{_pyconfig_h}

  %endif

  %{_includedir}/python%{LDVERSION_optimized}/*.h
@@ -1536,7 +1568,7 @@ 

  %{_libdir}/%{py_INSTSONAME_debug}

  

  # Analog of the -devel subpackage's files:

- %{pylibdir}/config-%{LDVERSION_debug}-%{_arch}-linux%{_gnu}

+ %{pylibdir}/config-%{LDVERSION_debug}-%{platform_triplet}

  %{_includedir}/python%{LDVERSION_debug}

  %{_bindir}/python%{LDVERSION_debug}-config

  %{_bindir}/python%{LDVERSION_debug}-*-config
@@ -1580,6 +1612,14 @@ 

  # ======================================================

  

  %changelog

+ * Mon Oct 05 2020 Miro Hrončok <mhroncok@redhat.com> - 3.7.9-3

+ - Use upstream architecture names on Fedora 34+

+ - https://fedoraproject.org/wiki/Changes/Python_Upstream_Architecture_Names

+ 

+ * Mon Sep 21 2020 Miro Hrončok <mhroncok@redhat.com> - 3.7.9-2

+ - Rebuilt for new %%extension flags

+ - Fixes: rhbz#1877652

+ 

  * Wed Aug 19 2020 Tomas Hrnciar <thrnciar@redhat.com> - 3.7.9-1

  - Update to 3.7.9

  

no initial comment

Build succeeded.

The diff looks good to me, the package builds, the interpreter works and it can import the module from simple-manylinux-demo.

[root@43ea4997c6da /]# python3 -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))"
.cpython-37m-ppc64le-linux-gnu.so
[root@43ea4997c6da /]# python3 -m venv venv
[root@43ea4997c6da /]# venv/bin/pip install -U pip
Collecting pip
  Using cached https://files.pythonhosted.org/packages/4e/5f/528232275f6509b1fff703c9280e58951a81abe24640905de621c9f81839/pip-20.2.3-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 19.1.1
    Uninstalling pip-19.1.1:
      Successfully uninstalled pip-19.1.1
Successfully installed pip-20.2.3
[root@43ea4997c6da /]# venv/bin/pip install simple-manylinux-demo
Collecting simple-manylinux-demo
  Using cached simple_manylinux_demo-1.0-cp37-cp37m-manylinux2014_ppc64le.whl (18 kB)
Installing collected packages: simple-manylinux-demo
Successfully installed simple-manylinux-demo-1.0
[root@43ea4997c6da /]# venv/bin/python -c "from dummyextension import extension"

:thumbsup:

Pull-Request has been merged by churchyard

3 years ago