2019-03-02 17:56:39 +00:00
|
|
|
commit 0435bc2577d4b18f54b78b2f5185abb2b2005982
|
2016-02-06 07:11:53 +00:00
|
|
|
Author: Alexander V. Nikolaev <avn@avnik.info>
|
|
|
|
Date: Sat Feb 6 08:09:06 2016 +0200
|
|
|
|
|
|
|
|
Patch dlopen() to allow direct paths to all required libs
|
|
|
|
|
|
|
|
This patch is NixOS specific
|
|
|
|
|
|
|
|
diff --git a/cairocffi/__init__.py b/cairocffi/__init__.py
|
2019-03-02 17:56:39 +00:00
|
|
|
index 6061973..3538a58 100644
|
2016-02-06 07:11:53 +00:00
|
|
|
--- a/cairocffi/__init__.py
|
|
|
|
+++ b/cairocffi/__init__.py
|
2019-03-02 17:56:39 +00:00
|
|
|
@@ -21,19 +21,22 @@ VERSION = __version__ = (Path(__file__).parent / 'VERSION').read_text().strip()
|
|
|
|
version = '1.16.0'
|
|
|
|
version_info = (1, 16, 0)
|
2016-02-06 07:11:53 +00:00
|
|
|
|
|
|
|
+# Use hardcoded soname, because ctypes.util use gcc/objdump which shouldn't be required for runtime
|
|
|
|
+_LIBS = {
|
2018-06-06 08:17:52 +01:00
|
|
|
+ 'cairo': '@cairo@/lib/libcairo@ext@',
|
|
|
|
+ 'glib-2.0': '@glib@/lib/libglib-2.0@ext@',
|
|
|
|
+ 'gobject-2.0': '@glib@/lib/libgobject-2.0@ext@',
|
|
|
|
+ 'gdk_pixbuf-2.0': '@gdk_pixbuf@/lib/libgdk_pixbuf-2.0@ext@',
|
2016-02-06 07:11:53 +00:00
|
|
|
+}
|
|
|
|
|
|
|
|
-def dlopen(ffi, *names):
|
|
|
|
+def dlopen(ffi, name, *names):
|
|
|
|
"""Try various names for the same library, for different platforms."""
|
|
|
|
- for name in names:
|
2019-03-02 17:56:39 +00:00
|
|
|
- for lib_name in (name, 'lib' + name):
|
2016-02-06 07:11:53 +00:00
|
|
|
- try:
|
|
|
|
- path = ctypes.util.find_library(lib_name)
|
2019-03-02 17:56:39 +00:00
|
|
|
- lib = ffi.dlopen(path or lib_name)
|
|
|
|
- if lib:
|
|
|
|
- return lib
|
2016-02-06 07:11:53 +00:00
|
|
|
- except OSError:
|
|
|
|
- pass
|
|
|
|
- raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
|
|
|
|
+ path = _LIBS.get(name, None)
|
|
|
|
+ if path:
|
|
|
|
+ lib = ffi.dlopen(path)
|
|
|
|
+ if lib:
|
|
|
|
+ return lib
|
|
|
|
+ raise OSError("dlopen() failed to load a library: %s as %s" % (name, path))
|
|
|
|
|
|
|
|
|
2019-03-02 17:56:39 +00:00
|
|
|
cairo = dlopen(ffi, 'cairo', 'cairo-2', 'cairo-gobject-2', 'cairo.so.2')
|