# Maintainer: opal hart <opal@wowana.me>
pkgname=py3-keyring
pkgver=24.3.1
pkgrel=2
pkgdesc="Access the system keyring service from Python"
url="https://github.com/jaraco/keyring"
arch="noarch"
license="MIT"
depends="
	py3-importlib-metadata
	py3-jaraco.classes
	py3-jeepney
	py3-secretstorage
	python3
	"
makedepends="py3-setuptools py3-gpep517 py3-installer py3-wheel py3-setuptools_scm py3-shtab"
checkdepends="py3-pytest"
subpackages="
	$pkgname-pyc
	$pkgname-bash-completion
	$pkgname-zsh-completion
"
source="https://files.pythonhosted.org/packages/source/k/keyring/keyring-$pkgver.tar.gz"
builddir="$srcdir/keyring-$pkgver"

export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver

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

	python3 -m venv --clear --without-pip --system-site-packages .tempenv
	.tempenv/bin/python3 -m installer .dist/keyring-$pkgver-py3-none-any.whl
	.tempenv/bin/keyring --print-completion zsh > keyring.bash
	.tempenv/bin/keyring --print-completion zsh > keyring.zsh
}

check() {
	pytest
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/keyring-$pkgver-py3-none-any.whl

	install -Dm 644 keyring.bash "$pkgdir/usr/share/bash-completion/completions/keyring"
	install -Dm 644 keyring.zsh "$pkgdir/usr/share/zsh/site-functions/_keyring"
}

sha512sums="
53f26763175c7f1de041d8805062696ef3ef6c79792cdc75ae72621da8e729ac4cbb6e76937db2a0a5ce4bc41ab92c164d62e4627f92edab8c0d0fc02ca4980e  keyring-24.3.1.tar.gz
"
