-
Bug
-
Resolution: Done-Errata
-
Undefined
-
rhel-8.9.0
-
rpm-4.14.3-27.el8
-
None
-
None
-
rhel-sst-cs-software-management
-
ssg_core_services
-
10
-
12
-
None
-
QE ack, Dev ack
-
False
-
-
No
-
None
-
-
Pass
-
None
-
Release Note Not Required
-
-
Unspecified
-
None
The `%__os_install_post` macro is run after the %install section of each RPM build. It launches the `brp-python-bytecompile` script that is supposed to bytecompile all Python scripts that haven't been bytecompiled already.
The Python 3.11 stack was added to both RHEL 8 and 9. On RHEL 9 the brp-python-bytecompile script is newer and is prepared for Python 3.11, but on RHEL 8 it isn't. Thus Python 3.11 scripts that weren't bytecompiled as part of the %build or %install sections are left uncompiled.
Tested in Copr: https://copr.devel.redhat.com/coprs/torsava/python3.11-test-os-install-post-bytecompile/
Spec file changes to reproduce:
```
...
%install
mkdir -p %
echo "print()" > %{buildroot}
%
{python3_sitelib}/directory/hugo.py...
%check
echo "============== Print .py files found =================="
find %{buildroot}%{python3_sitelib}
/directory/ -name "*.py"
echo "============== Print .pyc files found =================="
find %
echo "============== End of print =================="
# Count .py and .pyc files
PY=$(find %{buildroot}
%
{python3_sitelib}/directory/ -name "*.py" | wc -l)PYC=$(find %{buildroot}%{python3_sitelib}
/directory/ -name "*.py[co]" | wc -l)
test $PY -eq 1
test $(expr $PY * 2) -eq $PYC
...
```
Output for .py files is the same on RHEL 8 & 9:
============== Print .py files found ==================
+ find /builddir/build/BUILDROOT/python3.11-wheel-0.38.4-3.el9.x86_64/usr/lib/python3.11/site-packages/directory/ -name '*.py'
/builddir/build/BUILDROOT/python3.11-wheel-0.38.4-3.el9.x86_64/usr/lib/python3.11/site-packages/directory/hugo.py
But for .pyc it's different:
RHEL 9:
+ echo '============== Print .pyc files found =================='
+ find /builddir/build/BUILDROOT/python3.11-wheel-0.38.4-3.el9.x86_64/usr/lib/python3.11/site-packages/directory/ -name '*.py[co]'
/builddir/build/BUILDROOT/python3.11-wheel-0.38.4-3.el9.x86_64/usr/lib/python3.11/site-packages/directory/_pycache_/hugo.cpython-311.opt-1.pyc
/builddir/build/BUILDROOT/python3.11-wheel-0.38.4-3.el9.x86_64/usr/lib/python3.11/site-packages/directory/_pycache_/hugo.cpython-311.pyc
============== End of print ==================
RHEL 8:
+ echo '============== Print .pyc files found =================='
+ find /builddir/build/BUILDROOT/python3.11-wheel-0.38.4-3.el8.x86_64/usr/lib/python3.11/site-packages/directory/ -name '*.py[co]'
============== End of print ==================