# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: Karol 'Kenji Takahashi' Woźniak <kenji.sx>
# Contributor: Pierre Gueth <pierre.gueth@gmail.com>

pkgname=python-redis
pkgver=5.0.1
pkgrel=2
pkgdesc='The Python interface to the Redis key-value store'
arch=('any')
url='https://github.com/redis/redis-py'
license=('MIT')
depends=(
  'python'
  'python-async-timeout'
)
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-wheel'
  'python-setuptools'
)
optdepends=(
  'python-hiredis: faster performance via hiredis'
  'python-cryptography: OCSP certificate validation'
  'python-pyopenssl: OCSP certificate validation'
  'python-requests: OCSP certificate validation'
)
checkdepends=(
  'pifpaf'
  'redis'
  'python-pytest'
  'python-pytest-asyncio'
  'python-hiredis'
  'python-cryptography'
  'python-pyopenssl'
  'python-requests'
)
_commit='cc4bc1a544d1030aec1696baef2861064fa8dd1c'
source=("$pkgname::git+$url#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

build() {
  cd "$pkgname"

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

check() {
  cd "$pkgname"

  # tests/test_ssl.py requires SSL keys
  pifpaf run redis -- pytest --ignore tests/test_ssl.py || echo "Tests failed"
}

package() {
  cd "$pkgname"

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

  # symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir/usr/share/licenses/$pkgname"
  ln -s "$site_packages/${pkgname#python-}-$pkgver.dist-info/LICENSE" \
    "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

# vim:set ts=2 sw=2 et:
