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 2169780 - python3_version macros doesn't support python 3.11
Summary: python3_version macros doesn't support python 3.11
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: python-rpm-macros
Version: 8.8
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Python Maintainers
QA Contact: Lukáš Zachar
URL:
Whiteboard:
Depends On:
Blocks: 2137139 2172909
TreeView+ depends on / blocked
 
Reported: 2023-02-14 16:49 UTC by Dimitri Savineau
Modified: 2023-05-16 09:53 UTC (History)
5 users (show)

Fixed In Version: python-rpm-macros-3-45.el8
Doc Type: No Doc Update
Doc Text:
Clone Of:
: 2172909 (view as bug list)
Environment:
Last Closed: 2023-05-16 08:35:40 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker CS-1523 0 None None None 2023-03-29 17:43:14 UTC
Red Hat Issue Tracker RHELPLAN-148615 0 None None None 2023-02-14 16:51:45 UTC
Red Hat Product Errata RHBA-2023:2820 0 None None None 2023-05-16 08:35:47 UTC

Description Dimitri Savineau 2023-02-14 16:49:32 UTC
Description of problem:

The %python3_version macros don't support python 3.11 (ie: they only support one digit for the python minor version)

Version-Release number of selected component (if applicable):

# python3.11 -V
Python 3.11.1
# rpm -q python3.11
python3.11-3.11.1-4.el8.x86_64
# rpm -q python3-rpm-macros
python3-rpm-macros-3-44.el8.noarch

How reproducible:
100%

Steps to Reproduce:
1. Set %global __python3 /usr/bin/python3.11
2. Try to use anything that use the %python3_version macro like %py3_shebang_fix

Actual results:

+ '[' -f /usr/bin/pathfix3.1.py ']'
+ pathfix=/usr/bin/pathfix.py
+ '[' -z '' ']'
+ shebang_flags=-k
+ /usr/bin/pathfix.py -pni /usr/bin/python3.11 -k test/lib/ansible_test
/var/tmp/rpm-tmp.0UpaOA: line 88: /usr/bin/pathfix.py: No such file or directory


Expected results:


+ '[' -f /usr/bin/pathfix3.11.py ']'
+ pathfix=/usr/bin/pathfix3.11.py
+ '[' -z '' ']'
+ shebang_flags=-k
+ /usr/bin/pathfix3.11.py -pni /usr/bin/python3.11 -k test/lib/ansible_test

Additional info:

%py3_shebang_fix macro is based on the %python3_version macro but the latest only supports one digit for the python minor version (%python3_version_nodots is also affected by this)

The current macro definition from the python3-rpm-macros package is the following:

%python3_version %(%{__python3} -Ic "import sys; sys.stdout.write(sys.version[:3])")
%python3_version_nodots %(%{__python3} -Ic "import sys; sys.stdout.write(sys.version[:3].replace('.',''))")


# /usr/bin/python3.11 -Ic "import sys; sys.stdout.write(sys.version[:3])"
3.1
# /usr/bin/python3.11 -Ic "import sys; sys.stdout.write(sys.version[:3].replace('.',''))"
31

Those macros on RHEL 9 aren't affected by the same issue due to a different implementation:

%python3_version %(RPM_BUILD_ROOT= %{__python3} -Ic "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))")
%python3_version_nodots %(RPM_BUILD_ROOT= %{__python3} -Ic "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))")

Note that as a workaround, one can just override the macro with the following:

%global python3_version 3.11

Comment 1 Miro Hrončok 2023-02-14 17:08:12 UTC
Thanks for the report.

The idea is that for Python 3.11 you use python3.11-rpm-macros on RHEL 8, because the original macros are too old. https://git.centos.org/rpms/python3.11/blob/c8s/f/SOURCES/macros.python3.11#_12

But on the other hand, fixing the %python3_version macro in python3-rpm-macros (and python-rpm-macros) is certainly possible and I suspect we will have a hard time explaining the concept of python3.11-rpm-macros to users who get bit by this if we don't fix it.

Comment 2 Dimitri Savineau 2023-02-14 17:26:40 UTC
> The idea is that for Python 3.11 you use python3.11-rpm-macros on RHEL 8

That was my initial plan by using

%global python3_pkgversion 3.11

BuildRequires: python%{python3_pkgversion}-rpm-macros

And I was not able to find any python3.11-rpm-macros package available.

But looks like I didn't look closely as that package is built as part of the python3.11 package so let me retest this.

So if this is working correctly then we can close this BZ unless you really want to fix this for python3-rpm-macros

