diff --git a/epel-rpm-macros.spec b/epel-rpm-macros.spec index 9132303..ef78b5e 100644 --- a/epel-rpm-macros.spec +++ b/epel-rpm-macros.spec @@ -1,6 +1,6 @@ Name: epel-rpm-macros Version: 8 -Release: 12.playground +Release: 12 Summary: Extra Packages for Enterprise Linux RPM macros Group: System Environment/Base @@ -25,7 +25,6 @@ Requires: python-rpm-macros Requires: python2-rpm-macros # Make sure EPEL8's Python 3 packages use /usr/bin/python3.6 or python3.8 # instead of /usr/libexec/platform-python -Requires: (python38-rpm-macros if python38-devel) Requires: (python-modular-rpm-macros if python3-devel) Suggests: python36-rpm-macros @@ -61,8 +60,9 @@ install -Dpm 644 %{SOURCE3} \ %changelog -* Thu Apr 30 2020 Troy Dawson - 8-12 -- Use Suggests for python36-rpm-macros +* Sun Jun 07 2020 Miro HronĨok - 8-12 +- Backport %%py_shebang_fix, %%pytest, %%py_provides +- Allow to combine %%pycached with other macros (e.g. %%exclude or %%ghost) (#1838992) * Thu Apr 30 2020 Troy Dawson - 8-11 - Install python36-rpm-macros or python38-rpm-macros correctly @@ -71,11 +71,11 @@ install -Dpm 644 %{SOURCE3} \ - Define %%python, but make it work only if %%__python is redefined - Add the %%pycached macro -* Fri Apr 03 2020 Troy Dawson - 8-9.playground +* Fri Apr 03 2020 Troy Dawson - 8-9 - Add %qt5_qtwebengine_arches to macros -* Thu Nov 21 2019 Troy Dawson - 8-8.playground -- Bump release for proper playground build. +* Thu Nov 21 2019 Troy Dawson - 8-8 +- Bump release to be in sync with playground build. * Wed Nov 20 2019 Troy Dawson - 8-6 - Enable python requires generator diff --git a/macros.epel-rpm-macros b/macros.epel-rpm-macros index e7edbba..3aa950c 100644 --- a/macros.epel-rpm-macros +++ b/macros.epel-rpm-macros @@ -20,6 +20,11 @@ %python2 %__python2 %python3 %__python3 +# Simplified version backported from Fedora +%py_shebang_fix %{expand:/usr/bin/pathfix.py -pni "%{__python} %{py_shbang_opts}"} +%py2_shebang_fix %{expand:/usr/bin/pathfix.py -pni "%{__python2} %{py2_shbang_opts}"} +%py3_shebang_fix %{expand:/usr/bin/pathfix.py -pni "%{__python3} %{py3_shbang_opts}"} + # Users can use %%python only if they redefined %%__python (e.g. to %%__python3) %python() %{lua:\ __python = rpm.expand("%__python")\ @@ -33,7 +38,7 @@ # This only supports Python 3.5+ and will never work with Python 2. # Hence, it has no Python version in the name. %pycached() %{lua: - path = rpm.expand("%{?1}") + path = rpm.expand("%{?*}") if (string.sub(path, "-3") ~= ".py") then rpm.expand("%{error:%%pycached can only be used with paths explicitly ending with .py}") else @@ -45,6 +50,32 @@ end } +# This is intended for Python 3 only, hence also no Python version in the name. +%__pytest /usr/bin/pytest-3 +%pytest %{expand:\\\ + CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\ + PATH="%{buildroot}%{_bindir}:$PATH"\\\ + PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}"\\\ + PYTHONDONTWRITEBYTECODE=1\\\ + %__pytest} + +%py_provides() %{lua: + local name = rpm.expand('%1') + if name == '%1' then + rpm.expand('%{error:%%py_provides requires at least 1 argument, the name to provide}') + end + local evr = rpm.expand('%2') + if evr == '%2' then + evr = rpm.expand('%{?epoch:%{epoch}:}%{version}-%{release}') + end + print('Provides: ' .. name .. ' = ' .. evr .. '\\n') + -- NB: dash needs to be escaped! + if name:match('^python3%-') then + replaced = name:gsub('^python3%-', 'python-') + print('Provides: ' .. replaced .. ' = ' .. evr .. '\\n') + end +} + # gpgverify verifies signed sources. There is documentation in the script. %gpgverify %{_rpmconfigdir}/gpgverify