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.1";
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-WpvWv6UG7T0yJ1ZKZweHbWjh+C0PbEIYbbMAS4yyhzg=";
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 orjson
86 ];
87 };
88
89 nativeCheckInputs = [
90 cachetools
91 orjson
92 pyflakes
93 pytestCheckHook
94 requests-mock
95 respx
96 ]
97 ++ lib.flatten (lib.attrValues optional-dependencies);
98
99 pythonImportsCheck = [ "confluent_kafka" ];
100
101 disabledTestPaths = [
102 "tests/integration/"
103 "tests/test_Admin.py"
104 "tests/test_misc.py"
105 # Failed: async def functions are not natively supported.
106 "tests/schema_registry/_async"
107 # missing cel-python dependency
108 "tests/schema_registry/_sync/test_avro_serdes.py"
109 "tests/schema_registry/_sync/test_json_serdes.py"
110 "tests/schema_registry/_sync/test_proto_serdes.py"
111 # missing tink dependency
112 "tests/schema_registry/_async/test_config.py"
113 "tests/schema_registry/_sync/test_config.py"
114 # crashes the test runner on shutdown
115 "tests/test_kafka_error.py"
116 ];
117
118 meta = with lib; {
119 description = "Confluent's Apache Kafka client for Python";
120 homepage = "https://github.com/confluentinc/confluent-kafka-python";
121 changelog = "https://github.com/confluentinc/confluent-kafka-python/blob/${src.tag}/CHANGELOG.md";
122 license = licenses.asl20;
123 maintainers = with maintainers; [ mlieberman85 ];
124 };
125}