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