about summary refs log tree commit diff
path: root/pkgs/development/python-modules/ibis-framework/default.nix
blob: 596bba56f0ae4689f74da64a685d3e2f2ad57518 (plain) (blame)
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  pythonOlder,
  pytestCheckHook,
  atpublic,
  bidict,
  black,
  clickhouse-connect,
  dask,
  datafusion,
  db-dtypes,
  duckdb,
  duckdb-engine,
  filelock,
  geoalchemy2,
  geopandas,
  google-cloud-bigquery,
  google-cloud-bigquery-storage,
  graphviz,
  hypothesis,
  multipledispatch,
  numpy,
  oracledb,
  packaging,
  pandas,
  parsy,
  pins,
  poetry-core,
  poetry-dynamic-versioning,
  polars,
  psycopg2,
  pyarrow,
  pyarrow-hotfix,
  pydata-google-auth,
  pydruid,
  pymysql,
  pyodbc,
  pyspark,
  pytest-benchmark,
  pytest-httpserver,
  pytest-mock,
  pytest-randomly,
  pytest-snapshot,
  pytest-timeout,
  pytest-xdist,
  python-dateutil,
  pytz,
  regex,
  rich,
  shapely,
  snowflake-connector-python,
  snowflake-sqlalchemy,
  sqlalchemy,
  sqlalchemy-views,
  sqlglot,
  sqlite,
  toolz,
  trino-python-client,
  typing-extensions,
}:
let
  testBackends = [
    "datafusion"
    "duckdb"
    "pandas"
    "sqlite"
  ];

  ibisTestingData = fetchFromGitHub {
    name = "ibis-testing-data";
    owner = "ibis-project";
    repo = "testing-data";
    # https://github.com/ibis-project/ibis/blob/9.0.0/nix/overlay.nix#L20-L26
    rev = "1922bd4617546b877e66e78bb2b87abeb510cf8e";
    hash = "sha256-l5d7r/6Voy6N2pXq3IivLX3N0tNfKKwsbZXRexzc8Z8=";
  };
in

buildPythonPackage rec {
  pname = "ibis-framework";
  version = "9.0.0";
  pyproject = true;

  disabled = pythonOlder "3.9";

  src = fetchFromGitHub {
    name = "ibis-source";
    repo = "ibis";
    owner = "ibis-project";
    rev = "refs/tags/${version}";
    hash = "sha256-ebTYCBL1zm2Rmwg998x2kYvKhyQDk8Di1pcx5lR37xo=";
  };

  nativeBuildInputs = [
    poetry-core
    poetry-dynamic-versioning
  ];

  POETRY_DYNAMIC_VERSIONING_BYPASS = version;

  propagatedBuildInputs = [
    atpublic
    bidict
    multipledispatch
    numpy
    pandas
    parsy
    pyarrow
    pyarrow-hotfix
    python-dateutil
    pytz
    rich
    sqlglot
    toolz
    typing-extensions
  ];

  nativeCheckInputs = [
    pytestCheckHook
    black
    filelock
    hypothesis
    pytest-benchmark
    pytest-httpserver
    pytest-mock
    pytest-randomly
    pytest-snapshot
    pytest-timeout
    pytest-xdist
  ] ++ lib.concatMap (name: passthru.optional-dependencies.${name}) testBackends;

  pytestFlagsArray = [
    "--dist=loadgroup"
    "-m"
    "'${lib.concatStringsSep " or " testBackends} or core'"
  ];

  disabledTests = [
    # breakage from sqlalchemy2 truediv changes
    "test_tpc_h17"
    # tries to download duckdb extensions
    "test_attach_sqlite"
    "test_connect_extensions"
    "test_load_extension"
    "test_read_sqlite"
    "test_register_sqlite"
    # duckdb does not respect sample_size=2 (reads 3 lines of csv).
    "test_csv_reregister_schema"
    # duckdb fails with:
    # "This function can not be called with an active transaction!, commit or abort the existing one first"
    "test_vectorized_udf"
    "test_s3_403_fallback"
    "test_map_merge_udf"
    "test_udf"
    "test_map_udf"
    # DataFusion error
    "datafusion"
    # pluggy.PluggyTeardownRaisedWarning
    "test_repr_png_is_not_none_in_not_interactive"
    "test_interval_arithmetic"
  ];

  # patch out tests that check formatting with black
  postPatch = ''
    find ibis/tests -type f -name '*.py' -exec sed -i \
      -e '/^ *assert_decompile_roundtrip/d' \
      -e 's/^\( *\)code = ibis.decompile(expr, format=True)/\1code = ibis.decompile(expr)/g' {} +
  '';

  preCheck = ''
    HOME="$TMPDIR"
    export IBIS_TEST_DATA_DIRECTORY="ci/ibis-testing-data"

    # copy the test data to a directory
    ln -s "${ibisTestingData}" "$IBIS_TEST_DATA_DIRECTORY"
  '';

  postCheck = ''
    rm -r "$IBIS_TEST_DATA_DIRECTORY"
  '';

  pythonImportsCheck = [ "ibis" ] ++ map (backend: "ibis.backends.${backend}") testBackends;

  passthru = {
    optional-dependencies = {
      bigquery = [
        db-dtypes
        google-cloud-bigquery
        google-cloud-bigquery-storage
        pydata-google-auth
      ];
      clickhouse = [
        clickhouse-connect
        sqlalchemy
      ];
      dask = [
        dask
        regex
      ];
      datafusion = [ datafusion ];
      druid = [
        pydruid
        sqlalchemy
      ];
      duckdb = [
        duckdb
        duckdb-engine
        sqlalchemy
        sqlalchemy-views
      ];
      flink = [ ];
      geospatial = [
        geoalchemy2
        geopandas
        shapely
      ];
      mssql = [
        sqlalchemy
        pyodbc
        sqlalchemy-views
      ];
      mysql = [
        sqlalchemy
        pymysql
        sqlalchemy-views
      ];
      oracle = [
        sqlalchemy
        oracledb
        packaging
        sqlalchemy-views
      ];
      pandas = [ regex ];
      polars = [
        polars
        packaging
      ];
      postgres = [
        psycopg2
        sqlalchemy
        sqlalchemy-views
      ];
      pyspark = [
        pyspark
        sqlalchemy
        packaging
      ];
      snowflake = [
        snowflake-connector-python
        snowflake-sqlalchemy
        sqlalchemy-views
        packaging
      ];
      sqlite = [
        regex
        sqlalchemy
        sqlalchemy-views
      ];
      trino = [
        trino-python-client
        sqlalchemy
        sqlalchemy-views
      ];
      visualization = [ graphviz ];
      decompiler = [ black ];
      examples = [ pins ] ++ pins.optional-dependencies.gcs;
    };
  };

  meta = with lib; {
    description = "Productivity-centric Python Big Data Framework";
    homepage = "https://github.com/ibis-project/ibis";
    changelog = "https://github.com/ibis-project/ibis/blob/${version}/docs/release_notes.md";
    license = licenses.asl20;
    maintainers = with maintainers; [ cpcloud ];
  };
}