1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 hatchling,
6 ipython,
7 ipywidgets,
8 jinja2,
9 jsonschema,
10 narwhals,
11 numpy,
12 packaging,
13 pandas,
14 polars,
15 pytest-xdist,
16 pytestCheckHook,
17 pythonOlder,
18 toolz,
19 typing-extensions,
20 vega-datasets,
21}:
22
23buildPythonPackage rec {
24 pname = "altair";
25 version = "5.5.0";
26 pyproject = true;
27
28 disabled = pythonOlder "3.9";
29
30 src = fetchFromGitHub {
31 owner = "altair-viz";
32 repo = "altair";
33 tag = "v${version}";
34 hash = "sha256-lrKC4FYRQEax5E0lQNhO9FLk5UOJ0TnYzqZjndlRpGI=";
35 };
36
37 build-system = [ hatchling ];
38
39 dependencies = [
40 jinja2
41 jsonschema
42 narwhals
43 numpy
44 packaging
45 pandas
46 toolz
47 ]
48 ++ lib.optional (pythonOlder "3.14") typing-extensions;
49
50 nativeCheckInputs = [
51 ipython
52 ipywidgets
53 polars
54 pytest-xdist
55 pytestCheckHook
56 vega-datasets
57 ];
58
59 pythonImportsCheck = [ "altair" ];
60
61 disabledTests = [
62 # ValueError: Saving charts in 'svg' format requires the vl-convert-python or altair_saver package: see http://github.com/altair-viz/altair_saver/
63 "test_renderer_with_none_embed_options"
64 # Sometimes conflict due to parallelism
65 "test_dataframe_to_csv[polars]"
66 "test_dataframe_to_csv[pandas]"
67 # Network access
68 "test_theme_remote_lambda"
69 ];
70
71 disabledTestPaths = [
72 # Disabled because it requires internet connectivity
73 "tests/test_examples.py"
74 # TODO: Disabled because of missing altair_viewer package
75 "tests/vegalite/v5/test_api.py"
76 # avoid updating files and dependency on black
77 "tests/test_toplevel.py"
78 # require vl-convert package
79 "tests/utils/test_compiler.py"
80 ];
81
82 meta = with lib; {
83 description = "Declarative statistical visualization library for Python";
84 homepage = "https://altair-viz.github.io";
85 downloadPage = "https://github.com/altair-viz/altair";
86 changelog = "https://altair-viz.github.io/releases/changes.html";
87 license = licenses.bsd3;
88 maintainers = with maintainers; [
89 teh
90 vinetos
91 ];
92 };
93}