Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2040656

Summary: Sync patch 251 with Python 3.10+ on Fedora < 36
Product: Red Hat Enterprise Linux 9 Reporter: Miro Hrončok <mhroncok>
Component: python3.9Assignee: Miro Hrončok <mhroncok>
Status: CLOSED ERRATA QA Contact: Lukáš Zachar <lzachar>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.0CC: pviktori
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python3.9-3.9.9-4.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-17 15:36:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Miro Hrončok 2022-01-14 11:34:44 UTC
Backport this: https://src.fedoraproject.org/rpms/python3.9/pull-request/100


Instruct pip to use distutils
-----------------------------

The current version of pip uses distutils on Python < 3.10,
so this should change nothing,
but future versions of pip may theoretically change that.
Customers of RHEL who pip-upgrade pip might need this in the future.



Instruct pypa/distutils to add /local/ addition to prefix
---------------------------------------------------------

Needed for setuptools 60+ installed/upgraded by pip.
Setuptools 60+ uses bundled pypa/distutils instead of the standard library distutils.
Customers of RHEL who pip-upgrade setuptools already need this.

Comment 3 Miro Hrončok 2022-01-17 12:09:33 UTC
Old version of Python with RPM packaged setuptools:

<mock-chroot> sh-5.1# rpm -q python3
python3-3.9.9-2.el9.x86_64

<mock-chroot> sh-5.1# python3 -m pip list
Package    Version
---------- -------
pip        21.2.3
setuptools 53.0.0

<mock-chroot> sh-5.1# git clone https://github.com/fedora-python/Pello
Cloning into 'Pello'...
<mock-chroot> sh-5.1# cd Pello/

<mock-chroot> sh-5.1# python3 setup.py install
...
Extracting Pello-1.0.2-py3.9.egg to /usr/local/lib/python3.9/site-packages
Adding Pello 1.0.2 to easy-install.pth file
Installing pello_greeting script to /usr/local/bin
...

<mock-chroot> sh-5.1# python3 -m pip uninstall Pello
Found existing installation: Pello 1.0.2
Uninstalling Pello-1.0.2:
  Would remove:
    /usr/local/lib/python3.9/site-packages/Pello-1.0.2-py3.9.egg
...

Observe that it installs packages to /usr/local.


------------------------------------------------------


The same version of Python with pip-upgraded setuptools:

<mock-chroot> sh-5.1# python3 -m pip install --upgrade setuptools
...
Successfully installed setuptools-60.5.0

<mock-chroot> sh-5.1# python3 -m pip list
Package    Version
---------- -------
pip        21.2.3
setuptools 60.5.0


<mock-chroot> sh-5.1# python3 setup.py install
...
Extracting Pello-1.0.2-py3.9.egg to /usr/lib/python3.9/site-packages
byte-compiling /usr/lib/python3.9/site-packages/Pello-1.0.2-py3.9.egg/pello/__init__.py to __init__.cpython-39.pyc
byte-compiling /usr/lib/python3.9/site-packages/Pello-1.0.2-py3.9.egg/pello/__main__.py to __main__.cpython-39.pyc
byte-compiling /usr/lib/python3.9/site-packages/Pello-1.0.2-py3.9.egg/pello/pello_greeting.py to pello_greeting.cpython-39.pyc
Adding Pello 1.0.2 to easy-install.pth file
Installing pello_greeting script to /usr/bin

<mock-chroot> sh-5.1# python3 -m pip uninstall Pello
Found existing installation: Pello 1.0.2
Uninstalling Pello-1.0.2:
  Would remove:
    /usr/bin/pello_greeting
    /usr/lib/python3.9/site-packages/Pello-1.0.2-py3.9.egg
...



Observe that it installs packages to /usr directly. This is the behavior we want to prevent.


------------------------------------------------------


Similarly, if we get a hypothetical future release of pip that switches to sysconfig early, e.g. from https://github.com/hroncok/pip/tree/hypothetical-future

<mock-chroot> sh-5.1# python3 -m pip install --upgrade https://github.com/hroncok/pip/archive/refs/heads/hypothetical-future.zip
...
Successfully installed pip-22.0.dev0

