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:
parent
8dac864470
commit
e878fd6f5f
pkgs
development/python-modules/cairocffi
top-level
|
@ -1,12 +1,14 @@
|
||||||
# FIXME: make gdk_pixbuf dependency optional
|
# FIXME: make gdk_pixbuf dependency optional
|
||||||
{ stdenv
|
{ stdenv
|
||||||
, buildPythonPackage
|
, buildPythonPackage
|
||||||
|
, pythonOlder
|
||||||
, fetchPypi
|
, fetchPypi
|
||||||
, lib
|
, lib
|
||||||
, substituteAll
|
, substituteAll
|
||||||
, makeFontsConf
|
, makeFontsConf
|
||||||
, freefont_ttf
|
, freefont_ttf
|
||||||
, pytest
|
, pytest
|
||||||
|
, pytestrunner
|
||||||
, glibcLocales
|
, glibcLocales
|
||||||
, cairo
|
, cairo
|
||||||
, cffi
|
, cffi
|
||||||
|
@ -15,46 +17,62 @@
|
||||||
, glib
|
, glib
|
||||||
, gdk_pixbuf }:
|
, gdk_pixbuf }:
|
||||||
|
|
||||||
buildPythonPackage rec {
|
let
|
||||||
pname = "cairocffi";
|
generic = { version, sha256, dlopen_patch, disabled ? false }:
|
||||||
version = "1.0.2";
|
buildPythonPackage rec {
|
||||||
|
pname = "cairocffi";
|
||||||
|
inherit version disabled;
|
||||||
|
|
||||||
src = fetchPypi {
|
src = fetchPypi {
|
||||||
inherit pname version;
|
inherit pname version sha256;
|
||||||
sha256 = "01ac51ae12c4324ca5809ce270f9dd1b67f5166fe63bd3e497e9ea3ca91946ff";
|
};
|
||||||
};
|
|
||||||
|
|
||||||
LC_ALL = "en_US.UTF-8";
|
LC_ALL = "en_US.UTF-8";
|
||||||
|
|
||||||
# checkPhase require at least one 'normal' font and one 'monospace',
|
# checkPhase require at least one 'normal' font and one 'monospace',
|
||||||
# otherwise glyph tests fails
|
# otherwise glyph tests fails
|
||||||
FONTCONFIG_FILE = makeFontsConf {
|
FONTCONFIG_FILE = makeFontsConf {
|
||||||
fontDirectories = [ freefont_ttf ];
|
fontDirectories = [ freefont_ttf ];
|
||||||
};
|
};
|
||||||
|
|
||||||
checkInputs = [ pytest glibcLocales ];
|
checkInputs = [ pytest pytestrunner glibcLocales ];
|
||||||
propagatedBuildInputs = [ cairo cffi ] ++ lib.optional withXcffib xcffib;
|
propagatedBuildInputs = [ cairo cffi ] ++ lib.optional withXcffib xcffib;
|
||||||
|
|
||||||
checkPhase = ''
|
checkPhase = ''
|
||||||
py.test $out/${python.sitePackages}
|
py.test $out/${python.sitePackages}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
patches = [
|
patches = [
|
||||||
# OSError: dlopen() failed to load a library: gdk_pixbuf-2.0 / gdk_pixbuf-2.0-0
|
# OSError: dlopen() failed to load a library: gdk_pixbuf-2.0 / gdk_pixbuf-2.0-0
|
||||||
(substituteAll {
|
(substituteAll {
|
||||||
src = ./dlopen-paths.patch;
|
src = dlopen_patch;
|
||||||
ext = stdenv.hostPlatform.extensions.sharedLibrary;
|
ext = stdenv.hostPlatform.extensions.sharedLibrary;
|
||||||
cairo = cairo.out;
|
cairo = cairo.out;
|
||||||
glib = glib.out;
|
glib = glib.out;
|
||||||
gdk_pixbuf = gdk_pixbuf.out;
|
gdk_pixbuf = gdk_pixbuf.out;
|
||||||
})
|
})
|
||||||
./fix_test_scaled_font.patch
|
./fix_test_scaled_font.patch
|
||||||
];
|
];
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
homepage = https://github.com/SimonSapin/cairocffi;
|
homepage = https://github.com/SimonSapin/cairocffi;
|
||||||
license = licenses.bsd3;
|
license = licenses.bsd3;
|
||||||
maintainers = with maintainers; [];
|
maintainers = with maintainers; [];
|
||||||
description = "cffi-based cairo bindings for Python";
|
description = "cffi-based cairo bindings for Python";
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
cairocffi_1_0 = generic {
|
||||||
|
version = "1.0.2";
|
||||||
|
sha256 = "01ac51ae12c4324ca5809ce270f9dd1b67f5166fe63bd3e497e9ea3ca91946ff";
|
||||||
|
dlopen_patch = ./dlopen-paths.patch;
|
||||||
|
disabled = pythonOlder "3.5";
|
||||||
|
};
|
||||||
|
|
||||||
|
cairocffi_0_9 = generic {
|
||||||
|
version = "0.9.0";
|
||||||
|
sha256 = "15386c3a9e08823d6826c4491eaccc7b7254b1dc587a3b9ce60c350c3f990337";
|
||||||
|
dlopen_patch = ./dlopen-paths-0.9.patch;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
commit 705dc9a55bd160625d9996e63fc7dc532d0ad0ab
|
||||||
|
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
|
||||||
|
index 718aa7f..1a1dcff 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)
|
||||||
|
|
||||||
|
+# Use hardcoded soname, because ctypes.util use gcc/objdump which shouldn't be required for runtime
|
||||||
|
+_LIBS = {
|
||||||
|
+ '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@',
|
||||||
|
+}
|
||||||
|
|
||||||
|
-def dlopen(ffi, *names):
|
||||||
|
+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]:
|
||||||
|
- try:
|
||||||
|
- path = ctypes.util.find_library(lib_name)
|
||||||
|
- if path:
|
||||||
|
- lib = ffi.dlopen(path)
|
||||||
|
- if lib:
|
||||||
|
- return lib
|
||||||
|
- 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))
|
||||||
|
|
||||||
|
|
||||||
|
cairo = dlopen(ffi, 'cairo', 'cairo-2')
|
|
@ -1,4 +1,4 @@
|
||||||
commit 705dc9a55bd160625d9996e63fc7dc532d0ad0ab
|
commit 0435bc2577d4b18f54b78b2f5185abb2b2005982
|
||||||
Author: Alexander V. Nikolaev <avn@avnik.info>
|
Author: Alexander V. Nikolaev <avn@avnik.info>
|
||||||
Date: Sat Feb 6 08:09:06 2016 +0200
|
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
|
This patch is NixOS specific
|
||||||
|
|
||||||
diff --git a/cairocffi/__init__.py b/cairocffi/__init__.py
|
diff --git a/cairocffi/__init__.py b/cairocffi/__init__.py
|
||||||
index 718aa7f..1a1dcff 100644
|
index 6061973..3538a58 100644
|
||||||
--- a/cairocffi/__init__.py
|
--- a/cairocffi/__init__.py
|
||||||
+++ b/cairocffi/__init__.py
|
+++ b/cairocffi/__init__.py
|
||||||
@@ -27,20 +27,22 @@ VERSION = '0.7.2'
|
@@ -21,19 +21,22 @@ VERSION = __version__ = (Path(__file__).parent / 'VERSION').read_text().strip()
|
||||||
version = '1.10.0'
|
version = '1.16.0'
|
||||||
version_info = (1, 10, 0)
|
version_info = (1, 16, 0)
|
||||||
|
|
||||||
+# Use hardcoded soname, because ctypes.util use gcc/objdump which shouldn't be required for runtime
|
+# Use hardcoded soname, because ctypes.util use gcc/objdump which shouldn't be required for runtime
|
||||||
+_LIBS = {
|
+_LIBS = {
|
||||||
|
@ -26,13 +26,12 @@ index 718aa7f..1a1dcff 100644
|
||||||
+def dlopen(ffi, name, *names):
|
+def dlopen(ffi, name, *names):
|
||||||
"""Try various names for the same library, for different platforms."""
|
"""Try various names for the same library, for different platforms."""
|
||||||
- for name in names:
|
- for name in names:
|
||||||
- for lib_name in [name, 'lib' + name]:
|
- for lib_name in (name, 'lib' + name):
|
||||||
- try:
|
- try:
|
||||||
- path = ctypes.util.find_library(lib_name)
|
- path = ctypes.util.find_library(lib_name)
|
||||||
- if path:
|
- lib = ffi.dlopen(path or lib_name)
|
||||||
- lib = ffi.dlopen(path)
|
- if lib:
|
||||||
- if lib:
|
- return lib
|
||||||
- return lib
|
|
||||||
- except OSError:
|
- except OSError:
|
||||||
- pass
|
- pass
|
||||||
- raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
|
- 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))
|
+ 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')
|
||||||
|
|
|
@ -1311,7 +1311,10 @@ in {
|
||||||
|
|
||||||
canmatrix = callPackage ../development/python-modules/canmatrix {};
|
canmatrix = callPackage ../development/python-modules/canmatrix {};
|
||||||
|
|
||||||
cairocffi = callPackage ../development/python-modules/cairocffi {};
|
|
||||||
|
cairocffi = let
|
||||||
|
inherit (callPackage ../development/python-modules/cairocffi {}) cairocffi_1_0 cairocffi_0_9;
|
||||||
|
in if isPy3k then cairocffi_1_0 else cairocffi_0_9;
|
||||||
|
|
||||||
cairosvg1 = callPackage ../development/python-modules/cairosvg/1_x.nix {};
|
cairosvg1 = callPackage ../development/python-modules/cairosvg/1_x.nix {};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue