1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonOlder,
6 pytestCheckHook,
7 # build_requires
8 cython,
9 # install_requires
10 certifi,
11 importlib-metadata,
12 urllib3,
13 pytz,
14 zstandard,
15 lz4,
16 # extras_require
17 sqlalchemy,
18 numpy,
19 pandas,
20 pyarrow,
21 orjson,
22 # not in tests_require, but should be
23 pytest-dotenv,
24}:
25buildPythonPackage rec {
26 pname = "clickhouse-connect";
27 version = "0.7.8";
28
29 format = "setuptools";
30
31 disabled = pythonOlder "3.7";
32
33 src = fetchFromGitHub {
34 repo = "clickhouse-connect";
35 owner = "ClickHouse";
36 rev = "refs/tags/v${version}";
37 hash = "sha256-tdf9aYKAFpRyaqGGNxXs4bzmY6mdhKZ5toFBJRmD2VY=";
38 };
39
40 nativeBuildInputs = [ cython ];
41 setupPyBuildFlags = [ "--inplace" ];
42 enableParallelBuilding = true;
43
44 propagatedBuildInputs = [
45 certifi
46 importlib-metadata
47 urllib3
48 pytz
49 zstandard
50 lz4
51 ];
52
53 nativeCheckInputs = [
54 pytestCheckHook
55 pytest-dotenv
56 ] ++ passthru.optional-dependencies.sqlalchemy ++ passthru.optional-dependencies.numpy;
57
58 # these tests require a running clickhouse instance
59 disabledTestPaths = [
60 "tests/integration_tests"
61 "tests/tls"
62 ];
63
64 pythonImportsCheck = [
65 "clickhouse_connect"
66 "clickhouse_connect.driverc.buffer"
67 "clickhouse_connect.driverc.dataconv"
68 "clickhouse_connect.driverc.npconv"
69 ];
70
71 passthru = {
72 optional-dependencies = {
73 sqlalchemy = [ sqlalchemy ];
74 numpy = [ numpy ];
75 pandas = [ pandas ];
76 arrow = [ pyarrow ];
77 orjson = [ orjson ];
78 };
79 };
80
81 meta = with lib; {
82 description = "ClickHouse Database Core Driver for Python, Pandas, and Superset";
83 homepage = "https://github.com/ClickHouse/clickhouse-connect";
84 license = licenses.asl20;
85 maintainers = with maintainers; [ cpcloud ];
86 };
87}