mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
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:
parent
40b76c8809
commit
3086fc7f83
3 changed files with 65 additions and 60 deletions
64
pkgs/development/python-modules/pyocr/default.nix
Normal file
64
pkgs/development/python-modules/pyocr/default.nix
Normal 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;
|
||||
};
|
||||
}
|
|
@ -18113,66 +18113,7 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
pyocr = buildPythonPackage rec {
|
||||
name = "pyocr-${version}";
|
||||
version = "0.4.6";
|
||||
|
||||
# Don't fetch from PYPI because it doesn't contain tests.
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "jflesch";
|
||||
repo = "pyocr";
|
||||
rev = version;
|
||||
sha256 = "0amyhkkm400qzbw65ivyzrzxl2r7vxqgsgqm7ml95m7gwkwhnzz0";
|
||||
};
|
||||
|
||||
patches = [ ../development/python-modules/pyocr-tesseract.patch ];
|
||||
|
||||
postPatch = ''
|
||||
sed -i \
|
||||
-e 's,^\(TESSERACT_CMD *= *\).*,\1"${pkgs.tesseract}/bin/tesseract",' \
|
||||
-e 's,^\(CUNEIFORM_CMD *= *\).*,\1"${pkgs.cuneiform}/bin/cuneiform",' \
|
||||
-e '/^CUNIFORM_POSSIBLE_PATHS *= *\[/,/^\]$/ {
|
||||
c CUNIFORM_POSSIBLE_PATHS = ["${pkgs.cuneiform}/share/cuneiform"]
|
||||
}' src/pyocr/{tesseract,cuneiform}.py
|
||||
|
||||
sed -i -r \
|
||||
-e 's,"libtesseract\.so\.3","${pkgs.tesseract}/lib/libtesseract.so",' \
|
||||
-e 's,^(TESSDATA_PREFIX *=).*,\1 "${pkgs.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 = [ self.pillow self.six ];
|
||||
|
||||
meta = {
|
||||
homepage = "https://github.com/jflesch/pyocr";
|
||||
description = "A Python wrapper for Tesseract and Cuneiform";
|
||||
license = licenses.gpl3Plus;
|
||||
};
|
||||
};
|
||||
pyocr = callPackage ../development/python-modules/pyocr { };
|
||||
|
||||
pyparsing = callPackage ../development/python-modules/pyparsing { };
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue