1{
2 lib,
3 attrs,
4 buildPythonPackage,
5 fetchFromGitHub,
6 hypothesis,
7 pythonOlder,
8 jbig2dec,
9 deprecated,
10 lxml,
11 mupdf-headless,
12 numpy,
13 packaging,
14 pillow,
15 psutil,
16 pybind11,
17 pytest-xdist,
18 pytestCheckHook,
19 python-dateutil,
20 python-xmp-toolkit,
21 qpdf,
22 setuptools,
23 replaceVars,
24}:
25
26buildPythonPackage rec {
27 pname = "pikepdf";
28 version = "9.8.1";
29 pyproject = true;
30
31 src = fetchFromGitHub {
32 owner = "pikepdf";
33 repo = "pikepdf";
34 tag = "v${version}";
35 # The content of .git_archival.txt is substituted upon tarball creation,
36 # which creates indeterminism if master no longer points to the tag.
37 # See https://github.com/jbarlow83/OCRmyPDF/issues/841
38 postFetch = ''
39 rm "$out/.git_archival.txt"
40 '';
41 hash = "sha256-gFaGHml1F5i+w68xapmPHYUK760rT4GJzTWTkDsIwC8=";
42 };
43
44 patches = [
45 (replaceVars ./paths.patch {
46 jbig2dec = lib.getExe' jbig2dec "jbig2dec";
47 mutool = lib.getExe' mupdf-headless "mutool";
48 })
49 ];
50
51 postPatch = ''
52 substituteInPlace setup.py \
53 --replace-fail "shims_enabled = not cflags_defined" "shims_enabled = False"
54 '';
55
56 buildInputs = [ qpdf ];
57
58 build-system = [
59 pybind11
60 setuptools
61 ];
62
63 nativeCheckInputs = [
64 attrs
65 hypothesis
66 numpy
67 pytest-xdist
68 psutil
69 pytestCheckHook
70 python-dateutil
71 python-xmp-toolkit
72 ];
73
74 dependencies = [
75 deprecated
76 lxml
77 packaging
78 pillow
79 ];
80
81 pythonImportsCheck = [ "pikepdf" ];
82
83 meta = with lib; {
84 homepage = "https://github.com/pikepdf/pikepdf";
85 description = "Read and write PDFs with Python, powered by qpdf";
86 license = licenses.mpl20;
87 maintainers = with maintainers; [ dotlambda ];
88 changelog = "https://github.com/pikepdf/pikepdf/blob/${src.tag}/docs/releasenotes/version${lib.versions.major version}.md";
89 };
90}