# Contributor: Peter Bui <pnutzh4x0r@gmail.com>
# Maintainer: Fabian Affolter <fabian@affolter-engineering.ch>
pkgname=py-pep8
_pkgname=pep8
pkgver=1.7.1
pkgrel=0
pkgdesc="A Python style guide checker"
url="https://pypi.python.org/pypi/pep8/"
arch="noarch"
license="MIT"
makedepends="python2-dev python3-dev py-setuptools"
subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3"
options="!check"  # no testsuite
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
}

package() {
	cd "$builddir"

	mkdir -p "$pkgdir"/usr/bin
	ln -s pep8-3 "$pkgdir"/usr/bin/pep8
}

_py2() {
	replaces=$pkgname
	provides="$pkgname=$pkgver-r$pkgrel"
	_py python2
}

_py3() {
	_py python3
}

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

	cd "$builddir"
	$python setup.py --quiet install --prefix=/usr --root="$subpkgdir"
	local path; for path in "$subpkgdir"/usr/bin/*; do
		mv "$path" "$path-$pyver"
	done
}

sha512sums="d20d6a6f91bc865580e3d39c50e26f9c6be81fd8e80a1b9a029d7ea9c906748e46080b841dc5507004089e5ee0d0cb3f70a74bb35131c58113ff5571153af4da  pep8-1.7.1.tar.gz"
