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