# Contributor: Rasmus Thomsen <oss@cogitri.dev>
maintainer="fossdd <fossdd@pwned.life>"
pkgname=py3-authlib
pkgver=1.6.0
pkgrel=0
pkgdesc="Python library for building OAuth and OpenID Connect servers"
url="https://github.com/lepture/authlib"
arch="noarch"
license="BSD-3-Clause"
depends="python3 py3-cryptography"
makedepends="py3-gpep517 py3-setuptools py3-wheel"
checkdepends="
	py3-cachelib
	py3-django
	py3-flask-sqlalchemy
	py3-httpx
	py3-pytest-asyncio
	py3-pytest-django
	py3-requests
	py3-starlette
	"
subpackages="$pkgname-pyc"
source="https://github.com/authlib/authlib/archive/refs/tags/v$pkgver/authlib-v$pkgver.tar.gz"
builddir="$srcdir/authlib-$pkgver"

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

check() {
	# django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS,
	# but settings are not configured. You must either define the environment variable
	# DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
	pytest \
		--ignore tests/django/test_oauth2/test_authorization_code_grant.py \
		--ignore tests/django/test_oauth2/test_client_credentials_grant.py \
		--ignore tests/django/test_oauth2/test_implicit_grant.py \
		--ignore tests/django/test_oauth2/test_password_grant.py \
		--ignore tests/django/test_oauth2/test_refresh_token.py \
		--ignore tests/django/test_oauth2/test_resource_protector.py \
		--ignore tests/django/test_oauth2/test_revocation_endpoint.py \
		--ignore tests/django/test_oauth1/test_authorize.py \
		--ignore tests/django/test_oauth1/test_resource_protector.py \
		--ignore tests/django/test_oauth1/test_token_credentials.py \
		--ignore tests/clients/test_django/test_oauth_client.py \
		--ignore tests/jose/test_chacha20.py
}

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

sha512sums="
5ff057fe9699b192218bf0863635230137fe1cb86129ba545b468f2df4491b475e81b6c296efd9965cfdb2cfc782f46bd49f93b1b222b5ce1f0b49145ef9ef45  authlib-v1.6.0.tar.gz
"