<mock-chroot> sh-5.1# python3 -m pip install .
...
Successfully installed Pello-1.0.2

<mock-chroot> sh-5.1# python3 -m pip uninstall Pello
Found existing installation: Pello 1.0.2
Uninstalling Pello-1.0.2:
  Would remove:
    /usr/bin/pello_greeting
    /usr/lib/python3.9/site-packages/Pello-1.0.2.dist-info/*
    /usr/lib/python3.9/site-packages/pello/*

Observe that it installs packages to /usr directly. This is the behavior we want to prevent.


------------------------------------------------------

Now, with the updated Python, again in a fresh environment.


<mock-chroot> sh-5.1# rpm -q python3
python3-3.9.9-4.el9.x86_64

<mock-chroot> sh-5.1# python3 -m pip list
Package    Version
---------- -------
pip        21.2.3
setuptools 53.0.0

<mock-chroot> sh-5.1# git clone https://github.com/fedora-python/Pello
Cloning into 'Pello'...
<mock-chroot> sh-5.1# cd Pello/

<mock-chroot> sh-5.1# python3 setup.py install
...
Extracting Pello-1.0.2-py3.9.egg to /usr/local/lib/python3.9/site-packages
Adding Pello 1.0.2 to easy-install.pth file
Installing pello_greeting script to /usr/local/bin
...

<mock-chroot> sh-5.1# python3 -m pip uninstall Pello
Found existing installation: Pello 1.0.2
Uninstalling Pello-1.0.2:
  Would remove:
    /usr/local/lib/python3.9/site-packages/Pello-1.0.2-py3.9.egg
...

Observe that it *still* installs packages to /usr/local. It does not break stuff for RPM installed setuptools+pip.


------------------------------------------------------


New version of Python with pip-upgraded setuptools:

<mock-chroot> sh-5.1# python3 -m pip install --upgrade setuptools
...
Successfully installed setuptools-60.5.0

<mock-chroot> sh-5.1# python3 -m pip list
Package    Version
---------- -------
pip        21.2.3
setuptools 60.5.0


<mock-chroot> sh-5.1# python3 setup.py install
...
Extracting Pello-1.0.2-py3.9.egg to /usr/local/lib/python3.9/site-packages
byte-compiling /usr/local/lib/python3.9/site-packages/Pello-1.0.2-py3.9.egg/pello/__init__.py to __init__.cpython-39.pyc
byte-compiling /usr/local/lib/python3.9/site-packages/Pello-1.0.2-py3.9.egg/pello/__main__.py to __main__.cpython-39.pyc
byte-compiling /usr/local/lib/python3.9/site-packages/Pello-1.0.2-py3.9.egg/pello/pello_greeting.py to pello_greeting.cpython-39.pyc
Adding Pello 1.0.2 to easy-install.pth file
Installing pello_greeting script to /usr/local/bin
...

<mock-chroot> sh-5.1# python3 -m pip uninstall Pello
Found existing installation: Pello 1.0.2
Uninstalling Pello-1.0.2:
  Would remove:
    /usr/local/lib/python3.9/site-packages/Pello-1.0.2-py3.9.egg
...

Observe that it installs packages to /usr/local. That is the verified fix for setuptools.

------------------------------------------------------

And pip:

<mock-chroot> sh-5.1# python3 -m pip install --upgrade https://github.com/hroncok/pip/archive/refs/heads/hypothetical-future.zip
...
Successfully installed pip-22.0.dev0

<mock-chroot> sh-5.1# python3 -m pip install .
...
Successfully installed Pello-1.0.2

<mock-chroot> sh-5.1# python3 -m pip uninstall Pello
Found existing installation: Pello 1.0.2
Uninstalling Pello-1.0.2:
  Would remove:
    /usr/local/bin/pello_greeting
    /usr/local/lib/python3.9/site-packages/Pello-1.0.2.dist-info/*
    /usr/local/lib/python3.9/site-packages/pello/*
Proceed (Y/n)? 
...

Observe that it also installs packages to /usr/local. That is the verified fix for pip.

Comment 9 errata-xmlrpc 2022-05-17 15:36:22 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: python3.9), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:3899