Description of problem: callgrind scripts (cg_annotate, cg_merge, cg_diff) were rewritten as Python scripts for valgrind 3.21 release. These include features such as type annotations and the new walrus operator which are supported only in Python versions 3.7 and 3.8 respectively. This causes several issues when running cg_* scripts because RHEL-8 ships Python 3.6 as default, for example: File "../cg_annotate", line 449 while line := readline(): ^ SyntaxError: invalid syntax Version-Release number of selected component (if applicable): valgrind-3.21.0-3.el8 How reproducible: 100% Steps to Reproduce: 1. cg_annotate --version 2. cg_merge --version 3. cg_diff --version Actual results: # cg_annotate --version File "/usr/bin/cg_annotate", line 449 while line := readline(): ^ SyntaxError: invalid syntax # cg_merge --version File "/usr/bin/cg_merge", line 164 while line := readline(): ^ SyntaxError: invalid syntax # cg_diff --version File "/usr/bin/cg_diff", line 218 while line := readline(): ^ SyntaxError: invalid syntax
It seems that the scripts also use the "BooleanOptionalAction" action from the argparse module, which is available from Python 3.9. If we try to run the scripts with python38 (to cover the support of annotations and walrus operator), we get the following traceback: # cg_annotate --version Traceback (most recent call last): File "/usr/bin/cg_annotate", line 41, in <module> from argparse import ArgumentParser, BooleanOptionalAction, Namespace ImportError: cannot import name 'BooleanOptionalAction' from 'argparse' (/usr/lib64/python3.8/argparse.py)
The solution is easy, just add BuildRequires for python39 and python39-rpm-macros this will make sure the testsuite is run with python3.9 as python3 and the rpm-macros will adjust the installed scripts to use #!/usr/bin/python3.9 (and add a Requires for that to the package).
Looks like python39 is a "module" and so cannot be easily used as BuildRequires. But we can use python3.11 since that is newer and isn't a module.
Gating tests are all passing. Tested valgrind-3.21.0-8.el8: the python scripts now work as expected. The "Sanity/valgrind-scripts-smoke" testcase passes with this new build, while fails with previous valgrind-3.21.0-7.el8 build. Additionally there are no more "post check failures" in the %check rpmbuild testsuite in the tests that involved cg_merg, cg_diff and cg_annotate scripts.