# Maintainer: Corentin Henry <corentinhenry@gmail.com>
# Contributor: Corentin Henry <corentinhenry@gmail.com>
setvar pkgname = 'py-protobuf'
setvar _pkgname = ${pkgname#py-}
setvar pkgver = '3.2.0'
setvar pkgrel = '0'
setvar pkgdesc = ""Google's data interchange format.""
setvar url = ""https://github.com/google/protobuf""
setvar arch = ""noarch""
setvar license = ""BSD""
setvar depends = ""py-six>=1.9""
setvar makedepends = ""python2-dev python3-dev py-setuptools py-google-apputils""
setvar subpackages = ""py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3""
setvar source = ""$pkgname-$pkgver.tar.gz::https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz""
setvar builddir = ""$srcdir"/protobuf-$pkgver"

proc build {
	cd $builddir
	python2 setup.py build || return 1
	python3 setup.py build || return 1
}

proc package {
	mkdir -p $pkgdir
}

proc _py2 {
	setvar replaces = "$pkgname"
	setvar depends = "${depends//py-/py2-}"
	_py python2
}

proc _py3 {
	setvar depends = "${depends//py-/py3-}"
	_py python3
}

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

	cd $builddir
	$python setup.py install --prefix=/usr --root="$subpkgdir"
	# correct permissions
	chmod +r "$subpkgdir"/usr/lib/*/site-packages/*/*
}

setvar sha512sums = ""d20ecd17712ff66033f73747d789fdb0b8b46f692e6655608a6c1c141fa4f9f489dfccd91653c6876b12b40309c7a462a8c1024e2161e01041f2859f4353dedd  py-protobuf-3.2.0.tar.gz""