# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=py-opencl
_pkgreal=${pkgname/-/}
pkgver=2017.2.2
pkgrel=0
pkgdesc="Python wrapper for OpenCL"
url="https://pypi.python.org/pypi/pyopencl"
arch="all !s390x"
license="MIT"
depends="py-mako"
makedepends="python2-dev python3-dev py-setuptools py-mako py-numpy ctags libffi-dev mesa-dev opencl-headers
		opencl-icd-loader-dev py-cparser py-cffi"
checkdepends="py-six py-decorator pytest py-py"
subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3"
source="https://files.pythonhosted.org/packages/source/${_pkgreal:0:1}/$_pkgreal/$_pkgreal-$pkgver.tar.gz"
builddir="$srcdir/$_pkgreal-$pkgver"
options="!check"  # FIXME: tests are broken (see commit message for details)

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

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

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

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

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

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

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

sha512sums="d9026d8c615e0b776baf6852e835bf2b7390e42d283095ab524deb05f69e7b86a39b6ab035046af924b705726f78805610370d2c9be65dd7ce20d5e273fb3904  pyopencl-2017.2.2.tar.gz"
