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