1{
2 lib,
3 arabic-reshaper,
4 buildPythonPackage,
5 fetchFromGitHub,
6 fetchpatch2,
7 html5lib,
8 pillow,
9 pyhanko,
10 pyhanko-certvalidator,
11 pypdf,
12 pytestCheckHook,
13 python-bidi,
14 pythonOlder,
15 pythonRelaxDepsHook,
16 reportlab,
17 setuptools,
18 svglib,
19}:
20
21buildPythonPackage rec {
22 pname = "xhtml2pdf";
23 version = "0.2.15";
24 pyproject = true;
25
26 disabled = pythonOlder "3.8";
27
28 src = fetchFromGitHub {
29 owner = "xhtml2pdf";
30 repo = "xhtml2pdf";
31 rev = "refs/tags/v${version}";
32 hash = "sha256-JXxh/n1kUsy3O4P/6WTfa5p+mYy/t4ZBUhlHp+ypoQc=";
33 };
34
35 patches = [
36 # https://github.com/xhtml2pdf/xhtml2pdf/pull/754
37 (fetchpatch2 {
38 name = "reportlab-compat.patch";
39 url = "https://github.com/xhtml2pdf/xhtml2pdf/commit/1252510bd23b833b45b4d252aeac62c1eb51eeef.patch";
40 hash = "sha256-9Fkn086uh2biabmiChbBna8Q4lJV/604yX1ng9j5TGs=";
41 })
42 ];
43
44 nativeBuildInputs = [
45 pythonRelaxDepsHook
46 setuptools
47 ];
48
49 pythonRelaxDeps = [ "reportlab" ];
50
51 propagatedBuildInputs = [
52 arabic-reshaper
53 html5lib
54 pillow
55 pyhanko
56 pyhanko-certvalidator
57 pypdf
58 python-bidi
59 reportlab
60 svglib
61 ];
62
63 nativeCheckInputs = [ pytestCheckHook ];
64
65 disabledTests = [
66 # Tests requires network access
67 "test_document_cannot_identify_image"
68 "test_document_with_broken_image"
69 ];
70
71 pythonImportsCheck = [
72 "xhtml2pdf"
73 "xhtml2pdf.pisa"
74 ];
75
76 meta = with lib; {
77 description = "A PDF generator using HTML and CSS";
78 homepage = "https://github.com/xhtml2pdf/xhtml2pdf";
79 changelog = "https://github.com/xhtml2pdf/xhtml2pdf/releases/tag/v${version}";
80 license = licenses.asl20;
81 maintainers = with maintainers; [ ];
82 mainProgram = "xhtml2pdf";
83 };
84}