2021-09-22 15:38:15 +00:00
|
|
|
{ lib
|
|
|
|
, buildPythonPackage
|
|
|
|
, coloredlogs
|
2022-11-21 17:40:18 +00:00
|
|
|
, deprecation
|
2021-09-22 15:38:15 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, ghostscript
|
2023-05-24 13:37:59 +00:00
|
|
|
, hypothesis
|
2021-09-22 15:38:15 +00:00
|
|
|
, img2pdf
|
|
|
|
, importlib-resources
|
|
|
|
, jbig2enc
|
2022-11-21 17:40:18 +00:00
|
|
|
, packaging
|
2022-06-16 17:23:12 +00:00
|
|
|
, pdfminer-six
|
2021-09-22 15:38:15 +00:00
|
|
|
, pikepdf
|
|
|
|
, pillow
|
|
|
|
, pluggy
|
|
|
|
, pngquant
|
|
|
|
, pytest-xdist
|
|
|
|
, pytestCheckHook
|
2021-12-06 16:07:01 +00:00
|
|
|
, pythonOlder
|
2021-09-22 15:38:15 +00:00
|
|
|
, reportlab
|
2022-11-21 17:40:18 +00:00
|
|
|
, setuptools
|
2021-09-22 15:38:15 +00:00
|
|
|
, setuptools-scm
|
|
|
|
, substituteAll
|
2022-09-30 11:47:45 +00:00
|
|
|
, tesseract
|
2021-09-22 15:38:15 +00:00
|
|
|
, tqdm
|
2022-11-21 17:40:18 +00:00
|
|
|
, typing-extensions
|
2021-09-22 15:38:15 +00:00
|
|
|
, unpaper
|
2022-06-16 17:23:12 +00:00
|
|
|
, installShellFiles
|
2021-09-22 15:38:15 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "ocrmypdf";
|
2023-07-15 17:15:38 +00:00
|
|
|
version = "14.3.0";
|
2022-11-21 17:40:18 +00:00
|
|
|
|
|
|
|
disabled = pythonOlder "3.8";
|
|
|
|
|
|
|
|
format = "pyproject";
|
2021-09-22 15:38:15 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2022-06-16 17:23:12 +00:00
|
|
|
owner = "ocrmypdf";
|
2021-09-22 15:38:15 +00:00
|
|
|
repo = "OCRmyPDF";
|
|
|
|
rev = "v${version}";
|
2021-10-07 14:46:35 +00:00
|
|
|
# The content of .git_archival.txt is substituted upon tarball creation,
|
|
|
|
# which creates indeterminism if master no longer points to the tag.
|
2022-06-16 17:23:12 +00:00
|
|
|
# See https://github.com/ocrmypdf/OCRmyPDF/issues/841
|
|
|
|
postFetch = ''
|
2021-10-07 14:46:35 +00:00
|
|
|
rm "$out/.git_archival.txt"
|
|
|
|
'';
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = "sha256-OUz19N2YIl7iwayjulx0v1K00jB5SdWo8m5XiJ9BDSs=";
|
2021-09-22 15:38:15 +00:00
|
|
|
};
|
|
|
|
|
2021-10-04 12:37:57 +00:00
|
|
|
SETUPTOOLS_SCM_PRETEND_VERSION = version;
|
|
|
|
|
2021-09-22 15:38:15 +00:00
|
|
|
patches = [
|
|
|
|
(substituteAll {
|
|
|
|
src = ./paths.patch;
|
|
|
|
gs = "${lib.getBin ghostscript}/bin/gs";
|
|
|
|
jbig2 = "${lib.getBin jbig2enc}/bin/jbig2";
|
|
|
|
pngquant = "${lib.getBin pngquant}/bin/pngquant";
|
2022-09-30 11:47:45 +00:00
|
|
|
tesseract = "${lib.getBin tesseract}/bin/tesseract";
|
2021-09-22 15:38:15 +00:00
|
|
|
unpaper = "${lib.getBin unpaper}/bin/unpaper";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2022-11-21 17:40:18 +00:00
|
|
|
setuptools
|
2021-09-22 15:38:15 +00:00
|
|
|
setuptools-scm
|
2022-06-16 17:23:12 +00:00
|
|
|
installShellFiles
|
2021-09-22 15:38:15 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
coloredlogs
|
2022-11-21 17:40:18 +00:00
|
|
|
deprecation
|
2021-09-22 15:38:15 +00:00
|
|
|
img2pdf
|
2022-11-21 17:40:18 +00:00
|
|
|
packaging
|
2022-06-16 17:23:12 +00:00
|
|
|
pdfminer-six
|
2021-09-22 15:38:15 +00:00
|
|
|
pikepdf
|
|
|
|
pillow
|
|
|
|
pluggy
|
|
|
|
reportlab
|
|
|
|
tqdm
|
2022-11-21 17:40:18 +00:00
|
|
|
] ++ lib.optionals (pythonOlder "3.9") [
|
2021-12-06 16:07:01 +00:00
|
|
|
importlib-resources
|
2022-11-21 17:40:18 +00:00
|
|
|
] ++ lib.optionals (pythonOlder "3.10") [
|
|
|
|
typing-extensions
|
|
|
|
];
|
2021-09-22 15:38:15 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2023-05-24 13:37:59 +00:00
|
|
|
hypothesis
|
2021-09-22 15:38:15 +00:00
|
|
|
pytest-xdist
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
|
|
|
|
2021-10-04 12:37:57 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"ocrmypdf"
|
|
|
|
];
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
postInstall = ''
|
|
|
|
installShellCompletion --cmd ocrmypdf \
|
|
|
|
--bash misc/completion/ocrmypdf.bash \
|
|
|
|
--fish misc/completion/ocrmypdf.fish
|
|
|
|
'';
|
|
|
|
|
2021-09-22 15:38:15 +00:00
|
|
|
meta = with lib; {
|
2022-06-16 17:23:12 +00:00
|
|
|
homepage = "https://github.com/ocrmypdf/OCRmyPDF";
|
2021-09-22 15:38:15 +00:00
|
|
|
description = "Adds an OCR text layer to scanned PDF files, allowing them to be searched";
|
|
|
|
license = with licenses; [ mpl20 mit ];
|
|
|
|
maintainers = with maintainers; [ kiwi dotlambda ];
|
2022-06-16 17:23:12 +00:00
|
|
|
changelog = "https://github.com/ocrmypdf/OCRmyPDF/blob/${src.rev}/docs/release_notes.rst";
|
2021-09-22 15:38:15 +00:00
|
|
|
};
|
|
|
|
}
|