From Fedora Project Wiki
Line 200: Line 200:
 
On another ppc64le Linux (such as Debian or openSUSE):
 
On another ppc64le Linux (such as Debian or openSUSE):
  
 +
wormhole receive ...
 
  pip install ...whl
 
  pip install ...whl
 
  python -c 'from dummyextension import extension'
 
  python -c 'from dummyextension import extension'

Revision as of 11:39, 25 August 2020


Python Upstream Architecture Names

Summary

Use upstream architecture naming in Python (mostly in filenames) instead of previously patched Fedora names. For example, have /usr/lib64/python3.9/lib-dynload/array.cpython-39-powerpc64le-linux-gnu.so instead of /usr/lib64/python3.9/lib-dynload/array.cpython-39-ppc64le-linux-gnu.so. This makes packaging of Python itself a tad trickier, but it moves Fedora's Python closer to upstream. The difference only has impact on ppc64le and armv7hl (considering the architectures built by koji.fedoraproject.org). Packages assuming the filenames always contain %{_arch}-linux%{_gnu} will need to be adapted.

Owner

Current status

  • Targeted release: Fedora 34
  • Last updated: 2020-08-25
  • FESCo issue: <will be assigned by the Wrangler>
  • Tracker bug: <will be assigned by the Wrangler>
  • Release notes tracker: <will be assigned by the Wrangler>

Detailed Description

The Saga

A Long Time Ago in the Fedora Galaxy

Many releases ago, when Fedora hasn't built for power and arm yet, the Python maintainers mapped the Python "platform triplet" to %{_arch}-linux%{_gnu}. This worked. For example, on x86_64, this is x86_64-linux-gnu on Fedora and this is consistent with the "platform triplet" used in filenames in upstream.

The Phantom Technical Debt

Later around the year 2015, as more architectures were added, Python build scripts were patched to use "the Fedora's architecture names":

At the time, that was a reasonable decision: the idea of cross-Linux builds was sci-fi, and Fedora was not trying to stay close to upstream as it is now (we had around 60 patches; today we're down to around 6).

Raise of the Manylinux Wheels

In the meantime, cross-Linux builds become a thing. The manylinux1 standard was created in 2016, allowing to build Python wheels with compiled extension modules on one platform and ship them to many. The first manylinux version only supported x86_64 and i686 and hence it was not impacted by Fedora's patching decisions.

The manylinux standard arguably made the upstream Python packaging ecosystem a much nicer thing to work with. Installing packages with compiled extension modules was no longer such a pain. One could just run pip install numpy and not worry about a Fortran compiler. For that reason, manylinux wheels become widely adapted by the most popular projects.

A New Architecture

With the third manylinux version -- manylinux2014 (created in 2019, named after the oldest Linux it supports -- CentOS 7), support for more architectures was introduced: x86_64, i686, aarch64, armv7l, ppc64, ppc64le, s390x. The adaption of new architectures is somehow slow, because the official manylinux2014 containers only currently (August 2020) exist for x86_64, i686, aarch64, ppc64le and s390x.

Revenge of the Patches

We have discovered a problem with the ppc64le manylinux2014 wheels: The CentOS 7 manylinux2014 container images ship upstream Python without RHEL/CentOS/EPEL patches. When the extension modules it built there, it is named with an upstream named suffix: .cpython-XY(m)-powerpc64le-linux-gnu.so. The wheel is installable on Fedora (with Fedora's patches), but the module won't (even be considered for) import, because Fedora's Python expect the extension to be .cpython-XY(m)-ppc64le-linux-gnu.so.

In theory, we have the same problem on armv7hl, but there are no manylinux2014 containers available for that platform, so there are no such wheels out there (known to us).

The same problem also exists the other way around, albeit it's arguably less severe. It is possible to build manylinux wheels on (some version of) Fedora or EL (using the Python from the distribution). However such ppc64le wheels won't import on other Linux distributions.

The Workaround Awakens

To allow importing extension modules from ppc64le manylinux wheels, we have patched Pythons (3.5+) in Fedora to consider both "Fedora's" and upstream platform triplets when importing extension modules. This workarounds works well for users installing manylinux wheels on Fedora, but does not solve the problem when building the wheels on Fedora.

The change

With this change proposal, we plan to switch to use the upstream architecture names and keep the workaround to preserve backwards compatibility. When we do that the following will happen:

  1. The Python standard library extension module suffixes will change to .cpython-39-powerpc64le-linux-gnu.so and .cpython-39-arm-linux-gnueabihf.so. Python will still import extension modules with the legacy suffixes .cpython-39-ppc64le-linux-gnu.so and .cpython-39-arm-linux-gnu.so.
  2. The newly built Python packages with extension modules will also change the suffixes. Packages that assume the platform triplet is always %{_arch}-linux%{_gnu} (e.g. in the %files section) will need to be adapted. A mix of legacy and upstream suffixes will co-exist and work together.
  3. When safe, we will drop the workaround to support the legacy names. For example, when we initially package Python 3.10, it will be packaged without the workaround. On the other hand, older Python versions might never be able to drop it, because users will carry their own built extension modules from previous releases.

Feedback

Benefit to Fedora

Users of ppc64le and arm7hl Fedora (and future RHEL) will have a closer-to-upstream Python experience and will no longer suffer from compatibility issues when they install or build manylinux wheels.


Scope

  • Other developers: Mostly nothing, adapt the %files section if needed
  • Release engineering: a check of an impact with Release Engineering is not needed
  • Policies and guidelines: not needed for this Change
  • Trademark approval: not needed for this Change
  • Alignment with Objectives: no

Upgrade/compatibility impact

No significant user visible upgrade/compatibility problem is anticipated. Filenames will be different, but the old filenames are still supported. Scripts that hardcode filename assumptions might break.

How To Test

On ppc64le, try to install a manylinux wheel and import from it. It should work on any Python ≥ 3.5. E.g.:

pip install simple-manylinux-demo
python -c 'from dummyextension import extension'

On ppc64le, try to build a manylinux wheel and import from it on another Linux. It should work on any Python ≥ 3.5. E.g.:

pip wheel .  # on some project with extension module
auditwheel ...whl
wormhole send ...whl # or any other way

On another ppc64le Linux (such as Debian or openSUSE):

wormhole receive ...
pip install ...whl
python -c 'from dummyextension import extension'

User Experience

Dependencies

N/A (not a System Wide Change)

Contingency Plan

  • Contingency mechanism: (What to do? Who will do it?) N/A (not a System Wide Change)
  • Contingency deadline: N/A (not a System Wide Change)
  • Blocks release? N/A (not a System Wide Change), Yes/No
  • Blocks product? product

Documentation

N/A (not a System Wide Change)

Release Notes