Build only python3-qrcode-core on RHEL

Related: #1935839
This commit is contained in:
Christian Heimes 2021-04-22 13:56:15 +00:00
parent 62b5de3438
commit 4b2169cd7b

View File

@ -1,8 +1,15 @@
%global pkgname qrcode %global pkgname qrcode
%if 0%{?rhel}
# RHEL only ships qrcode-core and does not have pillow
%bcond_without coreonly
%else
%bcond_with coreonly
%endif
Name: python-%{pkgname} Name: python-%{pkgname}
Version: 6.1 Version: 6.1
Release: 10%{?dist} Release: 11%{?dist}
Summary: Python QR Code image generator Summary: Python QR Code image generator
License: BSD License: BSD
@ -13,8 +20,7 @@ BuildArch: noarch
BuildRequires: python3-devel BuildRequires: python3-devel
BuildRequires: python3-setuptools BuildRequires: python3-setuptools
BuildRequires: python3-six BuildRequires: python3-six
%if ! 0%{?rhel} %if %{without coreonly}
# RHEL only ships qrcode-core and does not have pillow
BuildRequires: python3-imaging BuildRequires: python3-imaging
%endif %endif
@ -24,6 +30,7 @@ generation of QR Codes.
%description %_description %description %_description
%if %{without coreonly}
%package -n python3-%{pkgname} %package -n python3-%{pkgname}
Summary: Python QR Code image generator Summary: Python QR Code image generator
Requires: python3-imaging Requires: python3-imaging
@ -34,6 +41,7 @@ Requires: python3-%{pkgname}-core = %{version}-%{release}
%description -n python3-%{pkgname} %description -n python3-%{pkgname}
This module uses the Python Imaging Library (PIL) to allow for the This module uses the Python Imaging Library (PIL) to allow for the
generation of QR Codes. Python 3 version. generation of QR Codes. Python 3 version.
%endif
%package -n python3-%{pkgname}-core %package -n python3-%{pkgname}-core
Requires: python3-six Requires: python3-six
@ -68,38 +76,50 @@ rm -r %{buildroot}%{python3_sitelib}/%{pkgname}/tests
# #
ln -s qr %{buildroot}%{_bindir}/qrcode ln -s qr %{buildroot}%{_bindir}/qrcode
%if %{with coreonly}
# remove files that were part of python3-qrcode package and not shipped in
# python3-qrcode-core
rm %{buildroot}%{_bindir}/qr
rm %{buildroot}%{_bindir}/qrcode
rm %{buildroot}%{_mandir}/man1/qr.1*
%pycached rm %{buildroot}%{python3_sitelib}/%{pkgname}/image/svg.py
%pycached rm %{buildroot}%{python3_sitelib}/%{pkgname}/image/pil.py
%endif
%check %check
%if 0%{?rhel} %if %{with coreonly}
# test method requires PIL # test method requires PIL
sed -i s/test_render_pil/disabled_render_pil/g qrcode/tests/test_qrcode.py sed -i s/test_render_pil/disabled_render_pil/g qrcode/tests/test_qrcode.py
%endif %endif
PYTHONPATH=%{buildroot}%{python3_sitelib} \ PYTHONPATH=%{buildroot}%{python3_sitelib} \
%{__python3} -m unittest -v qrcode.tests.test_qrcode.QRCodeTests %{__python3} -m unittest -v qrcode.tests.test_qrcode.QRCodeTests
%if %{without coreonly}
%files -n python3-%{pkgname} %files -n python3-%{pkgname}
%{_bindir}/qr %{_bindir}/qr
%{_bindir}/qrcode %{_bindir}/qrcode
%{_mandir}/man1/qr.1* %{_mandir}/man1/qr.1*
%{python3_sitelib}/%{pkgname}/image/svg.py* %pycached %{python3_sitelib}/%{pkgname}/image/svg.py
%{python3_sitelib}/%{pkgname}/image/pil.py* %pycached %{python3_sitelib}/%{pkgname}/image/pil.py
%{python3_sitelib}/%{pkgname}/image/__pycache__/svg.* %endif
%{python3_sitelib}/%{pkgname}/image/__pycache__/pil.*
%files -n python3-%{pkgname}-core %files -n python3-%{pkgname}-core
%doc README.rst CHANGES.rst %doc README.rst CHANGES.rst
%license LICENSE %license LICENSE
%dir %{python3_sitelib}/%{pkgname}/ %{python3_sitelib}/%{pkgname}
%dir %{python3_sitelib}/%{pkgname}/image
%dir %{python3_sitelib}/%{pkgname}/image/__pycache__
%{python3_sitelib}/%{pkgname}*.egg-info %{python3_sitelib}/%{pkgname}*.egg-info
%{python3_sitelib}/%{pkgname}/*.py*
%{python3_sitelib}/%{pkgname}/__pycache__ %if %{without coreonly}
%{python3_sitelib}/%{pkgname}/image/__init__.py* %pycached %exclude %{python3_sitelib}/%{pkgname}/image/svg.py
%{python3_sitelib}/%{pkgname}/image/base.py* %pycached %exclude %{python3_sitelib}/%{pkgname}/image/pil.py
%{python3_sitelib}/%{pkgname}/image/__pycache__/__init__.* %endif
%{python3_sitelib}/%{pkgname}/image/__pycache__/base.*
%changelog %changelog
* Thu Apr 22 2021 Christian Heimes <cheimes@redhat.com> - 6.1-11
- Build only python3-qrcode-core on RHEL
- Related: #1935839
* Thu Apr 22 2021 Christian Heimes <cheimes@redhat.com> - 6.1-10 * Thu Apr 22 2021 Christian Heimes <cheimes@redhat.com> - 6.1-10
- Resolves: #1935839 Remove python-imaging build requirements for RHEL - Resolves: #1935839 Remove python-imaging build requirements for RHEL
- Run unit tests during build - Run unit tests during build