summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/arelle/default.nix
blob: 8be34e9c8af6078d94025447cb7ca83605d4ba05 (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,

  setuptools,
  setuptools-scm,

  bottle,
  certifi,
  filelock,
  isodate,
  jaconv,
  jsonschema,
  lxml,
  numpy,
  openpyxl,
  pillow,
  pyparsing,
  python-dateutil,
  regex,
  truststore,
  typing-extensions,

  gui ? true,
  tkinter,

  aniso8601,
  cheroot,
  graphviz,
  holidays,
  matplotlib,
  pg8000,
  pycryptodome,
  pymysql,
  pyodbc,
  pytz,
  rdflib,
  tinycss2,
  tornado,

  sphinxHook,
  sphinx-autodoc2,
  myst-parser,
  sphinx-copybutton,
  furo,

  writableTmpDirAsHomeHook,
  pytestCheckHook,
  boto3,
}:

buildPythonPackage (finalAttrs: {
  pname = "arelle${lib.optionalString (!gui) "-headless"}";
  version = "2.38.4";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "Arelle";
    repo = "Arelle";
    tag = finalAttrs.version;
    hash = "sha256-ngFhY6yngr2OVQ6gsdpk5UAhzIpIrwiw+S+HK3oqfec=";
  };

  outputs = [
    "out"
    "doc"
  ];

  postPatch = ''
    substituteInPlace pyproject.toml --replace-fail \
        'requires = ["setuptools>=80.9,<81", "wheel>=0.45,<1", "setuptools_scm[toml]>=9.2,<10"]' \
        'requires = ["setuptools", "wheel", "setuptools_scm[toml]"]'
  '';

  pythonRelaxDeps = [
    "pillow" # pillow's current version is above what arelle officially supports, but it should be fine
  ];

  build-system = [
    setuptools
    setuptools-scm
  ];

  dependencies = [
    bottle
    certifi
    filelock
    isodate
    jaconv
    jsonschema
    lxml
    numpy
    openpyxl
    pillow
    pyparsing
    python-dateutil
    regex
    truststore
    typing-extensions
  ]
  ++ lib.optionals gui [ tkinter ];

  optional-dependencies = {
    crypto = [ pycryptodome ];
    db = [
      # cx-oracle # Unfree
      pg8000
      pymysql
      pyodbc
      rdflib
    ];
    efm = [
      aniso8601
      holidays
      matplotlib
      pytz
    ];
    esef = [ tinycss2 ];
    objectmaker = [ graphviz ];
    # viewer = [ ixbrl-viewer ]; # Not yet packaged
    webserver = [
      cheroot
      tornado
    ];
    xule = [ aniso8601 ];
  };

  nativeBuildInputs = [
    # deps for docs
    sphinxHook
    sphinx-autodoc2
    myst-parser
    sphinx-copybutton
    furo
  ];

  # the arelleGUI executable doesn't work when the gui option is false
  postInstall = lib.optionalString (!gui) ''
    find $out/bin -name "*arelleGUI*" -delete
  '';

  nativeCheckInputs = [
    writableTmpDirAsHomeHook
    pytestCheckHook
    boto3
  ]
  ++ lib.concatAttrValues finalAttrs.passthru.optional-dependencies;

  disabledTestPaths = [
    "tests/integration_tests"
  ]
  ++ lib.optionals (!gui) [
    # these tests import tkinter
    "tests/unit_tests/arelle/test_updater.py"
    "tests/unit_tests/arelle/test_import.py"
  ];

  meta = {
    description = "Open source XBRL platform";
    longDescription = ''
      An open source facility for XBRL, the eXtensible Business Reporting
      Language supporting various standards, exposed through a Python or
      REST API ${lib.optionalString gui " and a graphical user interface"}.
    '';
    mainProgram = "arelle";
    homepage = "http://arelle.org/";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [
      tomasajt
      roberth
    ];
  };
})