# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>
# Maintainer: Jaroslav Lichtblau <svetlemodry@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Daniel Micay <danielmicay@gmail.com>

pkgname=python-pygit2
pkgver=1.6.1
pkgrel=2
pkgdesc='Python bindings for libgit2'
arch=('x86_64')
url="https://github.com/libgit2/pygit2"
license=('GPL2')
depends=('libgit2>=1:0.27.0' 'python-cffi' 'python-six' 'python-cached-property')
makedepends=('python-cffi' 'python-setuptools' 'git' 'python-six')
checkdepends=('python-pytest-runner')
source=("$pkgname-$pkgver.tar.gz"::$url/archive/v$pkgver.tar.gz
        "https://raw.githubusercontent.com/Homebrew/formula-patches/bf370d7782f7686a4a61d8d7d28068e78e28e48c/pygit2/libgit2-1.2.0.patch")
sha256sums=('2e3fe066bb9a94694e6f87a54f28fffc3ff834fe3b1ff62036f4c9ec8aad1846'
            'b5acca41ff7752ea25adb050d7494939fc6d471f4f91d94a06f4afc9902f4117')

prepare() {
	cd "pygit2-$pkgver"
	# Upstream Issue: https://github.com/libgit2/pygit2/pull/1089
	patch -p1 < ../libgit2-1.2.0.patch
	# Disable tests that do stuff online
	sed -i -e '/has_network/s/True/False/' test/utils.py
}

build() {
	cd "pygit2-$pkgver"
	python setup.py build
}

check() {
	cd "pygit2-$pkgver"
	python setup.py pytest
}

package() {
	cd "pygit2-$pkgver"
	LANG=en_US.UTF8 python setup.py install --root="${pkgdir}" --optimize=1
}
