!5 Update to 7.4.2
From: @starlet-dx Reviewed-by: @caodongxia Signed-off-by: @caodongxia
This commit is contained in:
commit
b484487986
112
Make-pypng-an-extra-dependency.patch
Normal file
112
Make-pypng-an-extra-dependency.patch
Normal file
@ -0,0 +1,112 @@
|
||||
From 5cdc25153e93dc267d998de59d290b8f68d803a7 Mon Sep 17 00:00:00 2001
|
||||
From: starlet-dx <15929766099@163.com>
|
||||
Date: Fri, 28 Jul 2023 16:46:42 +0800
|
||||
Subject: [PATCH 1/1] Make pypng an extra dependency
|
||||
|
||||
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().
|
||||
|
||||
Refer:
|
||||
https://github.com/lincolnloop/python-qrcode/commit/e6d6faf43d06c8535034e89938ae97126b6c6c77
|
||||
---
|
||||
qrcode/main.py | 7 +++++--
|
||||
qrcode/tests/test_qrcode.py | 11 ++++++++---
|
||||
setup.cfg | 3 ++-
|
||||
3 files changed, 15 insertions(+), 6 deletions(-)
|
||||
|
||||
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 0a60eba..8d3d576 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
|
||||
--
|
||||
2.30.0
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
Name: python-qrcode
|
||||
Version: 7.3.1
|
||||
Version: 7.4.2
|
||||
Release: 1
|
||||
Summary: Python QR Code image generator
|
||||
License: BSD
|
||||
URL: https://github.com/lincolnloop/python-qrcode
|
||||
Source0: https://pypi.python.org/packages/source/q/qrcode/qrcode-%{version}.tar.gz
|
||||
Patch0: Make-pypng-an-extra-dependency.patch
|
||||
BuildArch: noarch
|
||||
BuildRequires: python3-devel python3-setuptools python3-imaging python3-six
|
||||
BuildRequires: python3-typing-extensions
|
||||
%description
|
||||
Python module for generating QR Codes.
|
||||
|
||||
@ -51,6 +53,7 @@ done
|
||||
%{_mandir}/man1/qr.1*
|
||||
%{python3_sitelib}/qrcode/image/{svg.py*,pil.py*,styledpil.py*}
|
||||
%{python3_sitelib}/qrcode/image/__pycache__/{svg.*,pil.*,styledpil.*}
|
||||
%{python3_sitelib}/qrcode/compat/*
|
||||
|
||||
%files -n python3-qrcode-core
|
||||
%doc README.rst CHANGES.rst LICENSE
|
||||
@ -61,6 +64,9 @@ done
|
||||
%exclude %{python3_sitelib}/qrcode/tests
|
||||
|
||||
%changelog
|
||||
* Fri Jul 28 2023 yaoxin <yao_xin001@hoperun.com> - 7.4.2-1
|
||||
- Update to 7.4.2
|
||||
|
||||
* Wed May 18 2022 houyingchao <houyingchao@h-partners.com> - 7.3.1-1
|
||||
- Upgrade to 7.3.1
|
||||
|
||||
|
||||
Binary file not shown.
BIN
qrcode-7.4.2.tar.gz
Normal file
BIN
qrcode-7.4.2.tar.gz
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user