2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchPypi,
|
|
|
|
lib,
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
# build-system
|
2024-06-05 15:53:02 +00:00
|
|
|
cython,
|
|
|
|
pkg-config,
|
2024-07-27 06:49:29 +00:00
|
|
|
setuptools,
|
|
|
|
|
|
|
|
# native dependencies
|
|
|
|
leptonica,
|
2024-06-05 15:53:02 +00:00
|
|
|
tesseract4,
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
# dependencies
|
2024-06-05 15:53:02 +00:00
|
|
|
pillow,
|
|
|
|
|
|
|
|
# tests
|
|
|
|
unittestCheckHook,
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "tesserocr";
|
2024-09-19 14:19:46 +00:00
|
|
|
version = "2.7.1";
|
2024-01-02 11:29:13 +00:00
|
|
|
format = "setuptools";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2024-09-19 14:19:46 +00:00
|
|
|
hash = "sha256-N0TFyLur8YFyhJx3Mb4A3C5eRPjFVtN8hQ54h5SuCvQ=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
# https://github.com/sirfz/tesserocr/issues/314
|
|
|
|
postPatch = ''
|
2024-07-27 06:49:29 +00:00
|
|
|
sed -i '/allheaders.h/a\ pass\n\ncdef extern from "leptonica/pix_internal.h" nogil:' tesserocr/tesseract.pxd
|
2023-02-16 17:41:37 +00:00
|
|
|
'';
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
build-system = [
|
2022-09-30 11:47:45 +00:00
|
|
|
cython
|
|
|
|
pkg-config
|
2024-07-27 06:49:29 +00:00
|
|
|
setuptools
|
2022-09-30 11:47:45 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
leptonica
|
2023-03-04 12:14:45 +00:00
|
|
|
tesseract4
|
2022-09-30 11:47:45 +00:00
|
|
|
];
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
dependencies = [ pillow ];
|
2022-09-30 11:47:45 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
pythonImportsCheck = [ "tesserocr" ];
|
2022-09-30 11:47:45 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
nativeCheckInputs = [ unittestCheckHook ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
preCheck = ''
|
|
|
|
rm -rf tesserocr
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
2022-09-30 11:47:45 +00:00
|
|
|
changelog = "https://github.com/sirfz/tesserocr/releases/tag/v${version}";
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Simple, Pillow-friendly, wrapper around the tesseract-ocr API for Optical Character Recognition (OCR)";
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://github.com/sirfz/tesserocr";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ mtrsk ];
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|