1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build
7 setuptools,
8 cmake,
9 pkg-config,
10
11 # dependencies
12 libpulsar,
13 pybind11,
14 certifi,
15
16 # optional dependencies
17 fastavro,
18 grpcio,
19 prometheus-client,
20 protobuf,
21 ratelimit,
22
23 # test
24 unittestCheckHook,
25}:
26
27buildPythonPackage rec {
28 pname = "pulsar-client";
29 version = "3.8.0";
30 pyproject = true;
31
32 src = fetchFromGitHub {
33 owner = "apache";
34 repo = "pulsar-client-python";
35 tag = "v${version}";
36 hash = "sha256-0EeQiYEYdER6qPQUYsk/OwYKiPWG0oymG5eiB01Oysk=";
37 };
38
39 build-system = [
40 setuptools
41 ];
42
43 nativeBuildInputs = [
44 cmake
45 pkg-config
46 ];
47
48 buildInputs = [
49 libpulsar
50 pybind11
51 ];
52
53 preBuild = ''
54 make -j$NIX_BUILD_CORES
55 make install
56 cd ..
57 '';
58
59 dependencies = [ certifi ];
60
61 optional-dependencies = {
62 functions = [
63 # apache-bookkeeper-client
64 grpcio
65 prometheus-client
66 protobuf
67 ratelimit
68 ];
69 avro = [ fastavro ];
70 all = lib.flatten (lib.attrValues (lib.filterAttrs (n: v: n != "all") optional-dependencies));
71 };
72
73 nativeCheckInputs = [
74 unittestCheckHook
75 ]
76 ++ optional-dependencies.all;
77
78 unittestFlagsArray = [
79 "-s"
80 "test"
81 ];
82
83 pythonImportsCheck = [ "pulsar" ];
84
85 __darwinAllowLocalNetworking = true;
86
87 meta = {
88 description = "Apache Pulsar Python client library";
89 homepage = "https://pulsar.apache.org/docs/next/client-libraries-python/";
90 changelog = "https://github.com/apache/pulsar-client-python/releases/tag/${src.tag}";
91 license = lib.licenses.asl20;
92 maintainers = with lib.maintainers; [ gaelreyrol ];
93 };
94}