summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 23be69bbf2c0c2aded4e375ff16b1d2263ba5fba (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
# Maintainer: Carl Smedstad <carsme@archlinux.org>

pkgname=python-anthropic
_pkgname=anthropic-sdk-python
pkgver=0.25.8
pkgrel=1
pkgdesc="Python library that provides convenient access to the Anthropic REST API"
arch=(any)
url="https://github.com/anthropics/anthropic-sdk-python"
license=(MIT)
depends=(
  python
  python-anyio
  python-distro
  python-httpx
  python-pydantic
  python-pydantic-core
  python-sniffio
  python-tokenizers
  python-typing_extensions
)
makedepends=(
  python-build
  python-hatch-fancy-pypi-readme
  python-hatchling
  python-installer
  python-wheel
)
checkdepends=(
  python-dirty-equals
  python-pytest
  python-pytest-asyncio
  python-respx
)
optdepends=(
  'python-boto3: for Anthropic Bedrock API support'
  'python-botocore: for Anthropic Bedrock API support'
  'python-google-auth: for Anthropic Vertex API support'
)
source=(
  "$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz"
  "fix-pytest-asyncio-usage.patch"
)
sha256sums=(
  'dcf220310e3fc50bf823b09378d243d3a56f878949c51ae0402ff57f66cd24d4'
  '9058cc717a6e8eebba65d9735e7376f9d1a024f0e4a2635b96278e6a39b31e01'
)

_archive="$_pkgname-$pkgver"

prepare() {
  cd "$_archive"

  patch --forward --strip=1 --input="$srcdir/fix-pytest-asyncio-usage.patch"
}

build() {
  cd "$_archive"

  python -m build --wheel --no-isolation
}

check() {
  cd "$_archive"

  rm -rf tmp_install
  python -m installer --destdir=tmp_install dist/*.whl

  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  export PYTHONPATH="$PWD/tmp_install/$site_packages"
  # Deselect tests/api_resources as it requires access to the API.
  # Also, deselect failing tests - not sure why they fail.
  pytest \
    --deselect tests/api_resources \
    --deselect tests/test_client.py::TestAnthropic::test_copy_build_request \
    --deselect tests/test_client.py::TestAnthropic::test_proxies_option_is_deprecated \
    --deselect tests/test_client.py::TestAsyncAnthropic::test_copy_build_request \
    --deselect tests/test_client.py::TestAsyncAnthropic::test_proxies_option_is_deprecated
}

package() {
  cd "$_archive"

  python -m installer --destdir="$pkgdir" dist/*.whl

  install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}