summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/itables/default.nix
blob: c13f8bf76de926e8cf95884af8835d89eca98906 (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
{
  lib,
  buildPythonPackage,
  fetchPypi,
  python,

  # build-system
  dash,
  hatchling,
  hatch-jupyter-builder,
  pyyaml,
  setuptools,

  # nativeBuildInputs
  nodejs,

  # optional-dependencies
  ipython,
  numpy,
  pandas,
  polars,
  narwhals,
  matplotlib,
  anywidget,
  traitlets,
  streamlit,
  marimo,
  pyarrow,
  typing-extensions,
}:

buildPythonPackage rec {
  pname = "itables";
  version = "2.6.2";

  # itables has 4 different node packages, each with their own
  # package-lock.json, and partially depending on each other.
  # Our fetchNpmDeps tooling in nixpkgs doesn't support this yet, so we fetch
  # the source tarball from pypi, which includes the javascript bundle already.
  src = fetchPypi {
    inherit pname version;
    hash = "sha256-P3PzBBB022Q3+9L3Loq18kyWhXB2JcCF/3FwHUPkxi8=";
  };

  pyproject = true;

  build-system = [
    dash
    hatchling
    hatch-jupyter-builder
    pyyaml
    setuptools
  ];

  nativeBuildInputs = [
    nodejs
  ];

  # shiny and modin omitted due to missing deps
  optional-dependencies = {
    all = [
      pandas
      polars
      narwhals
      matplotlib
      ipython
      anywidget
      traitlets
      dash
      streamlit
      marimo
      pyarrow
    ];
    pandas = [ pandas ];
    polars = [ polars ];
    narwhals = [ narwhals ];
    style = [
      pandas
      matplotlib
    ];
    notebook = [ ipython ];
    widget = [
      anywidget
      traitlets
    ];
    dash = [
      dash
      typing-extensions
    ];
    streamlit = [ streamlit ];
    marimo = [ marimo ];
    other_dataframes = [
      narwhals
      pyarrow
    ];
  };

  # no tests in pypi tarball
  doCheck = false;

  # don't run the hooks, as they try to invoke npm on packages/,
  env.HATCH_BUILD_NO_HOOKS = true;

  # The pyproject.toml shipped with the sources doesn't install anything,
  # as the paths in the pypi tarball are not the same as in the repo checkout.
  # We exclude itables_for_dash here, as it's missing the .dist-info dir
  # plumbing to be discoverable, and should be its own package anyways.
  postInstall = ''
    cp -R itables $out/${python.sitePackages}
  '';

  pythonImportsCheck = [ "itables" ];

  meta = {
    description = "Pandas and Polar DataFrames as interactive DataTables";
    homepage = "https://github.com/mwouts/itables";
    changelog = "https://github.com/mwouts/itables/releases/tag/v${version}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ flokli ];
  };
}