# Contributor: Ivan Tham <pickfire@riseup.net>
# Maintainer: Ivan Tham <pickfire@riseup.net>
setvar pkgname = 'py-xlib'
setvar _pkgname = 'python-xlib'
setvar pkgver = '0.20'
setvar pkgrel = '1'
setvar pkgdesc = ""A fully functional X client library for Python programs""
setvar url = ""https://github.com/python-xlib/python-xlib""
setvar arch = ""noarch""
setvar license = ""LGPL2""
setvar depends = ""py-six""
setvar checkdepends = ""xvfb""
setvar makedepends = ""python2-dev python3-dev py-setuptools""
setvar subpackages = ""${pkgname/py-/py3-}:_py3 ${pkgname/py-/py2-}:_py2""
setvar source = ""https://github.com/$_pkgname/$_pkgname/releases/download/$pkgver/$_pkgname-$pkgver.tar.bz2""
setvar builddir = ""$srcdir/$_pkgname-$pkgver""

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

proc check {
	cd $builddir
	Xvfb :1 &
	export DISPLAY=:1
	python2 setup.py test
	python3 setup.py test
}

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"
}

setvar sha512sums = ""7717832a8da13cde236143f4fc1b849b02e306b59cad6146db0a2fc6d19e9a9f60604110cceadd9a9041e013dcc4d67dcb1c2629e0ca44f9c69ed91d2a1c5adf  python-xlib-0.20.tar.bz2""