Comment 3 Dimitri Savineau 2023-02-14 17:36:11 UTC
Ok I confirm that using the correct python3.11-rpm-macros fix my issue.

I'll let you decide if this needs to be fixed for python3-rpm-macros or not and close this BZ accordaly

Comment 6 Miro Hrončok 2023-02-22 14:26:15 UTC
$ rpm -qa | grep python | grep macros
python-rpm-macros-3-44.el8.noarch
python-srpm-macros-3-44.el8.noarch
python3-rpm-macros-3-44.el8.noarch

$ rpm --define '__python3 /usr/bin/python3.11' --eval '%python3_version'
3.1

$ rpm --define '__python3 /usr/bin/python3.11' --eval '%python3_version_nodots'
31

$ rpm --define '__python3 /usr/bin/python3.11' --eval '%py3_shebang_fix'
\
  if [ -f /usr/bin/pathfix3.1.py ]; then
    pathfix=/usr/bin/pathfix3.1.py
  else
    # unversioned pathfix.py provided by platform-python-devel
    pathfix=/usr/bin/pathfix.py
  fi
  if [ -z "s" ]; then
    shebang_flags="-k"
  else
    shebang_flags="-kas"
  fi
  $pathfix -pni /usr/bin/python3.11 $shebang_flags


===========================================================================

$ rpm -qa | grep python | grep macros
python-rpm-macros-3-45.el8.noarch
python-srpm-macros-3-45.el8.noarch
python3-rpm-macros-3-45.el8.noarch

$ rpm --define '__python3 /usr/bin/python3.11' --eval '%python3_version'
3.11

$ rpm --define '__python3 /usr/bin/python3.11' --eval '%python3_version_nodots'
311

$ rpm --define '__python3 /usr/bin/python3.11' --eval '%py3_shebang_fix'
\
  if [ -f /usr/bin/pathfix3.11.py ]; then
    pathfix=/usr/bin/pathfix3.11.py
  else
    # unversioned pathfix.py provided by platform-python-devel
    pathfix=/usr/bin/pathfix.py
  fi
  if [ -z "s" ]; then
    shebang_flags="-k"
  else
    shebang_flags="-kas"
  fi
  $pathfix -pni /usr/bin/python3.11 $shebang_flags

Comment 7 Miro Hrončok 2023-02-22 14:29:36 UTC
Regression check, this still works as expected:

$ rpm --eval '%python3_version'
3.6

$ rpm --eval '%python3_version_nodots'
36

Comment 14 Miro Hrončok 2023-03-29 17:39:54 UTC
The updated package is missing from CentOS 8 Stream:

$ repoquery -q --repo=RHEL8.9-AppStream python3-rpm-macros
python3-rpm-macros-0:3-45.el8.noarch

$ repoquery -q --repo=c8s-appstream python3-rpm-macros
python3-rpm-macros-0:3-41.el8.noarch
python3-rpm-macros-0:3-42.el8.noarch
python3-rpm-macros-0:3-43.el8.noarch

Comment 15 Miro Hrončok 2023-03-29 17:43:14 UTC
(In reply to Miro Hrončok from comment #14)
> The updated package is missing from CentOS 8 Stream:
> 
> $ repoquery -q --repo=RHEL8.9-AppStream python3-rpm-macros
> python3-rpm-macros-0:3-45.el8.noarch
> 
> $ repoquery -q --repo=c8s-appstream python3-rpm-macros
> python3-rpm-macros-0:3-41.el8.noarch
> python3-rpm-macros-0:3-42.el8.noarch
> python3-rpm-macros-0:3-43.el8.noarch

I reported this in https://issues.redhat.com/browse/CS-1523

Comment 16 Maxwell G 2023-04-03 16:24:05 UTC
It seems python-rpm-macros-3-45.el8 was not built at all in CentOS Stream Koji [1]. The last build is python-rpm-macros-3-44.el8. Are the maintainers able to submit a build?

[1] https://kojihub.stream.centos.org/koji/packageinfo?packageID=1891

Comment 17 Miro Hrončok 2023-04-03 16:32:21 UTC
I don't really know. I can submit the build but it will not reach the compose until it's built and gated into RHEL, which will likely fail. I'd better ask in the CS jira ticket.

Comment 18 Miro Hrončok 2023-04-03 16:33:53 UTC
Ah, bstinson is actually building it, as it seems from https://kojihub.stream.centos.org/koji/packageinfo?packageID=1891

Comment 21 errata-xmlrpc 2023-05-16 08:35:40 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 (python-rpm-macros bug fix and enhancement update), 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-2023:2820


Note You need to log in before you can comment on or make changes to this bug.