1{ lib
2, stdenv
3, buildPythonPackage
4, cairosvg
5, cffi
6, cssselect2
7, fetchPypi
8, flit-core
9, fontconfig
10, fonttools
11, ghostscript
12, glib
13, harfbuzz
14, html5lib
15, pango
16, pillow
17, pydyf
18, pyphen
19, pytestCheckHook
20, pythonOlder
21, substituteAll
22, tinycss2
23}:
24
25buildPythonPackage rec {
26 pname = "weasyprint";
27 version = "57.0";
28 format = "pyproject";
29
30 disabled = pythonOlder "3.7";
31
32 src = fetchPypi {
33 inherit version;
34 pname = "weasyprint";
35 hash = "sha256-e29cwTgZ6afYdIwdvw6NJET3pIGKmDOfgtzKqCK/kRs=";
36 };
37
38 patches = [
39 (substituteAll {
40 src = ./library-paths.patch;
41 fontconfig = "${fontconfig.lib}/lib/libfontconfig${stdenv.hostPlatform.extensions.sharedLibrary}";
42 pangoft2 = "${pango.out}/lib/libpangoft2-1.0${stdenv.hostPlatform.extensions.sharedLibrary}";
43 gobject = "${glib.out}/lib/libgobject-2.0${stdenv.hostPlatform.extensions.sharedLibrary}";
44 pango = "${pango.out}/lib/libpango-1.0${stdenv.hostPlatform.extensions.sharedLibrary}";
45 pangocairo = "${pango.out}/lib/libpangocairo-1.0${stdenv.hostPlatform.extensions.sharedLibrary}";
46 harfbuzz = "${harfbuzz.out}/lib/libharfbuzz${stdenv.hostPlatform.extensions.sharedLibrary}";
47 })
48 ];
49
50 nativeBuildInputs = [
51 flit-core
52 ];
53
54 propagatedBuildInputs = [
55 cffi
56 cssselect2
57 fonttools
58 html5lib
59 pillow
60 pydyf
61 pyphen
62 tinycss2
63 ] ++ fonttools.optional-dependencies.woff;
64
65 checkInputs = [
66 pytestCheckHook
67 ghostscript
68 ];
69
70 disabledTests = [
71 # needs the Ahem font (fails on macOS)
72 "test_font_stretch"
73 # sensitive to sandbox environments
74 "test_tab_size"
75 "test_tabulation_character"
76 "test_linear_gradients_5"
77 "test_linear_gradients_12"
78 ];
79
80 FONTCONFIG_FILE = "${fontconfig.out}/etc/fonts/fonts.conf";
81
82 postPatch = ''
83 substituteInPlace pyproject.toml \
84 --replace "--isort --flake8 --cov --no-cov-on-fail" ""
85 '';
86
87 preCheck = ''
88 # Fontconfig wants to create a cache.
89 export HOME=$TMPDIR
90 '';
91
92 pythonImportsCheck = [
93 "weasyprint"
94 ];
95
96 meta = with lib; {
97 description = "Converts web documents to PDF";
98 homepage = "https://weasyprint.org/";
99 license = licenses.bsd3;
100 maintainers = with maintainers; [ elohmeier ];
101 };
102}