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