git: 49cc694155ed - main - www/py-django-hijack: Update to 3.1.4

From: Kai Knoblich <kai_at_FreeBSD.org>
Date: Fri, 25 Mar 2022 16:08:14 UTC
The branch main has been updated by kai:

URL: https://cgit.FreeBSD.org/ports/commit/?id=49cc694155ed62fc2163b201a1de9d832964af05

commit 49cc694155ed62fc2163b201a1de9d832964af05
Author:     Kai Knoblich <kai@FreeBSD.org>
AuthorDate: 2022-03-25 16:00:04 +0000
Commit:     Kai Knoblich <kai@FreeBSD.org>
CommitDate: 2022-03-25 16:07:58 +0000

    www/py-django-hijack: Update to 3.1.4
    
    Changelog since 2.1.10:
    
    https://github.com/django-hijack/django-hijack/compare/v2.1.10...3.1.4
    
    PR:             262678
    Approved by:    Kevin Golding (maintainer)
---
 www/py-django-hijack/Makefile             | 44 ++++++++++++++++++++++++++-----
 www/py-django-hijack/distinfo             |  8 +++---
 www/py-django-hijack/files/patch-setup.py | 35 ++++++++++++++++++++++++
 3 files changed, 78 insertions(+), 9 deletions(-)

diff --git a/www/py-django-hijack/Makefile b/www/py-django-hijack/Makefile
index 5ae7530492fe..48d6d9a293e9 100644
--- a/www/py-django-hijack/Makefile
+++ b/www/py-django-hijack/Makefile
@@ -1,11 +1,13 @@
 # Created by: Kevin Golding <ports@caomhin.org>
 
 PORTNAME=	django-hijack
-PORTVERSION=	2.1.10
-PORTREVISION=	1
+PORTVERSION=	3.1.4
 CATEGORIES=	www python
-MASTER_SITES=	CHEESESHOP
+MASTER_SITES=	CHEESESHOP \
+		https://ports.caomhin.org/:npmcache
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+DISTFILES=	${PORTNAME}-${PORTVERSION}${EXTRACT_SUFX} \
+		${PORTNAME}-npm-cache-${DISTVERSION}${EXTRACT_SUFX}:npmcache
 
 MAINTAINER=	ports@caomhin.org
 COMMENT=	Allows Django superusers to login as other users
@@ -13,12 +15,42 @@ COMMENT=	Allows Django superusers to login as other users
 LICENSE=	MIT
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
-RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}django22>0:www/py-django22@${PY_FLAVOR} \
-		${PYTHON_PKGNAMEPREFIX}django-compat>=1.0.14:www/py-django-compat@${PY_FLAVOR}
+BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}setuptools_scm>0:devel/py-setuptools_scm@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}pytest-runner>0:devel/py-pytest-runner@${PY_FLAVOR} \
+		npm:www/npm
+RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}django22>=2.2:www/py-django22@${PY_FLAVOR}
+TEST_DEPENDS=	${PYTHON_PKGNAMEPREFIX}pytest>0:devel/py-pytest@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}pytest-django>0:devel/py-pytest-django@${PY_FLAVOR}
 
-USES=		python:3.5+
+USES=		gettext-tools:build python:3.6+
 USE_PYTHON=	distutils autoplist
 
+MAKE_ENV=	npm_config_offline=true
+TEST_ENV=	DJANGO_SETTINGS_MODULES=hijack.tests.test_app.settings PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
+
 NO_ARCH=	yes
 
+_MY_NPMCACHE=	${WRKDIR}/.npm
+
+# Add remaining files (e.g. *.po) that aren't recorded by setuptools
+# during install.
+post-install:
+	@${FIND} ${STAGEDIR} -type f -o -type l | \
+		${SORT} | ${SED} -e 's|${STAGEDIR}||' \
+		> ${WRKDIR}/.PLIST.pymodtmp
+
+do-test:
+	@cd ${WRKSRC} && ${SETENV} ${TEST_ENV} ${PYTHON_CMD} -m pytest -v -rs -o addopts=
+
+# Helper target to make the generation of the npm cache easier
+make-npm-cache: extract
+	@${RM} -r ${_MY_NPMCACHE}
+	@cd ${WRKSRC}/ \
+		&& ${SETENV} HOME=${WRKDIR} ${LOCALBASE}/bin/npm ci
+	@cd ${_MY_NPMCACHE} \
+		&& ${RM} _locks anonymous-cli-metrics.json
+	@cd ${WRKDIR} \
+		&& ${TAR} -czf ${PORTNAME}-npm-cache-${DISTVERSION}${EXTRACT_SUFX} .npm \
+		&& ${ECHO_CMD} "Please upload the file ${WRKDIR}/${PORTNAME}-npm-cache-${DISTVERSION}${EXTRACT_SUFX}"
+
 .include <bsd.port.mk>
diff --git a/www/py-django-hijack/distinfo b/www/py-django-hijack/distinfo
index b84e250500cf..a5fca74d58e9 100644
--- a/www/py-django-hijack/distinfo
+++ b/www/py-django-hijack/distinfo
@@ -1,3 +1,5 @@
-TIMESTAMP = 1549044642
-SHA256 (django-hijack-2.1.10.tar.gz) = be484f0ca67a092d5bf9bf8a5307beb716dc2e86b56a69796479183fdeb9036c
-SIZE (django-hijack-2.1.10.tar.gz) = 20480
+TIMESTAMP = 1647700803
+SHA256 (django-hijack-3.1.4.tar.gz) = 785940c2e693401d8302fff4ced2d8cf0beb69a88b7f944539b035ab11b1b6d3
+SIZE (django-hijack-3.1.4.tar.gz) = 213799
+SHA256 (django-hijack-npm-cache-3.1.4.tar.gz) = 54252454e9ba0f93d101494392814027f29792344a9d06cc188f970b5e0e49c5
+SIZE (django-hijack-npm-cache-3.1.4.tar.gz) = 13227839
diff --git a/www/py-django-hijack/files/patch-setup.py b/www/py-django-hijack/files/patch-setup.py
new file mode 100644
index 000000000000..7527154ec8ba
--- /dev/null
+++ b/www/py-django-hijack/files/patch-setup.py
@@ -0,0 +1,35 @@
+Handle the installation by native setuptools to prevent errors like
+"command 'install' has no such option 'single_version_externally_managed'".
+
+--- setup.py.orig	2022-03-12 16:51:11 UTC
++++ setup.py
+@@ -5,7 +5,6 @@ import os
+ import subprocess  # nosec
+ from distutils.cmd import Command
+ from distutils.command.build import build as _build
+-from distutils.command.install import install as _install
+ 
+ from setuptools import setup
+ 
+@@ -62,21 +61,11 @@ class build(_build):
+         ("compile_scss", None),
+     ]
+ 
+-
+-class install(_install):
+-    sub_commands = [
+-        *_install.sub_commands,
+-        ("compile_translations", None),
+-        ("compile_scss", None),
+-    ]
+-
+-
+ setup(
+     name="django-hijack",
+     use_scm_version=True,
+     cmdclass={
+         "build": build,
+-        "install": install,
+         "compile_translations": compile_translations,
+         "compile_scss": compile_scss,
+     },