nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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 (finalAttrs: {
34 pname = "weasyprint";
35 version = "68.0";
36 pyproject = true;
37
38 __darwinAllowLocalNetworking = true;
39
40 src = fetchFromGitHub {
41 owner = "Kozea";
42 repo = "WeasyPrint";
43 tag = "v${finalAttrs.version}";
44 hash = "sha256-kAJgSQz1RKrPwzO7I5xHXyXcXYJtvca9izjrAgTy3ek=";
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
80 disabledTests = [
81 # needs the Ahem font (fails on macOS)
82 "test_font_stretch"
83 # sensitive to sandbox environments
84 "test_linear_gradients_12"
85 "test_linear_gradients_5"
86 "test_tab_size"
87 "test_tabulation_character"
88 # rounding issues in sandbox
89 "test_empty_inline_auto_margins"
90 "test_images_transparent_text"
91 "test_layout_table_auto_44"
92 "test_layout_table_auto_45"
93 "test_margin_boxes_element"
94 "test_running_elements"
95 "test_vertical_align_4"
96 "test_visibility_1"
97 "test_visibility_3"
98 "test_visibility_4"
99 "test_woff_simple"
100 # AssertionError
101 "test_2d_transform"
102 # Reported upstream: https://github.com/Kozea/WeasyPrint/issues/2666
103 "test_text_stroke"
104 ];
105
106 FONTCONFIG_FILE = "${fontconfig.out}/etc/fonts/fonts.conf";
107
108 # Set env variable explicitly for Darwin, but allow overriding when invoking directly
109 makeWrapperArgs = [ "--set-default FONTCONFIG_FILE ${finalAttrs.FONTCONFIG_FILE}" ];
110
111 pythonImportsCheck = [ "weasyprint" ];
112
113 meta = {
114 changelog = "https://github.com/Kozea/WeasyPrint/releases/tag/${finalAttrs.src.tag}";
115 description = "Converts web documents to PDF";
116 homepage = "https://weasyprint.org/";
117 license = lib.licenses.bsd3;
118 mainProgram = "weasyprint";
119 maintainers = with lib.maintainers; [
120 DutchGerman
121 friedow
122 ];
123 };
124})