1{ lib
2, attrs
3, buildPythonPackage
4, fetchFromGitHub
5, hypothesis
6, pythonOlder
7, importlib-metadata
8, jbig2dec
9, deprecation
10, lxml
11, mupdf
12, packaging
13, pillow
14, psutil
15, pybind11
16, pytest-xdist
17, pytestCheckHook
18, python-dateutil
19, python-xmp-toolkit
20, qpdf
21, setuptools-scm
22, substituteAll
23}:
24
25buildPythonPackage rec {
26 pname = "pikepdf";
27 version = "6.2.4";
28 format = "setuptools";
29
30 disabled = pythonOlder "3.7";
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-YSzwcrWhqyKjdydwodf57S+HIGaKE124umJPtJKiM5g=";
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 SETUPTOOLS_SCM_PRETEND_VERSION = version;
59
60 buildInputs = [
61 pybind11
62 qpdf
63 ];
64
65 nativeBuildInputs = [
66 setuptools-scm
67 ];
68
69 checkInputs = [
70 attrs
71 hypothesis
72 pytest-xdist
73 psutil
74 pytestCheckHook
75 python-dateutil
76 python-xmp-toolkit
77 ];
78
79 propagatedBuildInputs = [
80 deprecation
81 lxml
82 packaging
83 pillow
84 ] ++ lib.optionals (pythonOlder "3.8") [
85 importlib-metadata
86 ];
87
88 pythonImportsCheck = [ "pikepdf" ];
89
90 meta = with lib; {
91 homepage = "https://github.com/pikepdf/pikepdf";
92 description = "Read and write PDFs with Python, powered by qpdf";
93 license = licenses.mpl20;
94 maintainers = with maintainers; [ kiwi dotlambda ];
95 changelog = "https://github.com/pikepdf/pikepdf/blob/${src.rev}/docs/releasenotes/version${lib.versions.major version}.rst";
96 };
97}