Open robertknight opened 3 years ago
For anyone else coming across this, we implemented a local workaround in our application that uses pywb:
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.
"""
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()
pywb fails to load on macOS 11.0 Big Sur due to an issue with fakeredis, if using Python <= 3.8. The issue in fakeredis is a problem with the
find_library
function from ctypes. See https://bugs.python.org/issue41179. The issue was patched in ctypes for Python 3.9 and 3.10 but will still affect projects using earlier versions of Python.The code which calls
find_library
doesn't exist in the latest version of fakeredis, so updating the dependency would be one way to solve the problem.Steps to reproduce the bug
wayback
binaryIt fails to start with the following error:
A local workaround is to change the code just above where the error is produced in fakeredis.py from:
To:
Environment
Additional context
The issue was originally encountered in the context of a new version of Hypothesis Via proxy service. We currently use Python 3.6.9 for all of our projects, though we plan to update in future as Python 3.6 and 3.7 are in maintenance mode. Python 3.9 was still only released very recently (Oct 2020), so updating to it may be difficult for some projects.