summary refs log tree commit diff
path: root/pkgs/development/python-modules/ibis-framework/default.nix
blob: e25832fbfcb36855b0fd2b32b9881390ce1109bf (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
{ lib
, buildPythonPackage
, fetchFromGitHub
, pythonOlder
, pytestCheckHook
, atpublic
, cached-property
, clickhouse-driver
, click
, dask
, graphviz
, importlib-metadata
, multipledispatch
, numpy
, pandas
, parsy
, poetry-core
, pyarrow
, pytest
, pytest-mock
, pytest-xdist
, pytz
, regex
, requests
, sqlalchemy
, tables
, toolz
}:
let
  # ignore tests for which dependencies are not available
  backends = [
    "csv"
    "dask"
    "hdf5"
    "pandas"
    "parquet"
    "sqlite"
  ];

  backendsString = lib.concatStringsSep " " backends;

  ibisTestingData = fetchFromGitHub {
    owner = "ibis-project";
    repo = "testing-data";
    rev = "743201a35c6b968cf55b054f9d28949ea15d1f0a";
    sha256 = "sha256-xuSE6wHP3aF8lnEE2SuFbTRBu49ecRmc1F3HPcszptI=";
  };
in

buildPythonPackage rec {
  pname = "ibis-framework";
  version = "2.1.1";
  format = "pyproject";

  disabled = pythonOlder "3.7";

  src = fetchFromGitHub {
    repo = "ibis";
    owner = "ibis-project";
    rev = version;
    sha256 = "sha256-n3fR6wvcSfIo7760seB+5SxtoYSqQmqkzZ9VlNQF200=";
  };

  nativeBuildInputs = [ poetry-core ];

  propagatedBuildInputs = [
    atpublic
    cached-property
    clickhouse-driver
    dask
    graphviz
    multipledispatch
    numpy
    pandas
    parsy
    pyarrow
    pytz
    regex
    requests
    sqlalchemy
    tables
    toolz
  ] ++ lib.optionals (pythonOlder "3.8" && lib.versionOlder version "3.0.0") [
    importlib-metadata
  ];

  checkInputs = [
    pytestCheckHook
    click
    pytest
    pytest-mock
    pytest-xdist
  ];

  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace 'atpublic = ">=2.3,<3"' 'atpublic = ">=2.3"'
  '';

  preBuild = ''
    # setup.py exists only for developer convenience and is automatically generated
    rm setup.py
  '';

  disabledTests = [
    # These tests are broken upstream: https://github.com/ibis-project/ibis/issues/3291
    "test_summary_numeric"
    "test_summary_non_numeric"
    "test_batting_most_hits"
    "test_join_with_window_function"
    "test_where_long"
    "test_quantile_groupby"
    "test_summary_numeric"
    "test_summary_numeric_group_by"
    "test_summary_non_numeric"
    "test_searched_case_column"
    "test_simple_case_column"
    "test_summary_non_numeric_group_by"
  ];

  pytestFlagsArray = [
    "ibis/tests"
    "ibis/backends/tests"
    "ibis/backends/{${lib.concatStringsSep "," backends}}/tests"
  ];

  preCheck = ''
    set -euo pipefail

    export IBIS_TEST_DATA_DIRECTORY
    IBIS_TEST_DATA_DIRECTORY="$(mktemp -d)"

    # copy the test data to a writable directory
    cp -r ${ibisTestingData}/* "$IBIS_TEST_DATA_DIRECTORY"

    find "$IBIS_TEST_DATA_DIRECTORY" -type d -exec chmod u+rwx {} +
    find "$IBIS_TEST_DATA_DIRECTORY" -type f -exec chmod u+rw {} +

    # load data
    for backend in ${backendsString}; do
      python ci/datamgr.py "$backend" &
    done

    wait
  '' + lib.optionalString (lib.versionOlder version "3.0.0") ''
    export PYTEST_BACKENDS="${backendsString}"
  '';

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

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