python-qrcode/python-qrcode.spec
Yaakov Selkowitz aac3768e19 Make pypng requirement optional
There are uses of qrcode that do not require image support; e.g. FreeIPA
uses qrcode only for print_ascii().  Allow such use cases to require
qrcode without depending upon pypng, while leaving it the fallback
provider for make_image().
2023-07-24 22:34:09 -04:00

80 lines
1.8 KiB
RPMSpec

%global pkgname qrcode
Name: python-%{pkgname}
Version: 7.4.2
Release: %autorelease
Summary: Python QR Code image generator
License: BSD
URL: https://github.com/lincolnloop/python-qrcode
Source0: %{pypi_source qrcode}
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: python3-pytest
# Comment out failing test
Patch0: qrcode_test.patch
# Fix failure with Python3.12
Patch1: qrcode_assert-has-calls.patch
# Make pypng requirement optional
# https://github.com/lincolnloop/python-qrcode/pull/338
Patch2: qrcode-optional-pypng.patch
%description
This module uses the Python Imaging Library (PIL) to allow for the\
generation of QR Codes.
%package -n python3-%{pkgname}
Summary: Python QR Code image generator
Obsoletes: python3-qrcode-core < 7.4.2-2
Provides: python3-qrcode-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.
%generate_buildrequires
# RHEL does not include the extra test dependencies (coverage, pillow)
%pyproject_buildrequires %{?!rhel:-x test -x pil -x png}
%prep
%autosetup -n qrcode-%{version} -p1
# Remove shebang
sed -i '1d' qrcode/console_scripts.py
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files qrcode
#
# In previous iterations of the package, the qr script had been
# renamed to qrcode. This was an unnecessary change from upstream.
#
# We cary this symlink to maintain compat with old packages.
#
ln -s qr %{buildroot}%{_bindir}/qrcode
%check
%pytest -v
%files -n python3-%{pkgname} -f %{pyproject_files}
%doc README.rst CHANGES.rst
%license LICENSE
%{_bindir}/qr
%{_bindir}/qrcode
%{_mandir}/man1/qr.1*
%changelog
%autochangelog