From 8ab02487bf46d5e8b1963d3de95ee27d68cacbc4 Mon Sep 17 00:00:00 2001 From: Florence Blanc-Renaud Date: Thu, 28 May 2026 17:40:16 +0200 Subject: [PATCH] Update to 8.0 Resolves: RHEL-180019 Rebase to python-qrcode 8.0 Signed-off-by: Florence Blanc-Renaud --- .gitignore | 1 + flit-pyproject.toml.in | 42 ++++++++++++++++ python-qrcode.spec | 39 ++++++++------- qrcode-optional-pypng.patch | 93 ----------------------------------- qrcode_assert-has-calls.patch | 9 ---- qrcode_test.patch | 16 ------ sources | 2 +- 7 files changed, 64 insertions(+), 138 deletions(-) create mode 100644 flit-pyproject.toml.in delete mode 100644 qrcode-optional-pypng.patch delete mode 100644 qrcode_assert-has-calls.patch delete mode 100644 qrcode_test.patch diff --git a/.gitignore b/.gitignore index 1f62e60..921880c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /qrcode-6.1.tar.gz /qrcode-7.3.1.tar.gz /qrcode-7.4.2.tar.gz +/qrcode-8.0.tar.gz diff --git a/flit-pyproject.toml.in b/flit-pyproject.toml.in new file mode 100644 index 0000000..c49d59a --- /dev/null +++ b/flit-pyproject.toml.in @@ -0,0 +1,42 @@ +[build-system] +requires = ["flit_core >=3.2,<4"] +build-backend = "flit_core.buildapi" + +[project] +name = "qrcode" +version = "@VERSION@" +description = "QR Code image generator" +authors = [ + { name = "Lincoln Loop", email = "info@lincolnloop.com" }, +] +license = { file = "LICENSE" } +readme = "README.rst" +keywords = ["qr", "denso-wave", "IEC18004"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Intended Audience :: Developers", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Multimedia :: Graphics", + "Topic :: Software Development :: Libraries :: Python Modules", +] +requires-python = "~=3.9" +dependencies = [ + "colorama; sys_platform == 'win32'", +] + +[project.scripts] +qr = "qrcode.console_scripts:main" + +[project.optional-dependencies] +pil = ["pillow >=9.1.0"] +png = ["pypng"] +all = ["pypng", "pillow >=9.1.0"] diff --git a/python-qrcode.spec b/python-qrcode.spec index d86a9b5..887bd0a 100644 --- a/python-qrcode.spec +++ b/python-qrcode.spec @@ -1,25 +1,23 @@ +# RHEL does not include pillow or pypng +%bcond extras %[%{undefined rhel} || %{defined epel}] + %global pkgname qrcode Name: python-%{pkgname} -Version: 7.4.2 +Version: 8.0 Release: %autorelease Summary: Python QR Code image generator License: BSD-3-Clause URL: https://github.com/lincolnloop/python-qrcode Source0: %{pypi_source qrcode} +Source1: flit-pyproject.toml.in BuildArch: noarch BuildRequires: python3-devel +BuildRequires: pyproject-rpm-macros 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\ @@ -30,21 +28,33 @@ generation of QR Codes. Summary: Python QR Code image generator Obsoletes: python3-qrcode-core < 7.4.2-2 Provides: python3-qrcode-core = %{version}-%{release} +%if %{with extras} +Recommends: (python3-%{pkgname}+pil or python3-%{pkgname}+png or python3-%{pkgname}+all) +%endif %description -n python3-%{pkgname} This module uses the Python Imaging Library (PIL) to allow for the generation of QR Codes. Python 3 version. +%if %{with extras} +%pyproject_extras_subpkg -n python3-%{pkgname} pil,png,all +%endif + + %generate_buildrequires # RHEL does not include the extra test dependencies (coverage, pillow) -%pyproject_buildrequires %{?!rhel:-x test -x pil -x png} +%pyproject_buildrequires %{?with_extras:-x pil -x png} %prep %autosetup -n qrcode-%{version} -p1 # Remove shebang sed -i '1d' qrcode/console_scripts.py +%if %{defined rhel} && %{undefined epel} +# use flit-core instead of poetry-core +sed -e 's|@VERSION@|%{version}|' %{SOURCE1} > pyproject.toml +%endif %build @@ -55,14 +65,6 @@ sed -i '1d' qrcode/console_scripts.py %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 @@ -72,8 +74,7 @@ ln -s qr %{buildroot}%{_bindir}/qrcode %doc README.rst CHANGES.rst %license LICENSE %{_bindir}/qr -%{_bindir}/qrcode -%{_mandir}/man1/qr.1* + %changelog %autochangelog diff --git a/qrcode-optional-pypng.patch b/qrcode-optional-pypng.patch deleted file mode 100644 index cc7882a..0000000 --- a/qrcode-optional-pypng.patch +++ /dev/null @@ -1,93 +0,0 @@ -Backport of https://github.com/lincolnloop/python-qrcode/pull/338 - -diff --git a/qrcode/main.py b/qrcode/main.py -index 0ac91bb..53f2ab2 100644 ---- a/qrcode/main.py -+++ b/qrcode/main.py -@@ -16,7 +16,6 @@ from typing_extensions import Literal - - from qrcode import constants, exceptions, util - from qrcode.image.base import BaseImage --from qrcode.image.pure import PyPNGImage - - ModulesType = List[List[Optional[bool]]] - # Cache modules generated just based on the QR Code version -@@ -360,7 +359,11 @@ class QRCode(Generic[GenericImage]): - from qrcode.image.pil import Image, PilImage - - # Use PIL by default if available, otherwise use PyPNG. -- image_factory = PilImage if Image else PyPNGImage -+ if Image is not None: -+ image_factory = PilImage -+ else: -+ from qrcode.image.pure import PyPNGImage -+ image_factory = PyPNGImage - - im = image_factory( - self.border, -diff --git a/qrcode/tests/test_qrcode.py b/qrcode/tests/test_qrcode.py -index 5c1ea35..24c36f8 100644 ---- a/qrcode/tests/test_qrcode.py -+++ b/qrcode/tests/test_qrcode.py -@@ -5,18 +5,21 @@ import warnings - from tempfile import mkdtemp - from unittest import mock - --import png -- - import qrcode - import qrcode.util - from qrcode.compat.pil import Image as pil_Image - from qrcode.exceptions import DataOverflowError - from qrcode.image.base import BaseImage --from qrcode.image.pure import PyPNGImage - from qrcode.image.styledpil import StyledPilImage - from qrcode.image.styles import colormasks, moduledrawers - from qrcode.util import MODE_8BIT_BYTE, MODE_ALPHA_NUM, MODE_NUMBER, QRData - -+try: -+ import png -+ from qrcode.image.pure import PyPNGImage -+except ImportError: -+ PyPNGImage = None -+ - UNICODE_TEXT = "\u03b1\u03b2\u03b3" - WHITE = (255, 255, 255) - BLACK = (0, 0, 0) -@@ -175,6 +178,7 @@ class QRCodeTests(unittest.TestCase): - self.assertTrue(MockFactory.new_image.called) - self.assertTrue(MockFactory.drawrect.called) - -+ @unittest.skipIf(not PyPNGImage, "Requires pypng") - def test_render_pypng(self): - qr = qrcode.QRCode() - qr.add_data(UNICODE_TEXT) -@@ -184,6 +188,7 @@ class QRCodeTests(unittest.TestCase): - print(img.width, img.box_size, img.border) - img.save(io.BytesIO()) - -+ @unittest.skipIf(not PyPNGImage, "Requires pypng") - def test_render_pypng_to_str(self): - qr = qrcode.QRCode() - qr.add_data(UNICODE_TEXT) -diff --git a/setup.cfg b/setup.cfg -index 3aff842..c17189b 100644 ---- a/setup.cfg -+++ b/setup.cfg -@@ -30,7 +30,6 @@ packages = find: - install_requires = - colorama;platform_system=="Windows" - typing_extensions -- pypng - python_requires = >= 3.7 - - [options.extras_require] -@@ -45,6 +44,8 @@ test = - pytest - pil = - pillow>=9.1.0 -+png = -+ pypng - all = - zest.releaser[recommended] - tox diff --git a/qrcode_assert-has-calls.patch b/qrcode_assert-has-calls.patch deleted file mode 100644 index d8efa19..0000000 --- a/qrcode_assert-has-calls.patch +++ /dev/null @@ -1,9 +0,0 @@ -diff -rupN --no-dereference qrcode-7.4.2/qrcode/tests/test_release.py qrcode-7.4.2-new/qrcode/tests/test_release.py ---- qrcode-7.4.2/qrcode/tests/test_release.py 2023-02-05 23:11:38.000000000 +0100 -+++ qrcode-7.4.2-new/qrcode/tests/test_release.py 2023-05-12 13:59:22.069372313 +0200 -@@ -37,4 +37,4 @@ class UpdateManpageTests(unittest.TestCa - .replace("version", "3.11") - .replace("date", datetime.datetime.now().strftime("%-d %b %Y")) - ) -- mock_file().write.has_calls([mock.call(line) for line in expected]) -+ mock_file().write.assert_has_calls([mock.call(line) for line in expected if line]) diff --git a/qrcode_test.patch b/qrcode_test.patch deleted file mode 100644 index 0809b2b..0000000 --- a/qrcode_test.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff -rupN --no-dereference qrcode-7.4.2/qrcode/tests/test_script.py qrcode-7.4.2-new/qrcode/tests/test_script.py ---- qrcode-7.4.2/qrcode/tests/test_script.py 2023-02-05 23:11:38.000000000 +0100 -+++ qrcode-7.4.2-new/qrcode/tests/test_script.py 2023-05-12 13:59:22.053372149 +0200 -@@ -59,9 +59,9 @@ class ScriptTest(unittest.TestCase): - def test_optimize(self, mock_print_ascii): - main("testtext --optimize 0".split()) - -- @mock.patch("sys.stdout") -- def test_factory(self, mock_stdout): -- main("testtext --factory svg".split()) -+ #@mock.patch("sys.stdout") -+ #def test_factory(self, mock_stdout): -+ # main("testtext --factory svg".split()) - - @mock.patch("sys.stderr") - def test_bad_factory(self, mock_stderr): diff --git a/sources b/sources index 6a46dc8..83888fe 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (qrcode-7.4.2.tar.gz) = a8642845990341034e39c43ef674f5b4ce8d3175a44d6062f711af2c24ffd45bda5f3ecf8a7825b7ebafe734b6396d52a37bb59177c544f921e43eaa9f1f5405 +SHA512 (qrcode-8.0.tar.gz) = 14d37ef4fe0fca3253c92f39db7948f9d804f600ee3bf9ba053baf4e01488f340cb4977b94a338f448dd4f9007f9f0cb7c5cf1db5405d98a9b38a809c8ed8650