# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=gcs-oauth2-boto-plugin
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.0
pkgrel=3
pkgdesc="Auth plugin allowing use the use of OAuth 2.0 credentials for Google Cloud Storage in the Boto library. (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://developers.google.com/storage/docs/gspythonlibrary'
msys2_references=(
  'pypi: gcs-oauth2-boto-plugin'
)
license=('spdx:Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-rsa"
         "${MINGW_PACKAGE_PREFIX}-python-boto"
         "${MINGW_PACKAGE_PREFIX}-python-google-reauth"
         "${MINGW_PACKAGE_PREFIX}-python-httplib2"
         "${MINGW_PACKAGE_PREFIX}-python-oauth2client"
         "${MINGW_PACKAGE_PREFIX}-python-pyopenssl"
         "${MINGW_PACKAGE_PREFIX}-python-retry-decorator"
         "${MINGW_PACKAGE_PREFIX}-python-six")
makedepends=("${MINGW_PACKAGE_PREFIX}-python"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('f4120b08b7f8d32904674c98f07d4caf4083a58343c0c0fa0016e0f0254dfe31')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  sed -e "s|rsa==4.7.2|rsa|g" -i setup.py
}

build() {
  cd "${srcdir}"
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  "${MINGW_PREFIX}"/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  "${MINGW_PREFIX}"/bin/python setup.py check
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  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"
}
