nixpkgs/pkgs/development/python-modules/pyocr/default.nix

68 lines
1.9 KiB
Nix
Raw Normal View History

2018-09-10 16:27:56 +01:00
{ lib, fetchFromGitLab, buildPythonPackage, pillow, six
, tesseract, cuneiform, isPy3k, substituteAll, pytest, tox
}:
buildPythonPackage rec {
pname = "pyocr";
2018-09-10 16:27:56 +01:00
version = "0.5.3";
name = pname + "-" + version;
disabled = !isPy3k;
# Don't fetch from PYPI because it doesn't contain tests.
2018-09-10 16:27:56 +01:00
src = fetchFromGitLab {
domain = "gitlab.gnome.org";
group = "World";
owner = "OpenPaperwork";
repo = "pyocr";
rev = version;
2018-09-10 16:27:56 +01:00
sha256 = "1nihf0qmbpg3yj3yp11jp6hp5z5dqf39nz6j9lqbvgi1nqbs7x15";
};
2018-09-10 16:27:56 +01:00
patches = [ (substituteAll {
src = ./paths.patch;
inherit cuneiform tesseract;
})
];
postPatch = ''
2018-09-10 16:27:56 +01:00
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#*:}"
2018-09-10 16:27:56 +01:00
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"
2018-09-10 16:27:56 +01:00
"libtesseract:TestTxt.test_multi"
"tesseract:TestTxt.test_multi"
"tesseract:TestDigitLineBox.test_digits"
"tesseract:TestTxt.test_japanese"
];
propagatedBuildInputs = [ pillow six ];
2018-09-10 16:27:56 +01:00
checkInputs = [ pytest tox ];
checkPhase = "pytest";
meta = {
inherit (src.meta) homepage;
description = "A Python wrapper for Tesseract and Cuneiform";
license = lib.licenses.gpl3Plus;
};
}