git: fc93af74b8da - 2021Q2 - www/py-cherrypy: Fix runtime with Python 3.8 and onward

Kai Knoblich kai at FreeBSD.org
Fri May 7 13:30:10 UTC 2021


The branch 2021Q2 has been updated by kai:

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

commit fc93af74b8da19e5742801a0aafad914d73cb9af
Author:     Kai Knoblich <kai at FreeBSD.org>
AuthorDate: 2021-04-25 18:45:34 +0000
Commit:     Kai Knoblich <kai at FreeBSD.org>
CommitDate: 2021-05-07 13:29:32 +0000

    www/py-cherrypy: Fix runtime with Python 3.8 and onward
    
    Backport patches from the 18.x release branch that uses the Python's
    library "contextlib" instead of the external library "contextlib2".
    
    The "contextlib2" library is a backported version which is required for
    compatibility with Python 2.7 as the 17.x release of CherryPy is the
    last one that has compatibility for Python 2.7.
    
    Since the support for Python 2.7 has been removed in aa7a6c429ea6,
    "contextlib2 is no longer needed for backward compatibility.
    
    This is a transitional solution to fix the regression with Python 3.8
    because an update to the 18.x release needs a bit more work and also
    requires one or more new Python packages.
    
    While I'm here:
    
    * Sort variables according to the PHB and pet portclippy.
    * Remove superfluous EXAMPLESDIR.
    * Convert to newer options framework.
    * Set NO_ARCH as there are no architecture specific files.
    * Add "do-test" target to make future QA easier.
    
    PR:             250379
    Reported by:    jbeich
    Approved by:    maintainer timeout (6+ months)
    MFH:            2021Q2
    
    (cherry picked from commit 7915fe9b3fce2721c82d041ebbe47cf0a47981c1)
---
 www/py-cherrypy/Makefile                           | 43 ++++++++++++----------
 .../files/patch-cherrypy_lib_sessions.py           | 27 ++++++++++++++
 www/py-cherrypy/files/patch-setup.py               | 17 +++++++++
 3 files changed, 68 insertions(+), 19 deletions(-)

diff --git a/www/py-cherrypy/Makefile b/www/py-cherrypy/Makefile
index 9e9c1b357292..18393c8fce00 100644
--- a/www/py-cherrypy/Makefile
+++ b/www/py-cherrypy/Makefile
@@ -2,6 +2,7 @@
 
 PORTNAME=	cherrypy
 PORTVERSION=	17.4.2
+PORTREVISION=	1
 CATEGORIES=	www python
 MASTER_SITES=	CHEESESHOP
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
@@ -14,40 +15,44 @@ LICENSE=	BSD3CLAUSE
 
 BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}pip>0:devel/py-pip@${PY_FLAVOR} \
 		${PYTHON_PKGNAMEPREFIX}setuptools_scm>0:devel/py-setuptools_scm@${PY_FLAVOR}
-
-EXAMPLES_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}sqlobject>=1.5.1:databases/py-sqlobject@${PY_FLAVOR} \
-			${PYTHON_PKGNAMEPREFIX}cheetah3>0:devel/py-cheetah3@${PY_FLAVOR}
-EXAMPLESDIR=	${PREFIX}/share/examples/${PKGNAMEPREFIX}${PORTNAME}
-
 RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}six>=1.11.0:devel/py-six@${PY_FLAVOR} \
 		${PYTHON_PKGNAMEPREFIX}cheroot>=6.2.4:www/py-cheroot@${PY_FLAVOR} \
 		${PYTHON_PKGNAMEPREFIX}portend>=2.1.1:net/py-portend@${PY_FLAVOR} \
 		${PYTHON_PKGNAMEPREFIX}zclockfile>0:devel/py-zclockfile@${PY_FLAVOR} \
 		${PYTHON_PKGNAMEPREFIX}more-itertools>0:devel/py-more-itertools@${PY_FLAVOR}
+TEST_DEPENDS=	${PYTHON_PKGNAMEPREFIX}pytest>=2.8:devel/py-pytest@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}path.py>0:devel/py-path.py@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}requests-toolbelt>0:www/py-requests-toolbelt@${PY_FLAVOR}
 
-OPTIONS_DEFINE=	EXAMPLES
+USES=		python:3.6+
+USE_PYTHON=	distutils autoplist concurrent
+
+TEST_ENV=	PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
 
