1{
2 lib,
3 stdenv,
4 fetchFromGitLab,
5 buildPythonPackage,
6 pillow,
7 tesseract,
8 cuneiform,
9 isPy3k,
10 replaceVars,
11 pytestCheckHook,
12 setuptools,
13 setuptools-scm,
14 withTesseractSupport ? true,
15 withCuneiformSupport ? stdenv.hostPlatform.isLinux,
16}:
17
18buildPythonPackage rec {
19 pname = "pyocr";
20 version = "0.8.5";
21 disabled = !isPy3k;
22 format = "pyproject";
23
24 # Don't fetch from PYPI because it doesn't contain tests.
25 src = fetchFromGitLab {
26 domain = "gitlab.gnome.org";
27 group = "World";
28 owner = "OpenPaperwork";
29 repo = "pyocr";
30 rev = version;
31 hash = "sha256-gE0+qbHCwpDdxXFY+4rjVU2FbUSfSVrvrVMcWUk+9FU=";
32 };
33
34 patches =
35 [ ]
36 ++ (lib.optional withTesseractSupport (
37 replaceVars ./paths-tesseract.patch {
38 inherit tesseract;
39 tesseractLibraryLocation = "${tesseract}/lib/libtesseract${stdenv.hostPlatform.extensions.sharedLibrary}";
40 }
41 ))
42 ++ (lib.optional stdenv.hostPlatform.isLinux (
43 replaceVars ./paths-cuneiform.patch {
44 inherit cuneiform;
45 }
46 ));
47
48 propagatedBuildInputs = [ pillow ];
49
50 nativeBuildInputs = [
51 setuptools
52 setuptools-scm
53 ];
54
55 nativeCheckInputs = [ pytestCheckHook ];
56
57 meta = with lib; {
58 inherit (src.meta) homepage;
59 changelog = "https://gitlab.gnome.org/World/OpenPaperwork/pyocr/-/blob/${version}/ChangeLog";
60 description = "Python wrapper for Tesseract and Cuneiform";
61 license = licenses.gpl3Plus;
62 maintainers = with maintainers; [
63 symphorien
64 tomodachi94
65 ];
66 };
67}