diff --git a/epel-rpm-macros.spec b/epel-rpm-macros.spec index 310c479..41b73bb 100644 --- a/epel-rpm-macros.spec +++ b/epel-rpm-macros.spec @@ -1,6 +1,6 @@ Name: epel-rpm-macros Version: 8 -Release: 21 +Release: 22 Summary: Extra Packages for Enterprise Linux RPM macros Group: System Environment/Base @@ -65,6 +65,9 @@ install -Dpm 644 %{SOURCE3} \ %changelog +* Wed Jul 14 2021 Miro HronĨok - 8-22 +- Introduce %%py3_check_import + * Wed May 19 2021 Neal Gompa - 8-21 - Drop custom CMake macros, RHEL 8.4 includes them now (cf. rhbz#1858983) diff --git a/macros.epel-rpm-macros b/macros.epel-rpm-macros index dfe4f40..c693891 100644 --- a/macros.epel-rpm-macros +++ b/macros.epel-rpm-macros @@ -82,6 +82,35 @@ end } +# With $PATH and $PYTHONPATH set to the %%buildroot, +# try to import the given Python module(s). +# Useful as a smoke test in %%check when running tests is not feasible. +# Use spaces or commas as separators. +%py_check_import() %{expand:\\\ + (cd %{_topdir} &&\\\ + PATH="%{buildroot}%{_bindir}:$PATH"\\\ + PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python_sitearch}:%{buildroot}%{python_sitelib}}"\\\ + PYTHONDONTWRITEBYTECODE=1\\\ + %{__python} -c "import %{lua:local m=rpm.expand('%{?*}'):gsub('[%s,]+', ', ');print(m)}" + ) +} +%py2_check_import() %{expand:\\\ + (cd %{_topdir} &&\\\ + PATH="%{buildroot}%{_bindir}:$PATH"\\\ + PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python2_sitearch}:%{buildroot}%{python2_sitelib}}"\\\ + PYTHONDONTWRITEBYTECODE=1\\\ + %{__python2} -c "import %{lua:local m=rpm.expand('%{?*}'):gsub('[%s,]+', ', ');print(m)}" + ) +} +%py3_check_import() %{expand:\\\ + (cd %{_topdir} &&\\\ + PATH="%{buildroot}%{_bindir}:$PATH"\\\ + PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}"\\\ + PYTHONDONTWRITEBYTECODE=1\\\ + %{__python3} -c "import %{lua:local m=rpm.expand('%{?*}'):gsub('[%s,]+', ', ');print(m)}" + ) +} + %python_disable_dependency_generator() \ %undefine __pythondist_requires \ %{nil}