1{ buildPythonPackage,
2 fetchPypi,
3 cairosvg,
4 pyphen,
5 cffi,
6 cssselect,
7 lxml,
8 html5lib,
9 tinycss,
10 pygobject2,
11 glib,
12 pango,
13 fontconfig,
14 stdenv,
15 pytest,
16 pytestrunner,
17 pytest-isort,
18 pytest-flake8,
19 pytestcov,
20 isPy3k,
21 substituteAll
22}:
23
24buildPythonPackage rec {
25 pname = "weasyprint";
26 version = "50";
27 disabled = !isPy3k;
28
29 # excluded test needs the Ahem font
30 checkPhase = ''
31 runHook preCheck
32 pytest -k 'not test_font_stretch'
33 runHook postCheck
34 '';
35
36 # ignore failing flake8-test
37 prePatch = ''
38 substituteInPlace setup.cfg \
39 --replace '[tool:pytest]' '[tool:pytest]\nflake8-ignore = E501'
40 '';
41
42 checkInputs = [ pytest pytestrunner pytest-isort pytest-flake8 pytestcov ];
43
44 FONTCONFIG_FILE = "${fontconfig.out}/etc/fonts/fonts.conf";
45
46 propagatedBuildInputs = [ cairosvg pyphen cffi cssselect lxml html5lib tinycss pygobject2 ];
47
48 patches = [
49 (substituteAll {
50 src = ./library-paths.patch;
51 fontconfig = "${fontconfig.lib}/lib/libfontconfig${stdenv.hostPlatform.extensions.sharedLibrary}";
52 pangoft2 = "${pango.out}/lib/libpangoft2-1.0${stdenv.hostPlatform.extensions.sharedLibrary}";
53 gobject = "${glib.out}/lib/libgobject-2.0${stdenv.hostPlatform.extensions.sharedLibrary}";
54 pango = "${pango.out}/lib/libpango-1.0${stdenv.hostPlatform.extensions.sharedLibrary}";
55 pangocairo = "${pango.out}/lib/libpangocairo-1.0${stdenv.hostPlatform.extensions.sharedLibrary}";
56 })
57 ];
58
59 src = fetchPypi {
60 inherit version;
61 pname = "WeasyPrint";
62 sha256 = "0invs96zvmcr6wh5klj52jrcnr9qg150v9wpmbhcsf3vv1d1hbcw";
63 };
64
65 meta = with stdenv.lib; {
66 homepage = https://weasyprint.org/;
67 description = "Converts web documents to PDF";
68 license = licenses.bsd3;
69 maintainers = with maintainers; [ elohmeier ];
70 };
71}