1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 setuptools,
7 packaging,
8 tenacity,
9 kaleido,
10 pytestCheckHook,
11 pandas,
12 requests,
13 matplotlib,
14 xarray,
15 pillow,
16 scipy,
17 statsmodels,
18 ipython,
19 ipywidgets,
20 which,
21 nbformat,
22 scikit-image,
23 orca,
24 psutil,
25}:
26
27buildPythonPackage rec {
28 pname = "plotly";
29 version = "5.24.1";
30 pyproject = true;
31
32 src = fetchFromGitHub {
33 owner = "plotly";
34 repo = "plotly.py";
35 tag = "v${version}";
36 hash = "sha256-ONuX5/GlirPF8+7bZtib1Xsv5llcXcSelFfGyeTc5L8=";
37 };
38
39 sourceRoot = "${src.name}/packages/python/plotly";
40
41 # tracking numpy 2 issue: https://github.com/plotly/plotly.py/pull/4622
42 postPatch = ''
43 substituteInPlace pyproject.toml \
44 --replace-fail "\"jupyterlab~=3.0;python_version>='3.6'\"," ""
45
46 substituteInPlace plotly/tests/test_optional/test_utils/test_utils.py \
47 --replace-fail "np.NaN" "np.nan" \
48 --replace-fail "np.NAN" "np.nan" \
49 --replace-fail "np.Inf" "np.inf"
50
51 substituteInPlace plotly/tests/test_optional/test_px/test_imshow.py \
52 --replace-fail "- 255 * img.max()" "- np.int64(255) * img.max()"
53 '';
54
55 env.SKIP_NPM = true;
56
57 build-system = [ setuptools ];
58
59 dependencies = [
60 packaging
61 tenacity
62 kaleido
63 ];
64
65 # packages/python/plotly/optional-requirements.txt
66 optional-dependencies = {
67 orca = [
68 orca
69 requests
70 psutil
71 ];
72 };
73
74 nativeCheckInputs = [
75 pytestCheckHook
76 pandas
77 requests
78 matplotlib
79 xarray
80 pillow
81 scipy
82 statsmodels
83 ipython
84 ipywidgets
85 which
86 nbformat
87 scikit-image
88 ];
89
90 disabledTests = [
91 # failed pinning test, sensitive to dep versions
92 "test_legend_dots"
93 "test_linestyle"
94 # test bug, i assume sensitive to dep versions
95 "test_sanitize_json"
96 # requires vaex and polars, vaex is not packaged
97 "test_build_df_from_vaex_and_polars"
98 "test_build_df_with_hover_data_from_vaex_and_polars"
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 # numpy2 related error, RecursionError
104 # https://github.com/plotly/plotly.py/pull/4622#issuecomment-2452886352
105 "test_masked_constants_example"
106 ];
107 disabledTestPaths =
108 [
109 # unable to locate orca binary, adding the package does not fix it
110 "plotly/tests/test_orca/"
111 ]
112 ++ lib.optionals stdenv.hostPlatform.isDarwin [
113 # requires local networking
114 "plotly/tests/test_io/test_renderers.py"
115 # fails to launch kaleido subprocess
116 "plotly/tests/test_optional/test_kaleido"
117 ];
118
119 pythonImportsCheck = [ "plotly" ];
120
121 meta = {
122 description = "Python plotting library for collaborative, interactive, publication-quality graphs";
123 homepage = "https://plot.ly/python/";
124 downloadPage = "https://github.com/plotly/plotly.py";
125 changelog = "https://github.com/plotly/plotly.py/blob/master/CHANGELOG.md";
126 license = lib.licenses.mit;
127 maintainers = with lib.maintainers; [ pandapip1 ];
128 };
129}