Make %py3_dist respect %python3_pkgversion
By default, %{py3_dist foo} generates python3dist(foo).
This change makes it respect %python3_pkgversion so when
it is redefined as X.Y, %{py3_dist foo} generates pythonX.Y(foo).
This is a modified backport of https://src.fedoraproject.org/rpms/python-rpm-macros/c/638f809f4c15b8b14dfc1f6f8c3c08b0d2ba0b70
In addition, `:gsub('^3(%d)', '3.%1')` was added.
It makes sure that values of %python3_pkgversion without dot
are converted to values with dots.
In RHEL 8, at least until Python 3.9, the %python3_pkgversion value is 39.
It is written in a way that allows us to use 3.10 for the next version if desired.
$ rpm --define 'python3_pkgversion 3' --eval '%{py3_dist heh}'
python3dist(heh)
$ rpm --define 'python3_pkgversion 3.8' --eval '%{py3_dist heh}'
python3.8dist(heh)
$ rpm --define 'python3_pkgversion 38' --eval '%{py3_dist heh}'
python3.8dist(heh)
$ rpm --define 'python3_pkgversion 3.12' --eval '%{py3_dist heh}'
python3.12dist(heh)
$ rpm --define 'python3_pkgversion 312' --eval '%{py3_dist heh}'
python3.12dist(heh)
The default behavior is reasonable:
$ rpm -q python36-rpm-macros
package python36-rpm-macros is not installed
$ rpm -q python38-rpm-macros
package python38-rpm-macros is not installed
$ rpm -q python39-rpm-macros
package python39-rpm-macros is not installed
$ rpm --eval '%{py3_dist heh}'
python3dist(heh)
$ rpm -q python36-rpm-macros
python36-rpm-macros-3.6.8-38.module_el8.5.0+2569+5c5719bc.noarch
$ rpm --eval '%{py3_dist heh}'
python3dist(heh)
$ rpm -q python38-rpm-macros
python38-rpm-macros-3.8.12-1.module_el8.6.0+2778+cd494b30.noarch
$ rpm --eval '%{py3_dist heh}'
python3.8dist(heh)
$ rpm -q python39-rpm-macros
python39-rpm-macros-3.9.7-1.module_el8.6.0+2780+a40f65e1.noarch
$ rpm --eval '%{py3_dist heh}'
python3.9dist(heh)
The value for non-3 %python3_pkgversion is preserved as is:
$ rpm --define 'python3_pkgversion 4' --eval '%{py3_dist heh}'
python4dist(heh)
$ rpm --define 'python3_pkgversion 48' --eval '%{py3_dist heh}'
python48dist(heh)
Co-authored-by: Lumir Balhar <lbalhar@redhat.com>