# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: Felix Yan <felixonmars@archlinux.org>

_name=google-auth-library-python
pkgname=python-google-auth
pkgver=2.29.0
pkgrel=2
pkgdesc="Google Authentication Library"
url="https://github.com/GoogleCloudPlatform/google-auth-library-python"
license=('Apache-2.0')
arch=('any')
depends=(
  'python'
  'python-cachetools'
  'python-certifi'  # somehow implicitly required in google/auth/transport/urllib3.py
  'python-oauth2client'  # somehow implicitly required in google/auth/_oauth2client.py
  'python-packaging'  # somehow implicitly required in google/auth/transport/urllib3.py
  'python-pyasn1-modules'
  'python-rsa'
)
makedepends=(
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)
checkdepends=(
  'python-cryptography'
  'python-flask'
  'python-freezegun'
  'python-oauth2client'
  'python-requests'
  'python-pyopenssl'
  'python-pyu2f'
  'python-pytest'
  'python-pytest-localserver'
  'python-responses'
)
optdepends=(
  'python-aiohttp: for async HTTP support'
  'python-cryptography: for TLS support'
  'python-pyopenssl: for TLS support'
  'python-pyu2f: for reauthentication support'
  'python-requests: for async HTTP support'
)
source=(
  "$url/archive/v$pkgver/$pkgname-$pkgver.tar.gz"
  $pkgname-2.28.0-remove_mock.patch
)
sha512sums=('235722f7172d8c62df8e141e25475ce7e2d7731b383f6ce68d85bcabe57cbe048c6e63191d3ba22e3db07bc6eb8e7e64d43f398596cb17d8737356ca404f700b'
            'a6f33be9b95107e9f7aae6ac3cf70c3da6711baa1a1f5b34b4b0b421e5d5191f68acdbbece6d413a4011ba16caa10a2988ed478441f39abf539dc0598ebd9324')

prepare() {
  # backport patch to remove python-mock: https://github.com/googleapis/google-auth-library-python/pull/1361
  patch -Np1 -d $_name-$pkgver -i ../$pkgname-2.28.0-remove_mock.patch
}

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd $_name-$pkgver
  python -m pytest tests
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
}
