1{
2 lib,
3 aiohttp,
4 anyio,
5 buildPythonPackage,
6 dirty-equals,
7 distro,
8 fetchFromGitHub,
9 hatch-fancy-pypi-readme,
10 hatchling,
11 httpx-aiohttp,
12 httpx,
13 nest-asyncio,
14 pydantic,
15 pytest-asyncio,
16 pytest-xdist,
17 pytestCheckHook,
18 respx,
19 sniffio,
20 typing-extensions,
21}:
22
23buildPythonPackage rec {
24 pname = "groq";
25 version = "0.32.0";
26 pyproject = true;
27
28 src = fetchFromGitHub {
29 owner = "groq";
30 repo = "groq-python";
31 tag = "v${version}";
32 hash = "sha256-31doHBwdZWlEb1tk0OjfLciPhde0kfiMY6heiXDvnWI=";
33 };
34
35 postPatch = ''
36 substituteInPlace pyproject.toml \
37 --replace-fail "hatchling==1.26.3" \
38 "hatchling>=1.26.3"
39 '';
40
41 build-system = [
42 hatch-fancy-pypi-readme
43 hatchling
44 ];
45
46 dependencies = [
47 anyio
48 distro
49 httpx
50 pydantic
51 sniffio
52 typing-extensions
53 ];
54
55 optional-dependencies = {
56 aiohttp = [
57 aiohttp
58 httpx-aiohttp
59 ];
60 };
61
62 nativeCheckInputs = [
63 dirty-equals
64 nest-asyncio
65 pytest-asyncio
66 pytest-xdist
67 pytestCheckHook
68 respx
69 ]
70 ++ lib.flatten (builtins.attrValues optional-dependencies);
71
72 pythonImportsCheck = [ "groq" ];
73
74 disabledTests = [
75 # Tests require network access
76 "test_method"
77 "test_streaming"
78 "test_raw_response"
79 "test_copy_build_request"
80 ];
81
82 meta = {
83 description = "Library for the Groq API";
84 homepage = "https://github.com/groq/groq-python";
85 changelog = "https://github.com/groq/groq-python/blob/${src.tag}/CHANGELOG.md";
86 license = lib.licenses.asl20;
87 maintainers = with lib.maintainers; [
88 fab
89 sarahec
90 ];
91 };
92}