# Maintainer: Daniel M. Capella <polyzen@archlinux.org>

pkgname=python-aiodns
_name=${pkgname#python-}
pkgver=3.5.0
pkgrel=1
pkgdesc='Simple DNS resolver for asyncio'
arch=(any)
url=https://github.com/saghul/aiodns
license=(MIT)
depends=(python-pycares)
makedepends=(
  git
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(
  python-pytest
  python-pytest-asyncio
  python-uvloop
)
source=("git+$url.git#tag=v$pkgver")
b2sums=('86503334ff9b0f3c60b7b18ba2200d9ee7144fd49c79651376822635f941e0e70cedb1ca6191404b8fb63c0b7426088232b43ff108cb7c5f923ad482840054fb')

build() {
  cd "$_name"
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "$_name"
  # Override addopts as they invoke coverage testing
  PYTHONPATH=aiodns:$PYTHONPATH pytest --override-ini="addopts=" -v -k 'not test_gethostbyaddr'
}

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

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