# Contributor: Kevin Daudt <kdaudt@alpinelinux.org>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=py3-geoip2
pkgver=5.0.1
pkgrel=0
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="
44f37896dc73723c0f0a789661ac15d84a4ea9c30e92dbc9ac1746917b45c0e33fb7dc41a99d386e78bba580f9a5b1963b583e54ef7a09acc7c700082b6195db  py3-geoip2-5.0.1.tar.gz
a028b07cfdb84b98629e66937472feb291e0c022cf226513d765b21c420672620ff00b9004aa4cf1519d76a428a33600c453335e2fa9832e78e4621307b5723b  MaxMind-DB-test-data-1271107ccad72c320bc7dc8aefd767cba550101a.tar.gz
"
