1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pytestCheckHook,
6 pythonAtLeast,
7 pythonOlder,
8 python,
9 duckdb,
10 hypothesis,
11 pandas,
12 pyarrow,
13 poetry-core,
14 pytest-remotedata,
15 snapshottest,
16 sqlalchemy,
17 typing-extensions,
18}:
19
20buildPythonPackage rec {
21 pname = "duckdb-engine";
22 version = "0.15.0";
23 pyproject = true;
24
25 disabled = pythonOlder "3.8";
26
27 src = fetchFromGitHub {
28 repo = "duckdb_engine";
29 owner = "Mause";
30 tag = "v${version}";
31 hash = "sha256-mxv6xYO31MDzHvIf7Zk+kFtm6fX3x3AaJNn7RhvJ2fY=";
32 };
33
34 nativeBuildInputs = [ poetry-core ];
35
36 propagatedBuildInputs = [
37 duckdb
38 sqlalchemy
39 ];
40
41 preCheck = ''
42 export HOME="$(mktemp -d)"
43 '';
44
45 nativeCheckInputs = [ pytestCheckHook ];
46
47 checkInputs =
48 [
49 hypothesis
50 pandas
51 pytest-remotedata
52 typing-extensions
53 pyarrow
54 ]
55 ++ lib.optionals (pythonOlder "3.12") [
56 # requires wasmer which is broken for python 3.12
57 # https://github.com/wasmerio/wasmer-python/issues/778
58 snapshottest
59 ];
60
61 pytestFlagsArray = [
62 "-m"
63 "'not remote_data'"
64 ];
65
66 disabledTestPaths = lib.optionals (pythonAtLeast "3.12") [
67 # requires snapshottest
68 "duckdb_engine/tests/test_datatypes.py"
69 ];
70
71 disabledTests =
72 [
73 # incompatible with duckdb 1.1.1
74 "test_with_cache"
75 # these aren't set for some reason
76 "test_user_agent"
77 "test_user_agent_with_custom_user_agent"
78 ]
79 ++ lib.optionals (python.pythonVersion == "3.11") [
80 # incompatible with duckdb 1.1.1
81 "test_all_types_reflection"
82 "test_nested_types"
83 ];
84
85 pythonImportsCheck = [ "duckdb_engine" ];
86
87 meta = with lib; {
88 description = "SQLAlchemy driver for duckdb";
89 homepage = "https://github.com/Mause/duckdb_engine";
90 changelog = "https://github.com/Mause/duckdb_engine/blob/${src.tag}/CHANGELOG.md";
91 license = licenses.mit;
92 maintainers = with maintainers; [ cpcloud ];
93 };
94}