git: 47216afd723b - main - graphics/py-img2pdf: Update to 0.4.4

From: Kai Knoblich <kai_at_FreeBSD.org>
Date: Fri, 31 Mar 2023 05:15:25 UTC
The branch main has been updated by kai:

URL: https://cgit.FreeBSD.org/ports/commit/?id=47216afd723b71d9adc8d1a25241fd71a0de67cc

commit 47216afd723b71d9adc8d1a25241fd71a0de67cc
Author:     Kai Knoblich <kai@FreeBSD.org>
AuthorDate: 2023-03-31 05:12:45 +0000
Commit:     Kai Knoblich <kai@FreeBSD.org>
CommitDate: 2023-03-31 05:12:45 +0000

    graphics/py-img2pdf: Update to 0.4.4
    
    * Add GUI option to reflect the requirements given in setup.py and
      to make use of the graphical frontend script.
    
    * Simplify "do-test" target by switching to USE_PYTHON=pytest.
    
    Changelog since 0.3.5 :
    
    https://gitlab.mister-muffin.de/josch/img2pdf/src/tag/0.4.4/CHANGES.rst
---
 graphics/py-img2pdf/Makefile                       | 29 ++++++++++++++++-----
 graphics/py-img2pdf/distinfo                       |  6 ++---
 .../py-img2pdf/files/patch-src_img2pdf__test.py    | 30 ++++++++++++++++++++++
 3 files changed, 55 insertions(+), 10 deletions(-)

diff --git a/graphics/py-img2pdf/Makefile b/graphics/py-img2pdf/Makefile
index 38934cc6752b..2cc72805d24d 100644
--- a/graphics/py-img2pdf/Makefile
+++ b/graphics/py-img2pdf/Makefile
@@ -1,5 +1,5 @@
 PORTNAME=	img2pdf
-DISTVERSION=	0.3.5
+DISTVERSION=	0.4.4
 CATEGORIES=	graphics python
 MASTER_SITES=	PYPI
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
@@ -11,15 +11,30 @@ WWW=		https://gitlab.mister-muffin.de/josch/img2pdf
 LICENSE=	LGPL3+
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
-RUN_DEPENDS=	${PY_PILLOW}
-TEST_DEPENDS=	${PYTHON_PKGNAMEPREFIX}pdfrw>0:textproc/py-pdfrw@${PY_FLAVOR}
+RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}pikepdf>0:textproc/py-pikepdf@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}pillow>0:graphics/py-pillow@${PY_FLAVOR}
+TEST_DEPENDS=	${PY_NUMPY} \
+		${PYTHON_PKGNAMEPREFIX}packaging>0:devel/py-packaging@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}scipy>0:science/py-scipy@${PY_FLAVOR} \
+		convert:graphics/ImageMagick6 \
+		exiftool:graphics/p5-Image-ExifTool \
+		jpegtopnm:graphics/netpbm \
+		pdftocairo:graphics/poppler-utils
 
-USES=		python:3.5+
-USE_PYTHON=	autoplist concurrent distutils
+USES=		python:3.5+ shebangfix
+USE_PYTHON=	autoplist concurrent distutils pytest
+# Some tests fail, see following link for more info:
+# https://gitlab.mister-muffin.de/josch/img2pdf/issues/152
+PYTEST_BROKEN_TESTS=	jpg_cmyk tiff_cmyk8
+SHEBANG_FILES=	src/img2pdf.py
+
+TEST_ENV=	PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
 
 NO_ARCH=	yes
 
-do-test:
-	@(cd ${WRKSRC} && ${PYTHON_CMD} ${PYDISTUTILS_SETUP} test)
+OPTIONS_DEFINE=		GUI
+OPTIONS_DEFAULT=	GUI
+
+GUI_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}tkinter>0:x11-toolkits/py-tkinter@${PY_FLAVOR}
 
 .include <bsd.port.mk>
diff --git a/graphics/py-img2pdf/distinfo b/graphics/py-img2pdf/distinfo
index 45058800a23c..fab177241c64 100644
--- a/graphics/py-img2pdf/distinfo
+++ b/graphics/py-img2pdf/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1588236899
-SHA256 (img2pdf-0.3.5.tar.gz) = be676b5afebd3c55eb3f3edd9af1ff3e599fef89e91fbf2290b0259da58f1e19
-SIZE (img2pdf-0.3.5.tar.gz) = 83520
+TIMESTAMP = 1680120812
+SHA256 (img2pdf-0.4.4.tar.gz) = 8ec898a9646523fd3862b154f3f47cd52609c24cc3e2dc1fb5f0168f0cbe793c
+SIZE (img2pdf-0.4.4.tar.gz) = 97796
diff --git a/graphics/py-img2pdf/files/patch-src_img2pdf__test.py b/graphics/py-img2pdf/files/patch-src_img2pdf__test.py
new file mode 100644
index 000000000000..40e9379b63fd
--- /dev/null
+++ b/graphics/py-img2pdf/files/patch-src_img2pdf__test.py
@@ -0,0 +1,30 @@
+Fix value errors for some tests:
+
+>           psnr = float(psnr.strip(b"0"))
+E           ValueError: could not convert string to float: b'61.5441 (0.615441)'
+src/img2pdf_test.py:347: ValueError
+
+Obtained from:
+
+https://gitlab.mister-muffin.de/josch/img2pdf/issues/152
+
+--- src/img2pdf_test.py.orig	2023-03-30 18:01:47 UTC
++++ src/img2pdf_test.py
+@@ -345,7 +345,7 @@ def compare(im1, im2, exact, icc, cmyk):
+             stderr=subprocess.PIPE,
+         ).stderr
+         assert psnr != b"0"
+-        psnr = float(psnr.strip(b"0"))
++        psnr = float(psnr.split()[0])
+         assert psnr != 0  # or otherwise we would use the exact variant
+         assert psnr > 50
+ 
+@@ -501,7 +501,7 @@ def compare_pdfimages_png(tmpdir, img, pdf, exact=True
+                 stderr=subprocess.PIPE,
+             ).stderr
+         assert psnr != b"0"
+-        psnr = float(psnr.strip(b"0"))
++        psnr = float(psnr.split()[0])
+         assert psnr != 0  # or otherwise we would use the exact variant
+         assert psnr > 50
+     (tmpdir / "images-000.png").unlink()