# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Maintainer:
pkgname=py-itypes
_pkgreal=${pkgname#*-}
pkgver=1.1.0
pkgrel=1
pkgdesc="Basic immutable container types for Python"
url="https://github.com/tomchristie/itypes"
arch="noarch"
license="BSD"
depends=""
makedepends="python2-dev python3-dev py2-setuptools"
checkdepends="py2-flake8 py3-flake8 py2-pytest py3-pytest py-enum34
	py2-pycodestyle py3-pycodestyle py2-pyflakes py3-pyflakes"
subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3"
source="$pkgname-$pkgver.tar.gz::https://github.com/tomchristie/itypes/archive/$pkgver.tar.gz
	disable-flake8.patch"
builddir="$srcdir"/$_pkgreal-$pkgver

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

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

check() {
	cd "$builddir"
	python2 runtests
	python3 runtests
}

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

_py3() {
	depends="${depends//py-/py3-}"
	_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 --quiet install --prefix=/usr --root="$subpkgdir"
}

sha512sums="2f6dd5d655f1031059df8dcfd0a2f76875796a800144e887fb66cb5585949097edb6b9f5e973de2280f43cfeb25ab99d3ca428372fe239c8cd70f385304bcdd7  py-itypes-1.1.0.tar.gz
71421f34cf7c4303a2bb8dbbe48d7098f183ce41ed7bf454efa199d031a88c54c84a93eb84d0fa14b8231086709d2949eec7b6bbdb55af7aae4d62a734056d69  disable-flake8.patch"
