# Maintainer: David Runge <dvzrv@archlinux.org>
# Maintainer: Christian Heusel <gromit@archlinux.org>
# Contributor: Eli Schwartz <eschwartz@archlinux.org>

_name=cachecontrol
pkgname=python-cachecontrol
pkgver=0.14.4
pkgrel=1
epoch=1
pkgdesc="Port of the caching algorithms in httplib2 for use with requests session object"
arch=(any)
url="https://github.com/ionrock/cachecontrol"
license=(Apache-2.0)
depends=(
  python
  python-filelock
  python-msgpack
  python-requests
  python-urllib3
)
makedepends=(
  python-build
  python-uv-build
  python-installer
  python-wheel)
checkdepends=(
  python-cherrypy
  python-pytest
  python-redis
)
optdepends=(
  'python-lockfile: for filecache'
  'python-redis: for redis cache'
)
source=($_name-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz)
sha256sums=('d862b0f313c852c618510fbce464b5eb58b02dbe3a146952c5a7b7cb4957431d')
b2sums=('ee12d64ec215714b376ac48eeb07d4861f8221755d7f016c5a48970bdacc85d01209d845984e344d9a0b6a1fa9a42dc24e2bb383d136f18c5e2ff440dee87ddc')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  pytest -vv
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "$pkgdir/usr/share/doc/$pkgname/"
}
