1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9
10 # dependencies
11 ipython-genutils,
12 jinja2,
13 jupysql-plugin,
14 ploomber-core,
15 prettytable,
16 sqlalchemy,
17 sqlglot,
18 sqlparse,
19
20 # optional-dependencies
21 duckdb,
22 duckdb-engine,
23 grpcio,
24 ipython,
25 ipywidgets,
26 matplotlib,
27 numpy,
28 pandas,
29 polars,
30 pyarrow,
31 pyspark,
32
33 # tests
34 pytestCheckHook,
35 psutil,
36}:
37
38buildPythonPackage rec {
39 pname = "jupysql";
40 version = "0.10.16";
41
42 pyproject = true;
43
44 src = fetchFromGitHub {
45 owner = "ploomber";
46 repo = "jupysql";
47 tag = version;
48 hash = "sha256-TIISiGvspRG0d/4nEyi8Tiu0y80D1Rf8puDEkGIeA08=";
49 };
50
51 pythonRelaxDeps = [ "sqlalchemy" ];
52
53 build-system = [ setuptools ];
54
55 dependencies = [
56 ipython-genutils
57 jinja2
58 jupysql-plugin
59 ploomber-core
60 prettytable
61 sqlalchemy
62 sqlglot
63 sqlparse
64 ];
65
66 optional-dependencies.dev = [
67 duckdb
68 duckdb-engine
69 grpcio
70 ipython
71 ipywidgets
72 matplotlib
73 numpy
74 pandas
75 polars
76 pyarrow
77 pyspark
78 ];
79
80 nativeCheckInputs = [
81 pytestCheckHook
82 psutil
83 ] ++ optional-dependencies.dev;
84
85 disabledTests =
86 [
87 # AttributeError: 'DataFrame' object has no attribute 'frame_equal'
88 "test_resultset_polars_dataframe"
89 # all of these are broken with later versions of duckdb; see
90 # https://github.com/ploomber/jupysql/issues/1030
91 "test_resultset_getitem"
92 "test_resultset_dict"
93 "test_resultset_len"
94 "test_resultset_dicts"
95 "test_resultset_dataframe"
96 "test_resultset_csv"
97 "test_resultset_str"
98 "test_resultset_repr_html_when_feedback_is_2"
99 "test_resultset_repr_html_with_reduced_feedback"
100 "test_invalid_operation_error"
101 "test_resultset_config_autolimit_dict"
102 # fails due to strict warnings
103 "test_calling_legacy_plotting_functions_displays_warning"
104 ]
105 ++ lib.optionals stdenv.hostPlatform.isDarwin [
106 # Fatal Python error: Aborted (in matplotlib)
107 "test_no_errors_with_stored_query"
108 ];
109
110 disabledTestPaths = [
111 # require docker
112 "src/tests/integration"
113
114 # want to download test data from the network
115 "src/tests/test_parse.py"
116 "src/tests/test_ggplot.py"
117 "src/tests/test_plot.py"
118 "src/tests/test_magic.py"
119 "src/tests/test_magic_plot.py"
120
121 # require js2py (which is unmaintained and insecure)
122 "src/tests/test_widget.py"
123 ];
124
125 preCheck = ''
126 # tests need to write temp data
127 export HOME=$(mktemp -d)
128 '';
129
130 pythonImportsCheck = [ "sql" ];
131
132 meta = {
133 description = "Better SQL in Jupyter";
134 homepage = "https://github.com/ploomber/jupysql";
135 changelog = "https://github.com/ploomber/jupysql/blob/${version}/CHANGELOG.md";
136 license = lib.licenses.asl20;
137 maintainers = with lib.maintainers; [ pacien ];
138 };
139}