# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Fabian Affolter <fabian@affolter-engineering.ch>
pkgname=py-tempita
_pkgname=Tempita
pkgver=0.5.2
pkgrel=4
pkgdesc="A small templating language"
url="https://pypi.python.org/pypi/Tempita"
arch="noarch"
license="MIT"
makedepends="python2-dev py-setuptools python3-dev"
subpackages="py3-${pkgname/py-/}:_py3 py2-${pkgname/py-/}:_py2"
options="!check" #no testsuite
source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

prepare() {
	default_prepare

	local pyver; for pyver in 2 3; do
		cp -r "$builddir" "$builddir-$pyver"
	done
}

build() {
	cd "$builddir-2"
	python2 setup.py build

	cd "$builddir-3"
	2to3 -w .
	python3 setup.py build
}

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

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

_py3() {
	_py python3
}

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

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

md5sums="4c2f17bb9d481821c41b6fbee904cea1  Tempita-0.5.2.tar.gz"
sha256sums="cacecf0baa674d356641f1d406b8bff1d756d739c46b869a54de515d08e6fc9c  Tempita-0.5.2.tar.gz"
sha512sums="582d3ca35dfb2ad44491cf9e526db9f9c34c419f2b03a5ce86a7e5183f7760b380262367c062161d577c3fb3e69e39ee99bbf8e493873e1da1a350ef2f63630d  Tempita-0.5.2.tar.gz"
