1Patch dlopen() to allow direct paths to all required libs 2 3diff --git a/cairocffi/__init__.py b/cairocffi/__init__.py 4index f917d90..31dab12 100644 5--- a/cairocffi/__init__.py 6+++ b/cairocffi/__init__.py 7@@ -22,6 +22,14 @@ VERSION = __version__ = '1.7.1' 8 version = '1.17.2' 9 version_info = (1, 17, 2) 10 11+# Use hardcoded soname, because ctypes.util use gcc/objdump which shouldn't be 12+# required for runtime 13+_LIBS = { 14+ 'cairo': '@cairo@/lib/libcairo@ext@', 15+ 'glib-2.0': '@glib@/lib/libglib-2.0@ext@', 16+ 'gobject-2.0': '@glib@/lib/libgobject-2.0@ext@', 17+ 'gdk_pixbuf-2.0': '@gdk_pixbuf@/lib/libgdk_pixbuf-2.0@ext@', 18+} 19 20 # Python 3.8 no longer searches for DLLs in PATH, so we can add everything in 21 # CAIROCFFI_DLL_DIRECTORIES manually. Note that unlike PATH, add_dll_directory 22@@ -36,26 +44,14 @@ if dll_directories and hasattr(os, 'add_dll_directory'): 23 24 def dlopen(ffi, library_names, filenames): 25 """Try various names for the same library, for different platforms.""" 26- exceptions = [] 27- 28 for library_name in library_names: 29- library_filename = find_library(library_name) 30- if library_filename: 31- filenames = (library_filename, *filenames) 32- else: 33- exceptions.append( 34- 'no library called "{}" was found'.format(library_name)) 35- 36- for filename in filenames: 37- try: 38- return ffi.dlopen(filename) 39- except OSError as exception: # pragma: no cover 40- exceptions.append(exception) 41- 42- error_message = '\n'.join( # pragma: no cover 43- str(exception) for exception in exceptions) 44- raise OSError(error_message) # pragma: no cover 45+ path = _LIBS.get(library_name, None) 46+ if path: 47+ lib = ffi.dlopen(path) 48+ if lib: 49+ return lib 50 51+ raise OSError("dlopen() failed to load a library: %s as %s" % (library_name, path)) 52 53 cairo = dlopen( 54 ffi, ('cairo-2', 'cairo', 'libcairo-2'),