# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Sebastien Leduc <sebastien@sleduc.fr>
# Contributor: Roberto Catini <roberto.catini@gmail.com>

pkgname=python-requests-oauthlib
pkgver=2.0.0
pkgrel=1
pkgdesc='First-class OAuth library support for Requests'
arch=(any)
url='https://github.com/requests/requests-oauthlib'
license=(ISC)
depends=(
  python
  python-requests
  python-oauthlib
)
makedepends=(
  git
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(
  python-pytest
  python-requests-mock
  python-pyjwt
)
source=("$pkgname::git+$url#tag=v$pkgver")
sha512sums=('4823e0c027b5b07115530f30517c3cb2fe1841b283257f3a31e5f157edc78f601290ae88394d7011bdee742f08470ad6b9df6dfc3c313849955de069dede1b63')
b2sums=('84cd1506f72e078a5fbe963ba80ea9265ea9aa3801ab878bb35d5ecbdf77ebcbbfc84220c26ad27b5ee9d5ee1a29f82737053841568a4f5ea5761f7d5087ed03')

prepare() {
  cd "$pkgname"

  # fix rounding error in tests
  git cherry-pick --no-commit b1dd93c5d024500b6236dea06734d6e6482c3565
}

build() {
  cd "$pkgname"

  python -m build --wheel --no-isolation
}

check() {
  cd "$pkgname"

  local pytest_args=(
    --verbose
    # selenium? no thanks.
    --ignore tests/examples/base.py
    --ignore tests/examples/test_native_spa_pkce_auth0.py
  )

  pytest "${pytest_args[@]}"
}

package() {
  cd "$pkgname"

  python -m installer --destdir="$pkgdir" dist/*.whl

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
