# Contributor: Pierre-Gildas MILLON <pgmillon@gmail.com>
# Maintainer:
pkgname=py-pygit2
_pkgname=pygit2
pkgver=0.26.3
pkgrel=0
pkgdesc="Python bindings for libgit2"
url="https://github.com/libgit2/pygit2"
arch="all"
license="GPL-2.0-only-WITH-GCC-exception-2.0"
_pydepends="py-cffi py-six"
makedepends="$_pydepends python2-dev python3-dev py-setuptools
	libgit2-dev libssh2-dev libressl-dev"
subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3"
source="$pkgname-$pkgver.tar.gz::https://github.com/libgit2/$_pkgname/archive/v${pkgver}.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

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

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

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

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

_py3() {
	depends="${_pydepends//py-/py3-}"
	_py python3
}

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

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

sha512sums="d12c4f33b8bb19b76a459cfd67413532e38198aaf1108e57f4b2f25e6572a9e36354b62799d9c35ad9f1884da6d9ba654e7bf594a853e810c0da5e6430bd4ad1  py-pygit2-0.26.3.tar.gz"
