1{ lib
2, buildPythonPackage
3, duckdb
4, fsspec
5, google-cloud-storage
6, numpy
7, openssl
8, pandas
9, psutil
10, pybind11
11, setuptools-scm
12, pytestCheckHook
13}:
14
15buildPythonPackage rec {
16 inherit (duckdb) pname version src;
17 format = "setuptools";
18
19 # 1. let nix control build cores
20 # 2. default to extension autoload & autoinstall disabled
21 # 3. unconstrain setuptools_scm version
22 patches = (duckdb.patches or []) ++ [ ./setup.patch ];
23
24 postPatch = (duckdb.postPatch or "") + ''
25 # we can't use sourceRoot otherwise patches don't apply, because the patches apply to the C++ library
26 cd tools/pythonpkg
27
28 substituteInPlace setup.py --subst-var NIX_BUILD_CORES
29
30 # avoid dependency on mypy
31 rm tests/stubs/test_stubs.py
32 '';
33
34 BUILD_HTTPFS = 1;
35 SETUPTOOLS_SCM_PRETEND_VERSION = version;
36
37 nativeBuildInputs = [
38 pybind11
39 setuptools-scm
40 ];
41
42 buildInputs = [ openssl ];
43
44 propagatedBuildInputs = [
45 numpy
46 pandas
47 ];
48
49 nativeCheckInputs = [
50 fsspec
51 google-cloud-storage
52 psutil
53 pytestCheckHook
54 ];
55
56 disabledTests = [
57 # tries to make http request
58 "test_install_non_existent_extension"
59 # test is racy and interrupt can be delivered before or after target point
60 "test_connection_interrupt"
61 ];
62
63 preCheck = ''
64 export HOME="$(mktemp -d)"
65 '';
66
67 setupPyBuildFlags = [
68 "--inplace"
69 ];
70
71 pythonImportsCheck = [
72 "duckdb"
73 ];
74
75 meta = with lib; {
76 description = "Python binding for DuckDB";
77 homepage = "https://duckdb.org/";
78 license = licenses.mit;
79 maintainers = with maintainers; [ cpcloud ];
80 };
81}