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

_realname=requests-oauthlib
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.3.1
pkgrel=4
pkgdesc='"First-class OAuth library support for Requests (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/requests/requests-oauthlib"
msys2_references=(
  'pypi: requests-oauthlib'
)
license=('spdx:ISC')
depends=("${MINGW_PACKAGE_PREFIX}-python-oauthlib"
         "${MINGW_PACKAGE_PREFIX}-python-requests")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-mock"
              "${MINGW_PACKAGE_PREFIX}-python-requests-mock"
              "${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-pyjwt")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
options=('!emptydirs')
source=("https://github.com/requests/requests-oauthlib/archive/v$pkgver.tar.gz")
sha256sums=('2eeaa4764c58e78cb4334b3d748c08961e3ae5cb3d765e5d89854222a48e8d14')

export PBR_VERSION=$pkgver

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

build() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/py.test || warning "Tests failed"
}

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