pythonPackages.cairocffi: support 1.0 and 0.9

This patch ensures that Python2 can be used if cairocffi is used.
Version 1.0 dropped Python 2 support.
This commit is contained in:
Alexander V. Nikolaev
2019-03-02 19:56:39 +02:00
committed by Robert Schütz
parent 8dac864470
commit e878fd6f5f
4 changed files with 115 additions and 48 deletions

View File

@@ -1,4 +1,4 @@
commit 705dc9a55bd160625d9996e63fc7dc532d0ad0ab
commit 0435bc2577d4b18f54b78b2f5185abb2b2005982
Author: Alexander V. Nikolaev <avn@avnik.info>
Date: Sat Feb 6 08:09:06 2016 +0200
@@ -7,12 +7,12 @@ Date: Sat Feb 6 08:09:06 2016 +0200
This patch is NixOS specific
diff --git a/cairocffi/__init__.py b/cairocffi/__init__.py
index 718aa7f..1a1dcff 100644
index 6061973..3538a58 100644
--- a/cairocffi/__init__.py
+++ b/cairocffi/__init__.py
@@ -27,20 +27,22 @@ VERSION = '0.7.2'
version = '1.10.0'
version_info = (1, 10, 0)
@@ -21,19 +21,22 @@ VERSION = __version__ = (Path(__file__).parent / 'VERSION').read_text().strip()
version = '1.16.0'
version_info = (1, 16, 0)
+# Use hardcoded soname, because ctypes.util use gcc/objdump which shouldn't be required for runtime
+_LIBS = {
@@ -26,13 +26,12 @@ index 718aa7f..1a1dcff 100644
+def dlopen(ffi, name, *names):
"""Try various names for the same library, for different platforms."""
- for name in names:
- for lib_name in [name, 'lib' + name]:
- for lib_name in (name, 'lib' + name):
- try:
- path = ctypes.util.find_library(lib_name)
- if path:
- lib = ffi.dlopen(path)
- if lib:
- return lib
- lib = ffi.dlopen(path or lib_name)
- if lib:
- return lib
- except OSError:
- pass
- raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
@@ -44,4 +43,4 @@ index 718aa7f..1a1dcff 100644
+ raise OSError("dlopen() failed to load a library: %s as %s" % (name, path))
cairo = dlopen(ffi, 'cairo', 'cairo-2')
cairo = dlopen(ffi, 'cairo', 'cairo-2', 'cairo-gobject-2', 'cairo.so.2')