1# FIXME: make gdk_pixbuf dependency optional
2{ buildPythonPackage
3, fetchPypi
4, lib
5, substituteAll
6, makeFontsConf
7, freefont_ttf
8, pytest
9, glibcLocales
10, cairo
11, cffi
12, withXcffib ? false, xcffib
13, python
14, glib
15, gdk_pixbuf }:
16
17buildPythonPackage rec {
18 pname = "cairocffi";
19 version = "0.8.0";
20
21 src = fetchPypi {
22 inherit pname version;
23 sha256 = "0i9m3p39g9wrkpjvpawch2qmnmm3cnim7niz3nmmbcp2hrkixwk5";
24 };
25
26 LC_ALL = "en_US.UTF-8";
27
28 # checkPhase require at least one 'normal' font and one 'monospace',
29 # otherwise glyph tests fails
30 FONTCONFIG_FILE = makeFontsConf {
31 fontDirectories = [ freefont_ttf ];
32 };
33
34 checkInputs = [ pytest glibcLocales ];
35 propagatedBuildInputs = [ cairo cffi ] ++ lib.optional withXcffib xcffib;
36
37 checkPhase = ''
38 py.test $out/${python.sitePackages}
39 '';
40
41 patches = [
42 # OSError: dlopen() failed to load a library: gdk_pixbuf-2.0 / gdk_pixbuf-2.0-0
43 (substituteAll {
44 src = ./dlopen-paths.patch;
45 cairo = cairo.out;
46 glib = glib.out;
47 gdk_pixbuf = gdk_pixbuf.out;
48 })
49 ./fix_test_scaled_font.patch
50 ];
51
52 meta = with lib; {
53 homepage = https://github.com/SimonSapin/cairocffi;
54 license = licenses.bsd3;
55 maintainers = with maintainers; [];
56 description = "cffi-based cairo bindings for Python";
57 };
58}