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