nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, attrs
3, buildPythonPackage
4, defusedxml
5, fetchFromGitHub
6, hypothesis
7, pythonOlder
8, jbig2dec
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, setuptools-scm
22, setuptools-scm-git-archive
23, substituteAll
24}:
25
26buildPythonPackage rec {
27 pname = "pikepdf";
28 version = "5.1.3";
29 format = "setuptools";
30
31 disabled = pythonOlder "3.7";
32
33 src = fetchFromGitHub {
34 owner = "pikepdf";
35 repo = "pikepdf";
36 rev = "v${version}";
37 # The content of .git_archival.txt is substituted upon tarball creation,
38 # which creates indeterminism if master no longer points to the tag.
39 # See https://github.com/jbarlow83/OCRmyPDF/issues/841
40 postFetch = ''
41 rm "$out/.git_archival.txt"
42 '';
43 hash = "sha256-jkAwc1bQ1jRDf/qY+xAjiLXXO98qKjyX+J7Lu4tYWoI=";
44 };
45
46 patches = [
47 (substituteAll {
48 src = ./paths.patch;
49 jbig2dec = "${lib.getBin jbig2dec}/bin/jbig2dec";
50 mudraw = "${lib.getBin mupdf}/bin/mudraw";
51 })
52 ];
53
54 postPatch = ''
55 sed -i 's|\S*/opt/homebrew.*|pass|' setup.py
56 '';
57
58 SETUPTOOLS_SCM_PRETEND_VERSION = version;
59
60 buildInputs = [
61 pybind11
62 qpdf
63 ];
64
65 nativeBuildInputs = [
66 setuptools-scm-git-archive
67 setuptools-scm
68 ];
69
70 checkInputs = [
71 attrs
72 hypothesis
73 pytest-xdist
74 psutil
75 pytestCheckHook
76 python-dateutil
77 python-xmp-toolkit
78 ];
79
80 propagatedBuildInputs = [
81 defusedxml
82 lxml
83 packaging
84 pillow
85 setuptools
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/${version}/docs/release_notes.rst";
96 };
97}