nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ buildPythonPackage
2, fetchPypi
3, fetchpatch
4, pytestCheckHook
5, brotli
6, cairosvg
7, flit-core
8, fonttools
9, pydyf
10, pyphen
11, cffi
12, cssselect
13, lxml
14, html5lib
15, tinycss
16, zopfli
17, glib
18, harfbuzz
19, pango
20, fontconfig
21, lib
22, stdenv
23, ghostscript
24, isPy3k
25, substituteAll
26}:
27
28buildPythonPackage rec {
29 pname = "weasyprint";
30 version = "54.3";
31 disabled = !isPy3k;
32
33 format = "pyproject";
34
35 src = fetchPypi {
36 inherit version;
37 pname = "weasyprint";
38 sha256 = "sha256-4E2gQGMFZsRMqiAgM/B/hYdl9TZwkEWoCXOfPQSOidY=";
39 };
40
41 patches = [
42 (substituteAll {
43 src = ./library-paths.patch;
44 fontconfig = "${fontconfig.lib}/lib/libfontconfig${stdenv.hostPlatform.extensions.sharedLibrary}";
45 pangoft2 = "${pango.out}/lib/libpangoft2-1.0${stdenv.hostPlatform.extensions.sharedLibrary}";
46 gobject = "${glib.out}/lib/libgobject-2.0${stdenv.hostPlatform.extensions.sharedLibrary}";
47 pango = "${pango.out}/lib/libpango-1.0${stdenv.hostPlatform.extensions.sharedLibrary}";
48 pangocairo = "${pango.out}/lib/libpangocairo-1.0${stdenv.hostPlatform.extensions.sharedLibrary}";
49 harfbuzz = "${harfbuzz.out}/lib/libharfbuzz${stdenv.hostPlatform.extensions.sharedLibrary}";
50 })
51 # Disable tests for new Ghostscript
52 # Remove when next version is released
53 (fetchpatch {
54 url = "https://github.com/Kozea/WeasyPrint/commit/e544398b00d76bc0317ea7e2abe40dc46b380910.patch";
55 sha256 = "sha256-oQO3j9Mo1x98WaLPROxsOn0qkeYRJrCx5QWWKoHvabE=";
56 })
57 ];
58
59 nativeBuildInputs = [
60 flit-core
61 ];
62
63 propagatedBuildInputs = [
64 brotli
65 cairosvg
66 cffi
67 cssselect
68 fonttools
69 html5lib
70 lxml
71 flit-core
72 pydyf
73 pyphen
74 tinycss
75 zopfli
76 ];
77
78 checkInputs = [
79 pytestCheckHook
80 ghostscript
81 ];
82
83 disabledTests = [
84 # needs the Ahem font (fails on macOS)
85 "test_font_stretch"
86 # sensitive to sandbox environments
87 "test_tab_size"
88 "test_tabulation_character"
89 "test_linear_gradients_5"
90 "test_linear_gradients_12"
91 ];
92
93 FONTCONFIG_FILE = "${fontconfig.out}/etc/fonts/fonts.conf";
94
95 postPatch = ''
96 substituteInPlace pyproject.toml \
97 --replace "--isort --flake8 --cov --no-cov-on-fail" ""
98 '';
99
100 preCheck = ''
101 # Fontconfig wants to create a cache.
102 export HOME=$TMPDIR
103 '';
104
105 meta = with lib; {
106 homepage = "https://weasyprint.org/";
107 description = "Converts web documents to PDF";
108 license = licenses.bsd3;
109 maintainers = with maintainers; [ elohmeier ];
110 };
111}