# Contributor: Peter Bui <pnutzh4x0r@gmail.com>
# Maintainer: William Pitcock <nenolod@dereferenced.org>
pkgname=py-asn1
_pkgname=pyasn1
pkgver=0.4.2
pkgrel=0
pkgdesc="A python ASN1 library"
url="http://pyasn1.sourceforge.net/"
arch="noarch"
license="BSD"
depends=""
makedepends="python2-dev py-setuptools python3-dev"
subpackages="py3-${pkgname#py-}:_py3 py2-${pkgname#py-}:_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 test
	python3 setup.py test
}

package() {
	mkdir -p "$pkgdir"
}

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

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

_py2() {
	replaces="$pkgname"
	_py python2
}

_py3() {
	_py python3
}

sha512sums="30e7cdfd2f7b182081f951bd94169a300a577f95fbfcb4ddb6dc288617b2776265018d246ae0adb649650ee94aab9122a428313d7a61559f97ed7f02b9670709  pyasn1-0.4.2.tar.gz"
