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

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

makedepends=('python-setuptools')
depends=('python-py3dns' 'python')
optdepends=('python-authres: Return RFC 5451 Authentication Results headers')

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

_version_constraint() # (dep_pkgname)
{
  local dep_pkgname=$1
  local version=$(pacman -S --print-format='%v' ${dep_pkgname} | tail -n 1)
  version=${version%-*}
  local version_inc=${version%.*}.$(( ${version##*.} + 1 ))

  echo -n "${dep_pkgname}>=${version}" "${dep_pkgname}<${version_inc}"
}


build() {
  cd "$srcdir/pyspf-$pkgver"

  python setup.py build
}

package() {
  depends+=( $(_version_constraint 'python') )

  cd "$srcdir/pyspf-$pkgver"

  python setup.py install --root="$pkgdir" --optimize=1
}
