# Maintainer: Luke Shumaker <lukeshu@parabola.nu>
# Maintainer (aur): Hao Zhang <hao at hao-zhang com>
# Contributor: Rich Li <rich at dranek com>
# Contributor: Samed Beyribey <ras0ir AT eventualis DOT org>

pkgname=python-pyspf
_pkgname=${pkgname#python-}
pkgver=2.0.14
pkgrel=3
pkgdesc="Python implementation of the Sender Policy Framework (SPF) protocol"
arch=('any')
url="https://pypi.python.org/pypi/${_pkgname}"
license=('PSF')

makedepends=('python-build' 'python-installer' 'python-wheel' 'python-setuptools')
depends=('python-py3dns')
checkdepends=('python-yaml' 'python-authres')
optdepends=('python-authres: Return RFC 5451 Authentication Results headers')

source=("https://files.pythonhosted.org/packages/d4/dc/5b3838ff90474e21fe0914920c53430f73402e07d6598ea228e61b74963e/${_pkgname}-$pkgver.tar.gz")
sha256sums=('57a7ef01bda090173aafb6af0106251686ed73f03db4e911fcd34c57fc347186')

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

check() {
  cd "$_pkgname-$pkgver/test"
  PYTHONPATH=../build/lib python testspf.py
}

package() {
  _python_version=$(pacman -S --print-format='%v' python|cut -d- -f1|cut -d. -f1,2)
  depends+=("python>=${_python_version}" "python<${_python_version%.*}.$(( ${_python_version##*.} + 1 ))")

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