# Maintainer: Drew DeVault <sir@cmpwn.com>
pkgname=py-tqdm
_pkgname=tqdm
pkgver=4.19.5
pkgrel=1
pkgdesc="Fast, Extensible Progress Meter"
url="https://pypi.python.org/pypi/tqdm"
arch="noarch"
license="MIT"
makedepends="python2-dev python3-dev py-setuptools"
subpackages="py3-${pkgname#py-}:_py3 py2-${pkgname#py-}:_py2"
source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz
	0001-Skip-flaky-test-that-depends-on-GNU-coreutils.patch
	0001-Import-sleep-nearer-to-usage.patch"
builddir="$srcdir/$_pkgname-$pkgver"

prepare() {
	default_prepare
	cd "$builddir"

	case "$CARCH" in
		# XXX: Perf tests fail on aarch64 builder.
		aarch64) rm tqdm/tests/tests_perf.py;;
	esac
}

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

check() {
	cd "$builddir"

	python2 setup.py test
	# Broken on our current Python build due to setuptools version conflict
	#python3 setup.py test
}

package() {
	mkdir -p "$pkgdir"/usr/bin
	ln -s tqdm-3 "$pkgdir"/usr/bin/tqdm
}

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

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

	cd "$subpkgdir"

	# Add version suffix to executable.
	mv usr/bin/tqdm usr/bin/tqdm-$pyver

	rm -r usr/man
}

_py2() {
	_py python2
}

_py3() {
	_py python3
}

sha512sums="fff1946466e109bf020a6dbaca7e99b992c0335bc4b380224e981b2e0690a5ef465fdd95ee9473bdc0f0381897c5314cee715c600708d02892e0a109e5b9dbbe  tqdm-4.19.5.tar.gz
3e94642970da68ec422f78ba8aa080832ab3b2d2cb66b137d79dccd71921d0bb8796f97828b1eedd5751502a816bbd6a6d66fae238bd9a6fbc46c58f93d69636  0001-Skip-flaky-test-that-depends-on-GNU-coreutils.patch
4d6b06028a8d8c4214dc57168fa50ccd19fea79b7099d5d695bf00a6e8f01ece76341dc992ce8bfb513140f3b425d29e428842a8ade417d758bf4c67474d65d0  0001-Import-sleep-nearer-to-usage.patch"
