# Contributor: Kevin Daudt <kdaudt@alpinelinux.org>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=py3-geoip2
pkgver=4.8.0
pkgrel=1
pkgdesc="API for the GeoIP2 web services and databases"
options="!check" # Requires unpackaged mocket
url="https://www.maxmind.com/en/home"
arch="noarch"
license="Apache-2.0"
depends="py3-requests py3-maxminddb py3-aiohttp py3-urllib3"
makedepends="python3-dev py3-gpep517 py3-wheel libmaxminddb-dev py3-setuptools"
checkdepends="py3-nose py3-mock"
_test_data_commit=1271107ccad72c320bc7dc8aefd767cba550101a
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/maxmind/GeoIP2-python/archive/v$pkgver.tar.gz
	MaxMind-DB-test-data-$_test_data_commit.tar.gz::https://github.com/maxmind/MaxMind-DB/archive/$_test_data_commit.tar.gz"
builddir="$srcdir/GeoIP2-python-$pkgver"

prepare() {
	cd "$srcdir"

	# Submodule required for tests
	cp -r "MaxMind-DB-$_test_data_commit/" -T "$builddir/tests/data"
	default_prepare
}

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

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

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

sha512sums="
e22fac4c5016d6bc17a2e7902ea61f5ac43526a3d86c21a3199a409d084fd7a60001ed553a2c3d355636a06a73baad15014dc0ed41e5bb0eb93cefde5a14509e  py3-geoip2-4.8.0.tar.gz
a028b07cfdb84b98629e66937472feb291e0c022cf226513d765b21c420672620ff00b9004aa4cf1519d76a428a33600c453335e2fa9832e78e4621307b5723b  MaxMind-DB-test-data-1271107ccad72c320bc7dc8aefd767cba550101a.tar.gz
"
