2020-05-29 06:06:01 +00:00
|
|
|
{ lib
|
2024-02-29 20:09:43 +00:00
|
|
|
, stdenv
|
2020-05-29 06:06:01 +00:00
|
|
|
, buildPythonPackage
|
|
|
|
, duckdb
|
2023-10-09 19:29:22 +00:00
|
|
|
, fsspec
|
2022-06-26 10:26:21 +00:00
|
|
|
, google-cloud-storage
|
2020-05-29 06:06:01 +00:00
|
|
|
, numpy
|
2023-10-09 19:29:22 +00:00
|
|
|
, openssl
|
2020-05-29 06:06:01 +00:00
|
|
|
, pandas
|
2022-06-26 10:26:21 +00:00
|
|
|
, psutil
|
2020-05-29 06:06:01 +00:00
|
|
|
, pybind11
|
2021-06-04 09:07:49 +00:00
|
|
|
, setuptools-scm
|
2021-02-17 17:02:09 +00:00
|
|
|
, pytestCheckHook
|
2020-05-29 06:06:01 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
2024-02-29 20:09:43 +00:00
|
|
|
inherit (duckdb) patches pname src version;
|
|
|
|
pyproject = true;
|
2023-11-16 04:20:00 +00:00
|
|
|
|
|
|
|
postPatch = (duckdb.postPatch or "") + ''
|
2023-07-15 17:15:38 +00:00
|
|
|
# we can't use sourceRoot otherwise patches don't apply, because the patches apply to the C++ library
|
2022-07-14 12:49:19 +00:00
|
|
|
cd tools/pythonpkg
|
2022-11-21 17:40:18 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
# 1. let nix control build cores
|
|
|
|
# 2. default to extension autoload & autoinstall disabled
|
|
|
|
substituteInPlace setup.py \
|
|
|
|
--replace-fail "ParallelCompile()" 'ParallelCompile("NIX_BUILD_CORES")' \
|
|
|
|
--replace-fail "define_macros.extend([('DUCKDB_EXTENSION_AUTOLOAD_DEFAULT', '1'), ('DUCKDB_EXTENSION_AUTOINSTALL_DEFAULT', '1')])" ""
|
2022-07-14 12:49:19 +00:00
|
|
|
'';
|
2020-09-25 04:45:31 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
env = {
|
|
|
|
BUILD_HTTPFS = 1;
|
|
|
|
DUCKDB_BUILD_UNITY = 1;
|
|
|
|
};
|
2020-05-29 06:06:01 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
pybind11
|
2021-06-04 09:07:49 +00:00
|
|
|
setuptools-scm
|
2020-05-29 06:06:01 +00:00
|
|
|
];
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
buildInputs = [ openssl ];
|
|
|
|
|
2021-07-04 02:40:35 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
numpy
|
|
|
|
pandas
|
|
|
|
];
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2023-10-09 19:29:22 +00:00
|
|
|
fsspec
|
2022-06-26 10:26:21 +00:00
|
|
|
google-cloud-storage
|
|
|
|
psutil
|
2021-07-04 02:40:35 +00:00
|
|
|
pytestCheckHook
|
|
|
|
];
|
2020-05-29 06:06:01 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
# test flags from .github/workflows/Python.yml
|
|
|
|
pytestFlagsArray = [
|
|
|
|
"--verbose"
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
"tests/fast"
|
|
|
|
];
|
|
|
|
|
|
|
|
disabledTestPaths = [
|
|
|
|
# avoid dependency on mypy
|
|
|
|
"tests/stubs/test_stubs.py"
|
|
|
|
];
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
disabledTests = [
|
|
|
|
# tries to make http request
|
|
|
|
"test_install_non_existent_extension"
|
2024-02-29 20:09:43 +00:00
|
|
|
|
|
|
|
# https://github.com/duckdb/duckdb/issues/10702
|
|
|
|
# tests are racy and interrupt can be delivered before or after target point
|
|
|
|
# causing a later test to fail with a spurious KeyboardInterrupt
|
2023-11-16 04:20:00 +00:00
|
|
|
"test_connection_interrupt"
|
2024-02-29 20:09:43 +00:00
|
|
|
"test_query_interruption"
|
2023-07-15 17:15:38 +00:00
|
|
|
];
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
# remove duckdb dir to prevent import confusion by pytest
|
2023-07-15 17:15:38 +00:00
|
|
|
preCheck = ''
|
|
|
|
export HOME="$(mktemp -d)"
|
2024-02-29 20:09:43 +00:00
|
|
|
rm -rf duckdb
|
2023-07-15 17:15:38 +00:00
|
|
|
'';
|
|
|
|
|
2022-01-03 16:56:52 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"duckdb"
|
|
|
|
];
|
2020-05-29 06:06:01 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
2021-07-04 02:40:35 +00:00
|
|
|
description = "Python binding for DuckDB";
|
|
|
|
homepage = "https://duckdb.org/";
|
2020-05-29 06:06:01 +00:00
|
|
|
license = licenses.mit;
|
2023-08-04 22:07:22 +00:00
|
|
|
maintainers = with maintainers; [ cpcloud ];
|
2020-05-29 06:06:01 +00:00
|
|
|
};
|
|
|
|
}
|