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