1{ buildPythonPackage
2, fetchPypi
3, lib
4
5# build dependencies
6, cython
7, leptonica
8, pkg-config
9, tesseract4
10
11# propagates
12, pillow
13
14# tests
15, unittestCheckHook
16}:
17
18buildPythonPackage rec {
19 pname = "tesserocr";
20 version = "2.6.2";
21
22 src = fetchPypi {
23 inherit pname version;
24 sha256 = "sha256-RVJfocGjVvnRVanekbN1nKRECEr9hTVE9aKaqFizA5A=";
25 };
26
27 # https://github.com/sirfz/tesserocr/issues/314
28 postPatch = ''
29 sed -i '/allheaders.h/a\ pass\n\ncdef extern from "leptonica/pix_internal.h" nogil:' tesseract.pxd
30 '';
31
32 nativeBuildInputs = [
33 cython
34 pkg-config
35 ];
36
37 buildInputs = [
38 leptonica
39 tesseract4
40 ];
41
42 propagatedBuildInputs = [
43 pillow
44 ];
45
46 pythonImportsCheck = [
47 "tesserocr"
48 ];
49
50 nativeCheckInputs = [
51 unittestCheckHook
52 ];
53
54 meta = with lib; {
55 changelog = "https://github.com/sirfz/tesserocr/releases/tag/v${version}";
56 description = "A simple, Pillow-friendly, wrapper around the tesseract-ocr API for Optical Character Recognition (OCR)";
57 homepage = "https://github.com/sirfz/tesserocr";
58 license = licenses.mit;
59 maintainers = with maintainers; [ mtrsk ];
60 platforms = platforms.linux;
61 };
62}