# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=google-auth
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.31.0
pkgrel=1
pkgdesc='Google Authentication Library (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/GoogleCloudPlatform/google-auth-library-python"
license=('Apache')
depends=("${MINGW_PACKAGE_PREFIX}-ca-certificates" "${MINGW_PACKAGE_PREFIX}-python-cachetools" "${MINGW_PACKAGE_PREFIX}-python-pyasn1-modules" "${MINGW_PACKAGE_PREFIX}-python-rsa")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-mock" "${MINGW_PACKAGE_PREFIX}-python-requests" "${MINGW_PACKAGE_PREFIX}-python-flask" "${MINGW_PACKAGE_PREFIX}-python-oauth2client" "${MINGW_PACKAGE_PREFIX}-python-pytest-localserver" "${MINGW_PACKAGE_PREFIX}-python-cryptography" "${MINGW_PACKAGE_PREFIX}-python-freezegun" "${MINGW_PACKAGE_PREFIX}-python-responses" "${MINGW_PACKAGE_PREFIX}-python-pyopenssl")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
options=('!emptydirs')
source=("${_realname}-$pkgver.tar.gz::https://github.com/GoogleCloudPlatform/google-auth-library-python/archive/v$pkgver.tar.gz")
sha256sums=('2f3aa3d5db511a9664b8f004e8550204636c75f435f18a66247ca68d811f57ad')

prepare() {  
  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-library-python-${pkgver}" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python -m pytest tests || warning "Tests failed"
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
