summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/a2a-sdk/default.nix
blob: 347dbb2c2317f57f553d7f1094882c4adcaa3c9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
{
  lib,
  aiosqlite,
  buildPythonPackage,
  cryptography,
  fastapi,
  fetchFromGitHub,
  google-api-core,
  grpcio-reflection,
  grpcio-tools,
  grpcio,
  hatchling,
  httpx-sse,
  httpx,
  opentelemetry-api,
  opentelemetry-sdk,
  protobuf,
  pydantic,
  pyjwt,
  pytest-asyncio,
  pytest-cov-stub,
  pytest-timeout,
  pytest-xdist,
  pytestCheckHook,
  pythonAtLeast,
  respx,
  sqlalchemy,
  sse-starlette,
  starlette,
  uv-dynamic-versioning,
  uvicorn,
}:

buildPythonPackage (finalAttrs: {
  pname = "a2a-sdk";
  version = "0.3.26";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "a2aproject";
    repo = "a2a-python";
    tag = "v${finalAttrs.version}";
    hash = "sha256-OQVNoKCx/7t3LeLgcVCVJUDnrWnugbM6EReE0713CM4=";
  };

  build-system = [
    hatchling
    uv-dynamic-versioning
  ];

  dependencies = [
    google-api-core
    httpx
    httpx-sse
    protobuf
    pydantic
  ];

  optional-dependencies = {
    encryption = [ cryptography ];
    grpc = [
      grpcio
      grpcio-reflection
      grpcio-tools
    ];
    http-server = [
      fastapi
      sse-starlette
      starlette
    ];
    mysql = [
      sqlalchemy
    ]
    ++ sqlalchemy.optional-dependencies.asyncio
    ++ sqlalchemy.optional-dependencies.postgresql_asyncpg;
    postgresql = [
      sqlalchemy
    ]
    ++ sqlalchemy.optional-dependencies.asyncio
    ++ sqlalchemy.optional-dependencies.postgresql_asyncpg;
    signing = [ pyjwt ];
    sqlite = [
      sqlalchemy
    ]
    ++ sqlalchemy.optional-dependencies.asyncio
    ++ sqlalchemy.optional-dependencies.aiosqlite;
    telemetry = [
      opentelemetry-api
      opentelemetry-sdk
    ];
  };

  nativeCheckInputs = [
    aiosqlite
    pytest-asyncio
    pytest-cov-stub
    pytest-timeout
    pytest-xdist
    pytestCheckHook
    respx
    uvicorn
  ]
  ++ lib.flatten (builtins.attrValues finalAttrs.passthru.optional-dependencies);

  pythonImportsCheck = [ "a2a" ];

  disabledTests = lib.optionals (pythonAtLeast "3.14") [
    # _pickle.PicklingError: Can't pickle local object <function...
    "test_notification_triggering"
  ];

  meta = {
    description = "Python SDK for the Agent2Agent (A2A) Protocol";
    homepage = "https://github.com/a2aproject/a2a-python";
    changelog = "https://github.com/a2aproject/a2a-python/blob/${finalAttrs.src.tag}/CHANGELOG.md";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ fab ];
  };
})