Can you update to >= 18.0 or apply https://github.com/cherrypy/cherrypy/commit/2fc78dc9af3e ? $ python3.9 Python 3.9.0 (default, Oct 15 2020, 22:11:05) [Clang 11.0.0 (git@github.com:llvm/llvm-project.git llvmorg-11.0.0-rc5-0-g60a25 on freebsd13 Type "help", "copyright", "credits" or "license" for more information. >>> import cherrypy Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.9/site-packages/cherrypy/__init__.py", line 73, in <module> from ._cptools import default_toolbox as tools, Tool File "/usr/local/lib/python3.9/site-packages/cherrypy/_cptools.py", line 31, in <module> from cherrypy.lib import sessions as _sessions, xmlrpcutil as _xmlrpc File "/usr/local/lib/python3.9/site-packages/cherrypy/lib/sessions.py", line 112, in <module> import contextlib2 ModuleNotFoundError: No module named 'contextlib2'
Updating to a newer version is still not possible without (at least) two new ports. Patch inbound shortly.
Created attachment 218781 [details] Patch ported from upstream Fixes the regression with upstream's patch applied to Python >= 3.8 Has been tested as far as fixing the ImportError, I don't have any applications running on the later python versions with which to test (but don't see any reason why it wouldn't work - upstream didn't make huge code changes either).
Created attachment 218782 [details] Poudriere build log
Comment on attachment 218781 [details] Patch ported from upstream Works for me. Tested via www/py-flexget but I did't enable web_server which actually uses cherrypy.
Comment on attachment 218781 [details] Patch ported from upstream > +.if ${PYTHON_REL} >= 3800 [..] > .if ${PYTHON_REL} < 3800 > RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}contextlib2>0:devel/py-contextlib2@${PY_FLAVOR} Why is devel/py-contextlib2 disabled for python >= 3.8? "import cherrypy" survives with external "contextlib2" under lang/python39. Why python 3.6 and 3.7 cannot use default "contextlib" instead of "contextlib2"? "import cherrypy" survives with "contextlib" patches. https://contextlib2.readthedocs.io/en/stable/ says "contextlib2" is a backport of "contextlib" from python 3.6, so it shouldn't be necessery with lang/python36 while lang/python35 and older are no longer in the ports tree. > +EXTRA_PATCHES+= ${FILESDIR}/extra-patch-cherrypy_lib_sessions.py > +EXTRA_PATCHES+= ${FILESDIR}/extra-patch-setup.py Maybe combine into one file and document the patch origin in the header.
(In reply to Jan Beich from comment #5) > Why is devel/py-contextlib2 disabled for python >= 3.8? Officially Python 3.8+ are not on the supported versions list for contextlib2. The last supported version is Python 3.7 see: https://pypi.org/project/contextlib2/ It's python though, so unless it's doing something with a dropped/modified stdlib it's not a huge surprise that it works fine. > Why python 3.6 and 3.7 cannot use default "contextlib" instead of "contextlib2"? After a quick code review of what that library is pulled in for (cathing an exception), they probably can. This version of CherryPy still has Python 2 support & contextlib2 is required for that. I'll apply the patch to python > 3.2 (earliest version that shipped with contextlib) and drop contextlib2 as a dependency for those versions. > Maybe combine into one file and document the patch origin in the header. Can do, I'll submit an updated patch shortly that does all of the above.
Created attachment 218825 [details] Patch ported from upstream, remove contextlib2 for Python 3 Changes as described in comment #6 Some Makefile cleanup also included to satisfy portlint.
Created attachment 218826 [details] Patch ported from upstream, remove contextlib2 for Python 3 Actually puts the dependency against Python 2 rather than Python 3, cleans up the extra .if statement.
Created attachment 218827 [details] Updated poudriere build log (Python 3.7)
Created attachment 218828 [details] Poudriere build log (Python 2.7)