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