From 6ec7381fd88046e4f4b46efee2aeb84ba4ed362c Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Wed, 1 May 2024 10:43:37 +0100 Subject: [PATCH 1/2] Update to Python 3.11 --- .python-version | 2 +- Dockerfile | 2 +- tox.ini | 7 +++++++ viahtml/patch.py | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.python-version b/.python-version index 89a1ad7a..d4b278f0 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.8.12 +3.11.7 diff --git a/Dockerfile b/Dockerfile index 4c41a7bd..92befe97 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.8.12-alpine3.13 +FROM python:3.11.8-alpine3.19 LABEL maintainer="Hypothes.is Project and contributors" # Install nginx & supervisor diff --git a/tox.ini b/tox.ini index d0306635..4a40ed80 100644 --- a/tox.ini +++ b/tox.ini @@ -14,6 +14,13 @@ filterwarnings = ignore:^pkg_resources is deprecated as an API:DeprecationWarning:gevent ignore:^pkg_resources is deprecated as an API:DeprecationWarning:pywb + # https://github.com/webpy/webpy/issues/732 + ignore:^'cgi' is deprecated and slated for removal in Python 3.13:DeprecationWarning:webob + ignore:^'cgi' is deprecated and slated for removal in Python 3.13:DeprecationWarning:pywb + + # importlib warning triggered by py3amf + ignore:ModuleFinder\.find_spec\(\) not found; falling back to find_module\(\):ImportWarning:importlib + xfail_strict=true [tox] diff --git a/viahtml/patch.py b/viahtml/patch.py index 5d5f6457..222adf47 100644 --- a/viahtml/patch.py +++ b/viahtml/patch.py @@ -29,7 +29,7 @@ def _patch_url_rewriter(hooks: Hooks): UrlRewriter.NO_REWRITE_URI_PREFIX = tuple(prefixes) -class _PatchedHTMLRewriter(HTMLRewriter): # pylint: disable=abstract-method +class _PatchedHTMLRewriter(HTMLRewriter): hooks: Optional[Hooks] = None @classmethod From 0e2b98e1bee51618185d52d33bd359bb7b5abcbe Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Wed, 1 May 2024 10:48:25 +0100 Subject: [PATCH 2/2] Remove obsolete workaround for macOS With the current version of pywb, viahtml can be run on macOS (tested under macOS 14.4) without this workaround. --- viahtml/__init__.py | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/viahtml/__init__.py b/viahtml/__init__.py index 8acbe433..e69de29b 100644 --- a/viahtml/__init__.py +++ b/viahtml/__init__.py @@ -1,37 +0,0 @@ -"""Setup environment before loading app.""" - -import ctypes.util -import sys -from ctypes import CDLL - - -def patch_ctypes_on_macos_11(): # pragma: no cover - """Work around a problem loading pywb under macOS 11. - - pywb has a dependency on an old version of fakeredis which fails to load - when using Python <= 3.8 under macOS 11. This function patches `ctypes.util.find_library` - to work around the issue. - - See https://github.com/hypothesis/viahtml/issues/55. - """ - - if sys.platform != "darwin": - return - - def _find_library_patched(name): - path = f"lib{name}.dylib" - try: - # In macOS 11, some system libraries don't exist on disk. Instead you test - # the validity of a library path by trying to load it. - # See https://bugs.python.org/issue41179. - CDLL(path) - except OSError: - # Fall back to the un-patched version. - path = ctypes.util.find_library(name) - return path - - ctypes.util.find_library = _find_library_patched - - -# Apply ctypes patch before pywb is imported. -patch_ctypes_on_macos_11()