+NO_ARCH=	yes
 PORTEXAMPLES=	*
 
-USES=		python:3.6+
-USE_PYTHON=	distutils autoplist concurrent
+OPTIONS_DEFINE=	EXAMPLES
 
-.include <bsd.port.options.mk>
+EXAMPLES_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}sqlobject>=1.5.1:databases/py-sqlobject@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}cheetah3>0:devel/py-cheetah3@${PY_FLAVOR}
 
-.if ${PORT_OPTIONS:MEXAMPLES}
-post-install:
+post-install-EXAMPLES-on:
 	@${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
 	(cd ${WRKSRC}/cherrypy/tutorial && \
 	${COPYTREE_SHARE} . ${STAGEDIR}${EXAMPLESDIR})
 	(cd ${STAGEDIR}${PREFIX} && \
 	${PYTHON_CMD} ${PYTHON_LIBDIR}/compileall.py \
 		-d ${EXAMPLESDIR} ${EXAMPLESDIR:S,${PREFIX}/,,})
-.endif
-
-.include <bsd.port.pre.mk>
-
-.if ${PYTHON_REL} < 3800
-RUN_DEPENDS+=	${PYTHON_PKGNAMEPREFIX}contextlib2>0:devel/py-contextlib2@${PY_FLAVOR}
-.endif
 
-.include <bsd.port.post.mk>
+# Some tests fails with Python 3.6/3.7/3.8/3.9 and are omitted for now.
+# This should be revised once the ports gets updated to a newer release.
+do-test:
+	@cd ${TEST_WRKSRC} && ${SETENV} ${TEST_ENV} ${PYTHON_CMD} -m pytest -v -rs \
+		-o addopts='' \
+		-k 'not test_HTTP11_Timeout_after_request \
+		and not test_threadlocal_garbage \
+		and not test_null_bytes \
+		and not testCombinedTools'
+
+.include <bsd.port.mk>
diff --git a/www/py-cherrypy/files/patch-cherrypy_lib_sessions.py b/www/py-cherrypy/files/patch-cherrypy_lib_sessions.py
new file mode 100644
index 000000000000..8130d1130c5c
--- /dev/null
+++ b/www/py-cherrypy/files/patch-cherrypy_lib_sessions.py
@@ -0,0 +1,27 @@
+Remove contextlib2 and use contextlib from the standard library.
+
+* Contextlib has been in the Python standard library since Python 3.2.
+* Contextlib2 is a backport to Python 2 (and is supported through Python 3.7).
+
+Obtained from: https://github.com/cherrypy/cherrypy/commit/2fc78dc9af3e
+
+--- cherrypy/lib/sessions.py.orig	2021-04-22 13:06:39 UTC
++++ cherrypy/lib/sessions.py
+@@ -109,7 +109,7 @@ import binascii
+
+ import six
+ from six.moves import cPickle as pickle
+-import contextlib2
++import contextlib
+
+ import zc.lockfile
+
+@@ -572,7 +572,7 @@ class FileSession(Session):
+     def release_lock(self, path=None):
+         """Release the lock on the currently-loaded session data."""
+         self.lock.close()
+-        with contextlib2.suppress(FileNotFoundError):
++        with contextlib.suppress(FileNotFoundError):
+             os.remove(self.lock._path)
+         self.locked = False
+
diff --git a/www/py-cherrypy/files/patch-setup.py b/www/py-cherrypy/files/patch-setup.py
new file mode 100644
index 000000000000..d06d636f7de7
--- /dev/null
+++ b/www/py-cherrypy/files/patch-setup.py
@@ -0,0 +1,17 @@
+Remove contextlib2 and use contextlib from the standard library.
+
+* Contextlib has been in the Python standard library since Python 3.2.
+* Contextlib2 is a backport to Python 2 (and is supported through Python 3.7).
+
+Obtained from: https://github.com/cherrypy/cherrypy/commit/2fc78dc9af3e
+
+--- setup.py.orig	2021-04-22 13:05:31 UTC
++++ setup.py
+@@ -66,7 +66,6 @@ params = dict(
+         'portend>=2.1.1',
+         'more_itertools',
+         'zc.lockfile',
+-        'contextlib2',
+     ],
+     extras_require={
+         'docs': [


More information about the dev-commits-ports-branches mailing list