# Contributor: Iztok Fister, Jr. <iztok@iztok-jr-fister.eu>
# Maintainer: Iztok Fister, Jr. <iztok@iztok-jr-fister.eu>
pkgname=py3-cdsapi
_pkgorig=cdsapi
pkgver=0.7.4
pkgrel=0
pkgdesc="Python API to access the Copernicus Climate Data Store"
url="https://github.com/ecmwf/cdsapi"
arch="noarch"
license="Apache-2.0"
depends="py3-cads-api-client py3-requests py3-tqdm py3-setuptools"
makedepends="py3-gpep517 py3-wheel"
checkdepends="py3-pytest-xdist"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://files.pythonhosted.org/packages/source/c/cdsapi/cdsapi-$pkgver.tar.gz"
builddir="$srcdir/$_pkgorig-$pkgver"
options="!check" # we need API key for test

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest -n auto
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
8ec2e976accb96813e8db087876f8cec7a8e2c09d74efb668484b711cc9830692b7ce5aed7a47545aecd5316c494f2146ebeb64a795940439551af29205c7860  py3-cdsapi-0.7.4.tar.gz
"
