diff --git a/xchacha20poly1305.py b/xchacha20poly1305.py index 5ef5d8e..d27a7f7 100644 --- a/xchacha20poly1305.py +++ b/xchacha20poly1305.py @@ -35,8 +35,16 @@ import ctypes import ctypes.util +from glob import glob library_path = ctypes.util.find_library("sodium") or ctypes.util.find_library("libsodium") +# Workaround for bpo-21622: https://github.com/python/cpython/pull/18380 +if not library_path and glob("/lib/ld-musl-*.so*"): + library_path = glob("/usr/lib/libsodium.so*")[0] + +if not library_path: + raise RuntimeError("Unable to locate libsodium") + sodium = ctypes.cdll.LoadLibrary(library_path) if not sodium._name: