# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Maintainer: Fabian Affolter <fabian@affolter-engineering.ch>
pkgname=pytest
pkgver=3.5.0
pkgrel=0
pkgdesc="A python test library"
url="http://pytest.org"
arch="noarch"
license="MIT"
depends="py3-$pkgname"
makedepends="python2-dev py-setuptools python3-dev"
subpackages="py3-$pkgname:_py3 py2-$pkgname:_py2"
source="https://files.pythonhosted.org/packages/source/${pkgname:0:1}/$pkgname/$pkgname-$pkgver.tar.gz"
builddir="$srcdir/$pkgname-$pkgver"

build() {
	cd "$builddir"
	python2 setup.py build
	python3 setup.py build
}

check() {
	cd "$builddir"
	python2 setup.py check
	python3 setup.py check
}

package() {
	mkdir -p "$pkgdir"/usr/bin

	local name; for name in py.test pytest; do
		ln -s $name-3 "$pkgdir"/usr/bin/$name
	done
}

_py2() {
	replaces="$pkgname"
	depends="py2-py"
	_py python2
}

_py3() {
	depends="py3-py"
	_py python3
}

_py() {
	local python="$1"
	local pyver="${1:6:1}"
	pkgdesc="$pkgdesc (for $python)"
	depends="$depends $python"
	install_if="$pkgname=$pkgver-r$pkgrel $python"

	cd "$builddir"
	$python setup.py install --prefix=/usr --root="$subpkgdir"

	# Add version suffix to executable files.
	local path; for path in "$subpkgdir"/usr/bin/*; do
		mv "$path" "$path-$pyver"
	done
}

sha512sums="031997650592a5c5697981c517082a8de0f585b63e9fcba57903163c0e87ab6a4206f93038ecc130530422547bfc0e03f765c8f260e52e51f2f9e0cb26ceeaa8  pytest-3.5.0.tar.gz"
