# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=py-ldap3
_pkgname=ldap3
pkgver=2.3
pkgrel=0
pkgdesc="A strictly RFC 4510 conforming LDAP V3 pure Python client"
url="https://github.com/cannatag/ldap3"
arch="noarch"
license="LGPL3"
depends="py-asn1"
makedepends="python2-dev python3-dev py-setuptools"
subpackages="py2-$_pkgname:_subpackage py3-$_pkgname:_subpackage"
source="$pkgname-$pkgver.tar.gz::https://github.com/cannatag/$_pkgname/archive/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"
options="!check"  # tests need running LDAP server

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

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

_subpackage() {
	local pyver="${subpkgname:2:1}"
	local python="python$pyver"
	pkgdesc="$pkgdesc (for $python)"
	depends="$python ${depends//py-/py$pyver-}"
	install_if="$pkgname=$pkgver-r$pkgrel $python"

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

sha512sums="02b3d9af02d5073a84cc6137e5ca6dd53afbb893631da8b13158d694c28d4e7b4e7c9f0fd9419695682f9d0f5b456e6496eba26162cc8007cc0cfac238552d5a  py-ldap3-2.3.tar.gz"