about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/pyocr/default.nix
blob: 47a73c9c80af6d5b743f1dd66be25e99b2574c27 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{ lib, fetchFromGitLab, buildPythonPackage, pillow, six
, tesseract, cuneiform, isPy3k, substituteAll, pytest, tox
}:

buildPythonPackage rec {
  pname = "pyocr";
  version = "0.5.3";
  name = pname + "-" + version;
  disabled = !isPy3k;

  # Don't fetch from PYPI because it doesn't contain tests.
  src = fetchFromGitLab {
    domain = "gitlab.gnome.org";
    group = "World";
    owner = "OpenPaperwork";
    repo = "pyocr";
    rev = version;
    sha256 = "1nihf0qmbpg3yj3yp11jp6hp5z5dqf39nz6j9lqbvgi1nqbs7x15";
  };

  patches = [ (substituteAll {
    src = ./paths.patch;
    inherit cuneiform tesseract;
  })
  ];

  postPatch = ''
    echo 'version = "${version}"' > src/pyocr/_version.py

    # Disable specific tests that are probably failing because of this issue:
    # https://github.com/jflesch/pyocr/issues/52
    for test in $disabledTests; do
      file="''${test%%:*}"
      fun="''${test#*:}"
      echo "import pytest" >> "tests/tests_$file.py"
      echo "$fun = pytest.mark.skip($fun)" >> "tests/tests_$file.py"
    done
  '';

  disabledTests = [
    "cuneiform:TestTxt.test_basic"
    "cuneiform:TestTxt.test_european"
    "cuneiform:TestTxt.test_french"
    "cuneiform:TestWordBox.test_basic"
    "cuneiform:TestWordBox.test_european"
    "cuneiform:TestWordBox.test_french"
    "libtesseract:TestBasicDoc.test_basic"
    "libtesseract:TestDigitLineBox.test_digits"
    "libtesseract:TestLineBox.test_japanese"
    "libtesseract:TestTxt.test_japanese"
    "libtesseract:TestWordBox.test_japanese"
    "libtesseract:TestTxt.test_multi"
    "tesseract:TestTxt.test_multi"
    "tesseract:TestDigitLineBox.test_digits"
    "tesseract:TestTxt.test_japanese"
  ];

  propagatedBuildInputs = [ pillow six ];
  checkInputs = [ pytest tox ];
  checkPhase = "pytest";

  meta = {
    inherit (src.meta) homepage;
    description = "A Python wrapper for Tesseract and Cuneiform";
    license = lib.licenses.gpl3Plus;
  };
}