summaryrefslogtreecommitdiffstats
path: root/pkgs/development/python-modules/camelot/default.nix
blob: 1f95916baff008fa7c95a95201caa6fb160492b5 (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
85
86
87
88
89
90
91
92
93
{
  lib,
  pkgs,
  fetchFromGitHub,
  buildPythonPackage,

  # build system
  setuptools,

  # dependencies
  chardet,
  click,
  numpy,
  opencv-python-headless,
  openpyxl,
  pandas,
  pdfminer-six,
  pillow,
  pypdf,
  pypdfium2,
  tabulate,

  # tests
  pytestCheckHook,
  matplotlib,
}:
buildPythonPackage (finalAttrs: {
  pname = "camelot-py";
  version = "1.0.9";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "camelot-dev";
    repo = "camelot";
    tag = "v${finalAttrs.version}";
    sha256 = "sha256-msf49Vt0IlwUNTvLIqTWKlMfcFB0LnvGGf7vReqhJec=";
  };

  patches = [ ./ghostscript.patch ];

  postPatch = ''
    substituteInPlace camelot/backends/ghostscript_backend.py \
      --replace-fail '@ghostscript@' ${lib.getExe pkgs.ghostscript_headless}
  '';

  pythonRelaxDeps = [ "pypdf" ];

  build-system = [ setuptools ];

  dependencies = [
    click
    numpy
    opencv-python-headless
    openpyxl
    pandas
    pdfminer-six
    pillow
    pypdf
    pypdfium2
    tabulate
    # Dependency not present in project's pyproject.toml, but doesn't build without it
    chardet
  ];

  nativeCheckInputs = [
    pytestCheckHook
    matplotlib
  ];
  disabledTests = [
    # Assertion Error: <Cell cords> != <Cell other_cords>
    "test_repr_ghostscript"
    # cv2.error: color.cpp failure
    "test_repr_ghostscript_custom_backend"
    # urllib.error.URLError: temporary failure in name
    "test_url_pdfium"
    "test_url_ghostscript"
    "test_url_ghost_script_custom_backend"
    "test_pages_pdfium"
    "test_pages_ghostscript"
    "test_pages_ghostscript_custom_backend"
  ];

  pythonImportsCheck = [ "camelot" ];

  meta = {
    description = "Python library to extract tabular data from PDFs";
    mainProgram = "camelot";
    homepage = "http://camelot-py.readthedocs.io";
    changelog = "https://github.com/camelot-dev/camelot/blob/${finalAttrs.src.tag}/HISTORY.md";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ _2gn ];
  };
})