# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>

pkgname=python-requests
_name=${pkgname#python-}
pkgver=2.31.0
pkgrel=3
pkgdesc='Python HTTP for Humans'
arch=(any)
url=https://requests.readthedocs.io/
license=(Apache-2.0)
depends=(
  ca-certificates
  python-charset-normalizer
  python-idna
  python-urllib3
)
makedepends=(git python-build python-installer python-setuptools python-wheel)
checkdepends=(
  python-pysocks
  python-pytest-httpbin
  python-pytest-mock
  python-trustme
)
optdepends=(
  'python-chardet: alternative character encoding library'
  'python-pysocks: SOCKS proxy support'
)
source=(
  "git+https://github.com/psf/$_name.git#tag=v$pkgver?signed"
  certs.patch
)
b2sums=('228f60a657807b14bb8d316ecdf60d2b908dfaaa3f94f795a08cbc4dd60c9524d190c2baf5ad147d604f7d09f125f8bbabd1ff423a62d52a620796933ae22744'
        'b6a7c9796a8ffedebcdbf0d2f95c40b1bbfa0beb45a3c7d5b493a459c4516533992291c720cf02e291cdbbf554dd0bf25c1312f4be41e39acd586b41911ad5b0')
validpgpkeys=('87227E29AD9CFF5CFAC3EA6A44D3FF97B80DC864') # Nathanael Prewitt <nate.prewitt@gmail.com>

prepare() {
  cd "$_name"
  # Pytest 8 compat https://github.com/psf/requests/issues/6679
  git cherry-pick --no-commit cc23d1c6445d61c1e6905cae4861d6e3c3244274

  sed -i '/certifi/d' setup.py
  patch -p1 -i ../certs.patch
}

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

check() {
  cd "$_name"
  pytest tests
}

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

# vim: ts=2 sw=2 et:
