1{
2 lib,
3 anyio,
4 buildPythonPackage,
5 dirty-equals,
6 distro,
7 fetchFromGitHub,
8 google-auth,
9 hatch-fancy-pypi-readme,
10 hatchling,
11 httpx,
12 jiter,
13 pydantic,
14 pytest-asyncio,
15 pytestCheckHook,
16 pythonOlder,
17 respx,
18 sniffio,
19 tokenizers,
20 typing-extensions,
21}:
22
23buildPythonPackage rec {
24 pname = "anthropic";
25 version = "0.31.2";
26 pyproject = true;
27
28 disabled = pythonOlder "3.8";
29
30 src = fetchFromGitHub {
31 owner = "anthropics";
32 repo = "anthropic-sdk-python";
33 rev = "refs/tags/v${version}";
34 hash = "sha256-cKXOIVpF+CZ542JX9flQYKSrdYkSVeNESUztB6yaATQ=";
35 };
36
37 build-system = [
38 hatchling
39 hatch-fancy-pypi-readme
40 ];
41
42 dependencies = [
43 anyio
44 distro
45 httpx
46 jiter
47 sniffio
48 pydantic
49 tokenizers
50 typing-extensions
51 ];
52
53 passthru.optional-dependencies = {
54 vertex = [ google-auth ];
55 };
56
57 nativeCheckInputs = [
58 dirty-equals
59 pytest-asyncio
60 pytestCheckHook
61 respx
62 ];
63
64 pythonImportsCheck = [ "anthropic" ];
65
66 disabledTests = [
67 # Test require network access
68 "test_copy_build_request"
69 ];
70
71 disabledTestPaths = [
72 # Test require network access
73 "tests/api_resources"
74 "tests/lib/test_bedrock.py"
75 ];
76
77 pytestFlagsArray = [
78 "-W"
79 "ignore::DeprecationWarning"
80 ];
81
82 meta = with lib; {
83 description = "Anthropic's safety-first language model APIs";
84 homepage = "https://github.com/anthropics/anthropic-sdk-python";
85 changelog = "https://github.com/anthropics/anthropic-sdk-python/releases/tag/v${version}";
86 license = licenses.mit;
87 maintainers = with maintainers; [ natsukium ];
88 };
89}