1{
2 lib,
3 attrs,
4 authlib,
5 avro,
6 azure-identity,
7 azure-keyvault-keys,
8 boto3,
9 buildPythonPackage,
10 cachetools,
11 fastavro,
12 fetchFromGitHub,
13 google-auth,
14 google-api-core,
15 google-cloud-kms,
16 hvac,
17 httpx,
18 jsonschema,
19 orjson,
20 protobuf,
21 pyflakes,
22 pyrsistent,
23 pytestCheckHook,
24 pythonOlder,
25 pyyaml,
26 rdkafka,
27 requests,
28 requests-mock,
29 respx,
30 setuptools,
31}:
32
33buildPythonPackage rec {
34 pname = "confluent-kafka";
35 version = "2.11.0";
36 pyproject = true;
37
38 disabled = pythonOlder "3.7";
39
40 src = fetchFromGitHub {
41 owner = "confluentinc";
42 repo = "confluent-kafka-python";
43 tag = "v${version}";
44 hash = "sha256-s4UeuFXieyUcFJsYHTaJBKfUssYZ7mt4YoHgXN7bZKI=";
45 };
46
47 buildInputs = [ rdkafka ];
48
49 build-system = [ setuptools ];
50
51 optional-dependencies = {
52 avro = [
53 avro
54 fastavro
55 requests
56 ];
57 json = [
58 jsonschema
59 pyrsistent
60 requests
61 ];
62 protobuf = [
63 protobuf
64 requests
65 ];
66 rules = [
67 azure-identity
68 azure-keyvault-keys
69 boto3
70 # TODO: cel-python
71 google-auth
72 google-api-core
73 google-cloud-kms
74 # hkdf was removed
75 hvac
76 # TODO: jsonata-python
77 pyyaml
78 # TODO: tink
79 ];
80 schema-registry = [
81 attrs
82 authlib
83 cachetools
84 httpx
85 ];
86 };
87
88 nativeCheckInputs = [
89 cachetools
90 orjson
91 pyflakes
92 pytestCheckHook
93 requests-mock
94 respx
95 ]
96 ++ lib.flatten (lib.attrValues optional-dependencies);
97
98 pythonImportsCheck = [ "confluent_kafka" ];
99
100 disabledTestPaths = [
101 "tests/integration/"
102 "tests/test_Admin.py"
103 "tests/test_misc.py"
104 # Failed: async def functions are not natively supported.
105 "tests/schema_registry/_async"
106 # missing cel-python dependency
107 "tests/schema_registry/_sync/test_avro_serdes.py"
108 "tests/schema_registry/_sync/test_json_serdes.py"
109 "tests/schema_registry/_sync/test_proto_serdes.py"
110 # missing tink dependency
111 "tests/schema_registry/_async/test_config.py"
112 "tests/schema_registry/_sync/test_config.py"
113 # crashes the test runner on shutdown
114 "tests/test_KafkaError.py"
115 ];
116
117 meta = with lib; {
118 description = "Confluent's Apache Kafka client for Python";
119 homepage = "https://github.com/confluentinc/confluent-kafka-python";
120 changelog = "https://github.com/confluentinc/confluent-kafka-python/blob/${src.tag}/CHANGELOG.md";
121 license = licenses.asl20;
122 maintainers = with maintainers; [ mlieberman85 ];
123 };
124}