git: 255008d84916 - main - www/py-django-graphiql-debug-toolbar: Fix runtime after f8392fba5cb4

From: Kai Knoblich <kai_at_FreeBSD.org>
Date: Sat, 13 Jul 2024 17:12:22 UTC
The branch main has been updated by kai:

URL: https://cgit.FreeBSD.org/ports/commit/?id=255008d84916dfcec497341eb0c2357bbcee5a91

commit 255008d84916dfcec497341eb0c2357bbcee5a91
Author:     Kai Knoblich <kai@FreeBSD.org>
AuthorDate: 2024-07-13 17:07:56 +0000
Commit:     Kai Knoblich <kai@FreeBSD.org>
CommitDate: 2024-07-13 17:11:36 +0000

    www/py-django-graphiql-debug-toolbar: Fix runtime after f8392fba5cb4
    
    * Add a workaround for py-django-debug-toolbar 4.4.6 or newer to prevent
      following error [1]:
    
      [...]
        File "/usr/local/lib/python3.11/site-packages/graphiql_debug_toolbar/middleware.py", line 7, in <module>
            from debug_toolbar.middleware import _HTML_TYPES
        ImportError: cannot import name '_HTML_TYPES' from 'debug_toolbar.middleware' (/usr/local/lib/python3.11/site-packages/debug_toolbar/middleware.py)
      [...]
    
    * Switch to the PEP517 build framework while I'm here.
    
    * Bump PORTREVISION due package change.
    
    PR:             280254 [1]
    Reported by:    Fredrik Eriksson [1]
---
 www/py-django-graphiql-debug-toolbar/Makefile      |  8 ++++--
 .../patch-graphiql__debug__toolbar_middleware.py   | 29 ++++++++++++++++++++++
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/www/py-django-graphiql-debug-toolbar/Makefile b/www/py-django-graphiql-debug-toolbar/Makefile
index e1f505847178..33b04c194ca3 100644
--- a/www/py-django-graphiql-debug-toolbar/Makefile
+++ b/www/py-django-graphiql-debug-toolbar/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	django-graphiql-debug-toolbar
 DISTVERSION=	0.2.0
-PORTREVISION=	3
+PORTREVISION=	4
 CATEGORIES=	www python
 MASTER_SITES=	PYPI
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
@@ -12,15 +12,19 @@ WWW=		https://github.com/flavors/django-graphiql-debug-toolbar
 LICENSE=	MIT
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
+BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}poetry-core>=1.0.0:devel/py-poetry-core@${PY_FLAVOR}
 RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}django42>=2.2:www/py-django42@${PY_FLAVOR} \
 		${PYTHON_PKGNAMEPREFIX}graphene-django300>=2.0.0:devel/py-graphene-django300@${PY_FLAVOR} \
 		${PYTHON_PKGNAMEPREFIX}django-debug-toolbar>=3.1:www/py-django-debug-toolbar@${PY_FLAVOR}
 
 USES=		python
-USE_PYTHON=	autoplist distutils
+USE_PYTHON=	autoplist pep517
 
 CONFLICTS_INSTALL=	${PYTHON_PKGNAMEPREFIX}*${PORTNAME}
 
 NO_ARCH=	yes
 
+post-patch:
+	@${FIND} ${WRKSRC} -name '*.orig' -delete
+
 .include <bsd.port.mk>
diff --git a/www/py-django-graphiql-debug-toolbar/files/patch-graphiql__debug__toolbar_middleware.py b/www/py-django-graphiql-debug-toolbar/files/patch-graphiql__debug__toolbar_middleware.py
new file mode 100644
index 000000000000..8097b3f4e320
--- /dev/null
+++ b/www/py-django-graphiql-debug-toolbar/files/patch-graphiql__debug__toolbar_middleware.py
@@ -0,0 +1,29 @@
+Add compatibility for py-django-debug-toolbar >= 4.4.6
+
+If py-graphiql-debug-toolbar is used with py-django-debug-toolbar 4.4.6 or
+newer, the following error is emitted:
+
+[...]
+  File "/usr/local/lib/python3.11/site-packages/graphiql_debug_toolbar/middleware.py", line 7, in <module>
+      from debug_toolbar.middleware import _HTML_TYPES
+  ImportError: cannot import name '_HTML_TYPES' from 'debug_toolbar.middleware' (/usr/local/lib/python3.11/site-packages/debug_toolbar/middleware.py)
+[...]
+
+This is because py-django-debugtoolbar "_HTML_TYPES" has been moved from
+"debug_toolbar.middleware" to "debug_toolbar.utils" in the 4.4.6 release.
+
+--- graphiql_debug_toolbar/middleware.py.orig	2021-08-28 21:44:07 UTC
++++ graphiql_debug_toolbar/middleware.py
+@@ -4,7 +4,11 @@ from django.utils.encoding import force_str
+ from django.template.loader import render_to_string
+ from django.utils.encoding import force_str
+ 
+-from debug_toolbar.middleware import _HTML_TYPES
++try:
++    from debug_toolbar.middleware import _HTML_TYPES
++except ImportError:
++    from debug_toolbar.utils import _HTML_TYPES
++
+ from debug_toolbar.middleware import DebugToolbarMiddleware as BaseMiddleware
+ from debug_toolbar.toolbar import DebugToolbar
+ from graphene_django.views import GraphQLView