summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/easyocr/default.nix
blob: 604213314d258cc2d337c1643e1ba013e28fa16a (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  setuptools,
  hdf5,
  numpy,
  opencv-python-headless,
  pillow,
  pyaml,
  pyclipper,
  python-bidi,
  scikit-image,
  scipy,
  shapely,
  torch,
  torchvision,
  python,
}:

buildPythonPackage rec {
  pname = "easyocr";
  version = "1.7.2";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "JaidedAI";
    repo = "EasyOCR";
    tag = "v${version}";
    hash = "sha256-9mrAxt2lphYtLW81lGO5SYHsnMnSA/VpHiY2NffD/Js=";
  };

  build-system = [
    setuptools
  ];

  pythonRelaxDeps = [
    "torchvision"
  ];

  pythonRemoveDeps = [
    "ninja"
  ];

  dependencies = [
    hdf5
    numpy
    opencv-python-headless
    pillow
    pyaml
    pyclipper
    python-bidi
    scikit-image
    scipy
    shapely
    torch
    torchvision
  ];

  checkPhase = ''
    runHook preCheck

    export HOME="$(mktemp -d)"
    pushd unit_test
    ${python.interpreter} run_unit_test.py --easyocr "$out/${python.sitePackages}/easyocr"
    popd

    runHook postCheck
  '';

  # downloads detection model from the internet
  doCheck = false;

  pythonImportsCheck = [ "easyocr" ];

  meta = {
    description = "Ready-to-use OCR with 80+ supported languages and all popular writing scripts";
    mainProgram = "easyocr";
    homepage = "https://github.com/JaidedAI/EasyOCR";
    changelog = "https://github.com/JaidedAI/EasyOCR/releases/tag/v${version}";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ dit7ya ];
  };
}