summary refs log tree commit diff
path: root/pkgs/development/python-modules/duckdb/default.nix
blob: 5ff99568499261fda678357a6aa7885053f472c1 (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
{ lib
, buildPythonPackage
, duckdb
, fsspec
, google-cloud-storage
, numpy
, openssl
, pandas
, psutil
, pybind11
, setuptools-scm
, pytestCheckHook
}:

buildPythonPackage rec {
  inherit (duckdb) pname version src;
  format = "setuptools";

  # 1. let nix control build cores
  # 2. default to extension autoload & autoinstall disabled
  # 3. unconstrain setuptools_scm version
  patches = (duckdb.patches or []) ++ [ ./setup.patch ];

  postPatch = (duckdb.postPatch or "") + ''
    # we can't use sourceRoot otherwise patches don't apply, because the patches apply to the C++ library
    cd tools/pythonpkg

    substituteInPlace setup.py --subst-var NIX_BUILD_CORES

    # avoid dependency on mypy
    rm tests/stubs/test_stubs.py
  '';

  BUILD_HTTPFS = 1;
  SETUPTOOLS_SCM_PRETEND_VERSION = version;

  nativeBuildInputs = [
    pybind11
    setuptools-scm
  ];

  buildInputs = [ openssl ];

  propagatedBuildInputs = [
    numpy
    pandas
  ];

  nativeCheckInputs = [
    fsspec
    google-cloud-storage
    psutil
    pytestCheckHook
  ];

  disabledTests = [
    # tries to make http request
    "test_install_non_existent_extension"
    # test is racy and interrupt can be delivered before or after target point
    "test_connection_interrupt"
  ];

  preCheck = ''
    export HOME="$(mktemp -d)"
  '';

  setupPyBuildFlags = [
    "--inplace"
  ];

  pythonImportsCheck = [
    "duckdb"
  ];

  meta = with lib; {
    description = "Python binding for DuckDB";
    homepage = "https://duckdb.org/";
    license = licenses.mit;
    maintainers = with maintainers; [ cpcloud ];
  };
}