1{
2 lib,
3 stdenv,
4 pkgs,
5 buildPythonPackage,
6 fetchFromGitHub,
7 fontconfig,
8 glib,
9 harfbuzz,
10 pango,
11
12 # build-system
13 flit-core,
14
15 # dependencies
16 cffi,
17 cssselect2,
18 fonttools,
19 pillow,
20 pydyf,
21 pyphen,
22 tinycss2,
23 tinyhtml5,
24
25 # tests
26 pytest-cov-stub,
27 pytestCheckHook,
28 replaceVars,
29 versionCheckHook,
30 writableTmpDirAsHomeHook,
31}:
32
33buildPythonPackage rec {
34 pname = "weasyprint";
35 version = "66.0";
36 pyproject = true;
37
38 __darwinAllowLocalNetworking = true;
39
40 src = fetchFromGitHub {
41 owner = "Kozea";
42 repo = "WeasyPrint";
43 tag = "v${version}";
44 hash = "sha256-wmEDVEbikBpOQ5394IBPWQRjWZOLfMzEGxTtq4tt2Tw=";
45 };
46
47 patches = [
48 (replaceVars ./library-paths.patch {
49 fontconfig = "${fontconfig.lib}/lib/libfontconfig${stdenv.hostPlatform.extensions.sharedLibrary}";
50 gobject = "${glib.out}/lib/libgobject-2.0${stdenv.hostPlatform.extensions.sharedLibrary}";
51 harfbuzz = "${harfbuzz.out}/lib/libharfbuzz${stdenv.hostPlatform.extensions.sharedLibrary}";
52 harfbuzz_subset = "${harfbuzz.out}/lib/libharfbuzz-subset${stdenv.hostPlatform.extensions.sharedLibrary}";
53 pango = "${pango.out}/lib/libpango-1.0${stdenv.hostPlatform.extensions.sharedLibrary}";
54 pangoft2 = "${pango.out}/lib/libpangoft2-1.0${stdenv.hostPlatform.extensions.sharedLibrary}";
55 })
56 ];
57
58 build-system = [ flit-core ];
59
60 dependencies = [
61 cffi
62 cssselect2
63 fonttools
64 pillow
65 pydyf
66 pyphen
67 tinycss2
68 tinyhtml5
69 ]
70 ++ fonttools.optional-dependencies.woff;
71
72 nativeCheckInputs = [
73 pkgs.ghostscript
74 pytest-cov-stub
75 pytestCheckHook
76 versionCheckHook
77 writableTmpDirAsHomeHook
78 ];
79 versionCheckProgramArg = "--version";
80
81 disabledTests = [
82 # needs the Ahem font (fails on macOS)
83 "test_font_stretch"
84 # sensitive to sandbox environments
85 "test_linear_gradients_12"
86 "test_linear_gradients_5"
87 "test_tab_size"
88 "test_tabulation_character"
89 # rounding issues in sandbox
90 "test_empty_inline_auto_margins"
91 "test_images_transparent_text"
92 "test_layout_table_auto_44"
93 "test_layout_table_auto_45"
94 "test_margin_boxes_element"
95 "test_running_elements"
96 "test_vertical_align_4"
97 "test_visibility_1"
98 "test_visibility_3"
99 "test_visibility_4"
100 "test_woff_simple"
101 ];
102
103 FONTCONFIG_FILE = "${fontconfig.out}/etc/fonts/fonts.conf";
104
105 # Set env variable explicitly for Darwin, but allow overriding when invoking directly
106 makeWrapperArgs = [ "--set-default FONTCONFIG_FILE ${FONTCONFIG_FILE}" ];
107
108 pythonImportsCheck = [ "weasyprint" ];
109
110 meta = {
111 changelog = "https://github.com/Kozea/WeasyPrint/releases/tag/${src.tag}";
112 description = "Converts web documents to PDF";
113 mainProgram = "weasyprint";
114 homepage = "https://weasyprint.org/";
115 license = lib.licenses.bsd3;
116 teams = [ lib.teams.apm ];
117 };
118}