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