1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 jupyter-packaging,
9 setuptools,
10
11 # dependencies
12 narwhals,
13 packaging,
14
15 # optional-dependencies
16 numpy,
17 kaleido,
18
19 # tests
20 anywidget,
21 ipython,
22 ipywidgets,
23 matplotlib,
24 nbformat,
25 pandas,
26 pdfrw,
27 pillow,
28 polars,
29 pyarrow,
30 pytestCheckHook,
31 requests,
32 scikit-image,
33 scipy,
34 statsmodels,
35 which,
36 xarray,
37}:
38
39buildPythonPackage rec {
40 pname = "plotly";
41 version = "6.3.0";
42 pyproject = true;
43
44 src = fetchFromGitHub {
45 owner = "plotly";
46 repo = "plotly.py";
47 tag = "v${version}";
48 hash = "sha256-s+kWJy/dOqlNqRD/Ytxy/SSRsFJvp13jSvPMd0LQliQ=";
49 };
50
51 postPatch = ''
52 substituteInPlace pyproject.toml \
53 --replace-fail '"hatch", ' "" \
54 --replace-fail "jupyter_packaging~=0.10.0" jupyter_packaging
55 '';
56
57 env.SKIP_NPM = true;
58
59 build-system = [
60 setuptools
61 jupyter-packaging
62 ];
63
64 dependencies = [
65 narwhals
66 packaging
67 ];
68
69 optional-dependencies = {
70 express = [ numpy ];
71 kaleido = [ kaleido ];
72 };
73
74 nativeCheckInputs = [
75 anywidget
76 ipython
77 ipywidgets
78 matplotlib
79 nbformat
80 pandas
81 pdfrw
82 pillow
83 polars
84 pyarrow
85 pytestCheckHook
86 requests
87 scikit-image
88 scipy
89 statsmodels
90 which
91 xarray
92 ]
93 ++ lib.flatten (lib.attrValues optional-dependencies);
94
95 disabledTests = [
96 # failed pinning test, sensitive to dep versions
97 "test_legend_dots"
98 "test_linestyle"
99 # lazy loading error, could it be the sandbox PYTHONPATH?
100 # AssertionError: assert "plotly" not in sys.modules
101 "test_dependencies_not_imported"
102 "test_lazy_imports"
103 # [0.0, 'rgb(252, 255, 164)'] != [0.0, '#fcffa4']
104 "test_acceptance_named"
105 ];
106
107 __darwinAllowLocalNetworking = true;
108
109 disabledTestPaths = [
110 # Broken imports
111 "plotly/matplotlylib/mplexporter/tests"
112 # Fails to catch error when serializing document
113 "tests/test_optional/test_kaleido/test_kaleido.py::test_defaults"
114 ]
115 ++ lib.optionals stdenv.hostPlatform.isDarwin [
116 # fails to launch kaleido subprocess
117 "tests/test_optional/test_kaleido"
118 # numpy2 related error, RecursionError
119 # See: https://github.com/plotly/plotly.py/issues/4852
120 "tests/test_plotly_utils/validators/test_angle_validator.py"
121 "tests/test_plotly_utils/validators/test_any_validator.py"
122 "tests/test_plotly_utils/validators/test_color_validator.py"
123 "tests/test_plotly_utils/validators/test_colorlist_validator.py"
124 "tests/test_plotly_utils/validators/test_colorscale_validator.py"
125 "tests/test_plotly_utils/validators/test_dataarray_validator.py"
126 "tests/test_plotly_utils/validators/test_enumerated_validator.py"
127 "tests/test_plotly_utils/validators/test_fig_deepcopy.py"
128 "tests/test_plotly_utils/validators/test_flaglist_validator.py"
129 "tests/test_plotly_utils/validators/test_infoarray_validator.py"
130 "tests/test_plotly_utils/validators/test_integer_validator.py"
131 "tests/test_plotly_utils/validators/test_number_validator.py"
132 "tests/test_plotly_utils/validators/test_pandas_series_input.py"
133 "tests/test_plotly_utils/validators/test_string_validator.py"
134 "tests/test_plotly_utils/validators/test_xarray_input.py"
135 ];
136
137 pythonImportsCheck = [ "plotly" ];
138
139 meta = {
140 description = "Python plotting library for collaborative, interactive, publication-quality graphs";
141 homepage = "https://plot.ly/python/";
142 downloadPage = "https://github.com/plotly/plotly.py";
143 changelog = "https://github.com/plotly/plotly.py/blob/master/CHANGELOG.md";
144 license = lib.licenses.mit;
145 maintainers = with lib.maintainers; [
146 pandapip1
147 sarahec
148 ];
149 };
150}