nixpkgs/pkgs/applications/misc/ocropus/default.nix

60 lines
1.5 KiB
Nix
Raw Normal View History

2015-04-16 03:34:35 +02:00
{ stdenv, fetchFromGitHub, fetchurl, pythonPackages, curl }:
let
getmodel = name: sha256: {
inherit name;
src = fetchurl {
2015-04-16 03:34:35 +02:00
url = "http://www.tmbdev.net/ocropy/${name}";
inherit sha256;
};
};
models = [
(getmodel "en-default.pyrnn.gz"
"1xyi3k3p81mfw0491gb1haisazfyi2i18f1wjs1m34ak39qfqjdp")
(getmodel "fraktur.pyrnn.gz"
"1wlwvxn91ilgmlri1hj81arl3mbzxc24ycdnkf5icq4hdi4c6y8b")
];
2015-04-16 03:34:35 +02:00
in
pythonPackages.buildPythonApplication rec {
2019-02-11 00:06:54 +01:00
pname = "ocropus";
version = "1.3.3";
2015-04-16 03:34:35 +02:00
src = fetchFromGitHub {
2019-02-11 00:06:54 +01:00
sha256 = "02p1334mic5cfhvpfphfrbim4036yfd8s2zzpwm0xmm829z71nr7";
rev = "v${version}";
2015-04-16 03:34:35 +02:00
repo = "ocropy";
owner = "tmbdev";
};
propagatedBuildInputs = with pythonPackages; [ curl numpy scipy pillow
matplotlib beautifulsoup4 pygtk lxml ];
enableParallelBuilding = true;
preConfigure = with stdenv.lib; ''
${concatStrings (map (x: "cp -R ${x.src} models/`basename ${x.name}`;")
2015-04-16 03:34:35 +02:00
models)}
2017-09-06 13:45:49 +02:00
substituteInPlace ocrolib/common.py --replace /usr/local $out
substituteInPlace ocrolib/default.py --replace /usr/local $out
2015-04-16 03:34:35 +02:00
'';
doCheck = false; # fails
2015-04-16 03:34:35 +02:00
checkPhase = ''
patchShebangs .
2015-04-16 03:34:35 +02:00
substituteInPlace ./run-test \
--replace 'ocropus-rpred' 'ocropus-rpred -Q $NIX_BUILD_CORES'
PATH=".:$PATH" ./run-test
'';
meta = with stdenv.lib; {
description = "Open source document analysis and OCR system";
license = licenses.asl20;
2015-04-16 03:34:35 +02:00
homepage = https://github.com/tmbdev/ocropy/;
maintainers = with maintainers; [ domenkozar ];
platforms = platforms.linux;
};
}