1{ lib
2, buildPythonPackage
3, duckdb
4, google-cloud-storage
5, numpy
6, pandas
7, psutil
8, pybind11
9, setuptools-scm
10, pytestCheckHook
11}:
12
13buildPythonPackage rec {
14 inherit (duckdb) pname version src patches;
15 format = "setuptools";
16
17 postPatch = ''
18 # we can't use sourceRoot otherwise patches don't apply, because the patches apply to the C++ library
19 cd tools/pythonpkg
20
21 # 1. let nix control build cores
22 # 2. unconstrain setuptools_scm version
23 substituteInPlace setup.py \
24 --replace "multiprocessing.cpu_count()" "$NIX_BUILD_CORES" \
25 --replace "setuptools_scm<7.0.0" "setuptools_scm"
26
27 # avoid dependency on mypy
28 rm tests/stubs/test_stubs.py
29 '';
30
31 SETUPTOOLS_SCM_PRETEND_VERSION = version;
32
33 nativeBuildInputs = [
34 pybind11
35 setuptools-scm
36 ];
37
38 propagatedBuildInputs = [
39 numpy
40 pandas
41 ];
42
43 nativeCheckInputs = [
44 google-cloud-storage
45 psutil
46 pytestCheckHook
47 ];
48
49 disabledTests = [
50 # tries to make http request
51 "test_install_non_existent_extension"
52 ];
53
54 preCheck = ''
55 export HOME="$(mktemp -d)"
56 '';
57
58 pythonImportsCheck = [
59 "duckdb"
60 ];
61
62 meta = with lib; {
63 description = "Python binding for DuckDB";
64 homepage = "https://duckdb.org/";
65 license = licenses.mit;
66 maintainers = with maintainers; [ cpcloud ];
67 };
68}