summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/plotly/default.nix
blob: 7b0c006431a9d41230836c633ea7c57680bfaa85 (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
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  jupyter-packaging,
  setuptools,

  # dependencies
  narwhals,
  packaging,

  # optional-dependencies
  numpy,
  kaleido,

  # tests
  anywidget,
  ipython,
  ipywidgets,
  matplotlib,
  nbformat,
  pandas,
  pdfrw,
  pillow,
  polars,
  pyarrow,
  pytestCheckHook,
  requests,
  scikit-image,
  scipy,
  statsmodels,
  which,
  xarray,
}:

buildPythonPackage rec {
  pname = "plotly";
  version = "6.5.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "plotly";
    repo = "plotly.py";
    tag = "v${version}";
    hash = "sha256-JWb5bAu74j63E5tp8wmLjuWZqFAMpkg8utxM74VaGqA=";
  };

  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace-fail '"hatch", ' "" \
      --replace-fail "jupyter_packaging~=0.10.0" jupyter_packaging
  '';

  env.SKIP_NPM = true;

  build-system = [
    setuptools
    jupyter-packaging
  ];

  dependencies = [
    narwhals
    packaging
  ];

  optional-dependencies = {
    express = [ numpy ];
    kaleido = [ kaleido ];
  };

  nativeCheckInputs = [
    anywidget
    ipython
    ipywidgets
    matplotlib
    nbformat
    pandas
    pdfrw
    pillow
    polars
    pyarrow
    pytestCheckHook
    requests
    scikit-image
    scipy
    statsmodels
    which
    xarray
  ]
  ++ lib.concatAttrValues optional-dependencies;

  disabledTests = [
    # failed pinning test, sensitive to dep versions
    "test_legend_dots"
    "test_linestyle"
    # lazy loading error, could it be the sandbox PYTHONPATH?
    # AssertionError: assert "plotly" not in sys.modules
    "test_dependencies_not_imported"
    "test_lazy_imports"
    # [0.0, 'rgb(252, 255, 164)'] != [0.0, '#fcffa4']
    "test_acceptance_named"
    # AssertionError: assert '' == 'browser'
    "test_default_renderer"
  ];

  __darwinAllowLocalNetworking = true;

  disabledTestPaths = [
    # Broken imports
    "plotly/matplotlylib/mplexporter/tests"
    # Fails to catch error when serializing document
    "tests/test_optional/test_kaleido/test_kaleido.py::test_defaults"
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    # fails to launch kaleido subprocess
    "tests/test_optional/test_kaleido"
    # requiress access to osascript, which is not available while building
    "tests/test_plot.py::test_plot[plotly-psnr-rgb]"
    # numpy2 related error, RecursionError
    # See: https://github.com/plotly/plotly.py/issues/4852
    "tests/test_plotly_utils/validators/test_angle_validator.py"
    "tests/test_plotly_utils/validators/test_any_validator.py"
    "tests/test_plotly_utils/validators/test_color_validator.py"
    "tests/test_plotly_utils/validators/test_colorlist_validator.py"
    "tests/test_plotly_utils/validators/test_colorscale_validator.py"
    "tests/test_plotly_utils/validators/test_dataarray_validator.py"
    "tests/test_plotly_utils/validators/test_enumerated_validator.py"
    "tests/test_plotly_utils/validators/test_fig_deepcopy.py"
    "tests/test_plotly_utils/validators/test_flaglist_validator.py"
    "tests/test_plotly_utils/validators/test_infoarray_validator.py"
    "tests/test_plotly_utils/validators/test_integer_validator.py"
    "tests/test_plotly_utils/validators/test_number_validator.py"
    "tests/test_plotly_utils/validators/test_pandas_series_input.py"
    "tests/test_plotly_utils/validators/test_string_validator.py"
    "tests/test_plotly_utils/validators/test_xarray_input.py"
  ];

  pythonImportsCheck = [ "plotly" ];

  meta = {
    description = "Python plotting library for collaborative, interactive, publication-quality graphs";
    homepage = "https://plot.ly/python/";
    downloadPage = "https://github.com/plotly/plotly.py";
    changelog = "https://github.com/plotly/plotly.py/blob/master/CHANGELOG.md";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [
      pandapip1
      sarahec
    ];
  };
}