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