1{ lib
2, buildPythonPackage
3, deprecation
4, fetchFromGitHub
5, ghostscript
6, hypothesis
7, img2pdf
8, importlib-resources
9, jbig2enc
10, packaging
11, pdfminer-six
12, pikepdf
13, pillow
14, pluggy
15, pngquant
16, pytest-xdist
17, pytestCheckHook
18, pythonOlder
19, rich
20, reportlab
21, setuptools
22, setuptools-scm
23, substituteAll
24, tesseract
25, tqdm
26, typing-extensions
27, unpaper
28, wheel
29, installShellFiles
30}:
31
32buildPythonPackage rec {
33 pname = "ocrmypdf";
34 version = "15.4.0";
35
36 disabled = pythonOlder "3.9";
37
38 format = "pyproject";
39
40 src = fetchFromGitHub {
41 owner = "ocrmypdf";
42 repo = "OCRmyPDF";
43 rev = "v${version}";
44 # The content of .git_archival.txt is substituted upon tarball creation,
45 # which creates indeterminism if master no longer points to the tag.
46 # See https://github.com/ocrmypdf/OCRmyPDF/issues/841
47 postFetch = ''
48 rm "$out/.git_archival.txt"
49 '';
50 hash = "sha256-cbKqisaRAeT8ljANbYiUDrptAoQmmIkMu1ya8O6nXvQ=";
51 };
52
53 SETUPTOOLS_SCM_PRETEND_VERSION = version;
54
55 patches = [
56 (substituteAll {
57 src = ./paths.patch;
58 gs = lib.getExe ghostscript;
59 jbig2 = lib.getExe jbig2enc;
60 pngquant = lib.getExe pngquant;
61 tesseract = lib.getExe tesseract;
62 unpaper = lib.getExe unpaper;
63 })
64 ];
65
66 nativeBuildInputs = [
67 setuptools
68 setuptools-scm
69 wheel
70 installShellFiles
71 ];
72
73 propagatedBuildInputs = [
74 deprecation
75 img2pdf
76 packaging
77 pdfminer-six
78 pikepdf
79 pillow
80 pluggy
81 reportlab
82 rich
83 ] ++ lib.optionals (pythonOlder "3.10") [
84 typing-extensions
85 ];
86
87 nativeCheckInputs = [
88 hypothesis
89 pytest-xdist
90 pytestCheckHook
91 ];
92
93 pythonImportsCheck = [
94 "ocrmypdf"
95 ];
96
97 postInstall = ''
98 installShellCompletion --cmd ocrmypdf \
99 --bash misc/completion/ocrmypdf.bash \
100 --fish misc/completion/ocrmypdf.fish
101 '';
102
103 meta = with lib; {
104 homepage = "https://github.com/ocrmypdf/OCRmyPDF";
105 description = "Adds an OCR text layer to scanned PDF files, allowing them to be searched";
106 license = with licenses; [ mpl20 mit ];
107 maintainers = with maintainers; [ kiwi dotlambda ];
108 changelog = "https://github.com/ocrmypdf/OCRmyPDF/blob/${src.rev}/docs/release_notes.rst";
109 };
110}