Update to 8.0

Resolves: RHEL-180019 Rebase to python-qrcode 8.0

Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
Florence Blanc-Renaud 2026-05-28 17:40:16 +02:00
parent 8d04f96328
commit 8ab02487bf
7 changed files with 64 additions and 138 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@
/qrcode-6.1.tar.gz /qrcode-6.1.tar.gz
/qrcode-7.3.1.tar.gz /qrcode-7.3.1.tar.gz
/qrcode-7.4.2.tar.gz /qrcode-7.4.2.tar.gz
/qrcode-8.0.tar.gz

42
flit-pyproject.toml.in Normal file
View File

@ -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"]

View File

@ -1,25 +1,23 @@
# RHEL does not include pillow or pypng
%bcond extras %[%{undefined rhel} || %{defined epel}]
%global pkgname qrcode %global pkgname qrcode
Name: python-%{pkgname} Name: python-%{pkgname}
Version: 7.4.2 Version: 8.0
Release: %autorelease Release: %autorelease
Summary: Python QR Code image generator Summary: Python QR Code image generator
License: BSD-3-Clause License: BSD-3-Clause
URL: https://github.com/lincolnloop/python-qrcode URL: https://github.com/lincolnloop/python-qrcode
Source0: %{pypi_source qrcode} Source0: %{pypi_source qrcode}
Source1: flit-pyproject.toml.in
BuildArch: noarch BuildArch: noarch
BuildRequires: python3-devel BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
BuildRequires: python3-pytest 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 %description
This module uses the Python Imaging Library (PIL) to allow for the\ 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 Summary: Python QR Code image generator
Obsoletes: python3-qrcode-core < 7.4.2-2 Obsoletes: python3-qrcode-core < 7.4.2-2
Provides: python3-qrcode-core = %{version}-%{release} 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} %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.
%if %{with extras}
%pyproject_extras_subpkg -n python3-%{pkgname} pil,png,all
%endif
%generate_buildrequires %generate_buildrequires
# RHEL does not include the extra test dependencies (coverage, pillow) # 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 %prep
%autosetup -n qrcode-%{version} -p1 %autosetup -n qrcode-%{version} -p1
# Remove shebang # Remove shebang
sed -i '1d' qrcode/console_scripts.py 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 %build
@ -55,14 +65,6 @@ sed -i '1d' qrcode/console_scripts.py
%pyproject_install %pyproject_install
%pyproject_save_files qrcode %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 %check
%pytest -v %pytest -v
@ -72,8 +74,7 @@ ln -s qr %{buildroot}%{_bindir}/qrcode
%doc README.rst CHANGES.rst %doc README.rst CHANGES.rst
%license LICENSE %license LICENSE
%{_bindir}/qr %{_bindir}/qr
%{_bindir}/qrcode
%{_mandir}/man1/qr.1*
%changelog %changelog
%autochangelog %autochangelog

View File

@ -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

View File

@ -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])

View File

@ -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):

View File

@ -1 +1 @@
SHA512 (qrcode-7.4.2.tar.gz) = a8642845990341034e39c43ef674f5b4ce8d3175a44d6062f711af2c24ffd45bda5f3ecf8a7825b7ebafe734b6396d52a37bb59177c544f921e43eaa9f1f5405 SHA512 (qrcode-8.0.tar.gz) = 14d37ef4fe0fca3253c92f39db7948f9d804f600ee3bf9ba053baf4e01488f340cb4977b94a338f448dd4f9007f9f0cb7c5cf1db5405d98a9b38a809c8ed8650