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