python/pyocr: Move package into python-modules

We already have a patch feeling lonely inside the python-modules
directory and to have everything at one place let's actually move pyocr
into its own dedicated directory so it's easier to patch it up (which
we're going to).

Right now, the package fails to build because of a few test failures, so
I haven't tested this apart from evaluating.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig
2017-09-02 03:43:21 +02:00
parent 40b76c8809
commit 3086fc7f83
3 changed files with 65 additions and 60 deletions

View File

@@ -0,0 +1,64 @@
{ lib, fetchFromGitHub, buildPythonPackage, pillow, six
, tesseract, cuneiform
}:
buildPythonPackage rec {
name = "pyocr-${version}";
version = "0.4.6";
# Don't fetch from PYPI because it doesn't contain tests.
src = fetchFromGitHub {
owner = "jflesch";
repo = "pyocr";
rev = version;
sha256 = "0amyhkkm400qzbw65ivyzrzxl2r7vxqgsgqm7ml95m7gwkwhnzz0";
};
patches = [ ./tesseract.patch ];
postPatch = ''
sed -i \
-e 's,^\(TESSERACT_CMD *= *\).*,\1"${tesseract}/bin/tesseract",' \
-e 's,^\(CUNEIFORM_CMD *= *\).*,\1"${cuneiform}/bin/cuneiform",' \
-e '/^CUNIFORM_POSSIBLE_PATHS *= *\[/,/^\]$/ {
c CUNIFORM_POSSIBLE_PATHS = ["${cuneiform}/share/cuneiform"]
}' src/pyocr/{tesseract,cuneiform}.py
sed -i -r \
-e 's,"libtesseract\.so\.3","${tesseract}/lib/libtesseract.so",' \
-e 's,^(TESSDATA_PREFIX *=).*,\1 "${tesseract}/share/tessdata",' \
src/pyocr/libtesseract/tesseract_raw.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 "$fun = unittest.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"
"tesseract:TestDigitLineBox.test_digits"
"tesseract:TestTxt.test_japanese"
];
propagatedBuildInputs = [ pillow six ];
meta = {
homepage = "https://github.com/jflesch/pyocr";
description = "A Python wrapper for Tesseract and Cuneiform";
license = lib.licenses.gpl3Plus;
};
}