Merge pull request #307098 from r-ryantm/auto-update/cilium-cli
[NixPkgs.git] / pkgs / development / python-modules / cairocffi / dlopen-paths.patch
blob6542b4367eb455425af285391908935b96601aaf
1 Patch dlopen() to allow direct paths to all required libs
3 This is an update of the patch submitted in
4 https://github.com/NixOS/nixpkgs/commit/b13e44e094989d3a902f8c73b22e8d3c0cc7acf4
5 by Alexander V. Nikolaev <avn@avnik.info>
7 ---
8 cairocffi/__init__.py | 34 ++++++++++++++++------------------
9 1 file changed, 16 insertions(+), 18 deletions(-)
11 diff --git a/cairocffi/__init__.py b/cairocffi/__init__.py
12 index 307d58c..43c29e3 100644
13 --- a/cairocffi/__init__.py
14 +++ b/cairocffi/__init__.py
15 @@ -21,28 +21,26 @@ VERSION = __version__ = (Path(__file__).parent / 'VERSION').read_text().strip()
16 version = '1.17.2'
17 version_info = (1, 17, 2)
19 +# Use hardcoded soname, because ctypes.util use gcc/objdump which shouldn't be
20 +# required for runtime
21 +_LIBS = {
22 + 'cairo': '@cairo@/lib/libcairo@ext@',
23 + 'glib-2.0': '@glib@/lib/libglib-2.0@ext@',
24 + 'gobject-2.0': '@glib@/lib/libgobject-2.0@ext@',
25 + 'gdk_pixbuf-2.0': '@gdk_pixbuf@/lib/libgdk_pixbuf-2.0@ext@',
29 def dlopen(ffi, library_names, filenames):
30 """Try various names for the same library, for different platforms."""
31 - exceptions = []
33 for library_name in library_names:
34 - library_filename = find_library(library_name)
35 - if library_filename:
36 - filenames = (library_filename,) + filenames
37 - else:
38 - exceptions.append(
39 - 'no library called "{}" was found'.format(library_name))
41 - for filename in filenames:
42 - try:
43 - return ffi.dlopen(filename)
44 - except OSError as exception: # pragma: no cover
45 - exceptions.append(exception)
47 - error_message = '\n'.join( # pragma: no cover
48 - str(exception) for exception in exceptions)
49 - raise OSError(error_message) # pragma: no cover
50 + path = _LIBS.get(library_name, None)
51 + if path:
52 + lib = ffi.dlopen(path)
53 + if lib:
54 + return lib
56 + raise OSError("dlopen() failed to load a library: %s as %s" % (library_name, path))
59 cairo = dlopen(
61 2.19.2