depot/third_party/nixpkgs/pkgs/development/python-modules/tesserocr/default.nix
Default email f34ce41345 Project import generated by Copybara.
GitOrigin-RevId: b73c2221a46c13557b1b3be9c2070cc42cf01eb3
2024-07-27 08:49:29 +02:00

66 lines
1.3 KiB
Nix

{
buildPythonPackage,
fetchPypi,
lib,
# build-system
cython,
pkg-config,
setuptools,
# native dependencies
leptonica,
tesseract4,
# dependencies
pillow,
# tests
unittestCheckHook,
}:
buildPythonPackage rec {
pname = "tesserocr";
version = "2.7.0";
format = "setuptools";
src = fetchPypi {
inherit pname version;
hash = "sha256-RcCTYwM30Bpqj5d6JGrW1zLrEfLgcrsibVmtPSR4HJk=";
};
# https://github.com/sirfz/tesserocr/issues/314
postPatch = ''
sed -i '/allheaders.h/a\ pass\n\ncdef extern from "leptonica/pix_internal.h" nogil:' tesserocr/tesseract.pxd
'';
build-system = [
cython
pkg-config
setuptools
];
buildInputs = [
leptonica
tesseract4
];
dependencies = [ pillow ];
pythonImportsCheck = [ "tesserocr" ];
nativeCheckInputs = [ unittestCheckHook ];
preCheck = ''
rm -rf tesserocr
'';
meta = with lib; {
changelog = "https://github.com/sirfz/tesserocr/releases/tag/v${version}";
description = "Simple, Pillow-friendly, wrapper around the tesseract-ocr API for Optical Character Recognition (OCR)";
homepage = "https://github.com/sirfz/tesserocr";
license = licenses.mit;
maintainers = with maintainers; [ mtrsk ];
platforms = platforms.linux;
};
}