# Maintainer: Thore Bödecker <foxxx0@archlinux.org>
# Maintainer: Carl Smedstad <carsme@archlinux.org>
# Contributor: Laurent Soest <laurent.soest@gmail.com>
# Contributor: Angel Velasquez <angvp@archlinux.org>
# Contributor: Kaiting Chen <kaitocracy@gmail.com>
# Contributor: Douglas Soares de Andrade <dsa@aur.archlinux.org>
# Contributor: Armando M. Baratti <amblistas@ajato.com.br>
# Contributor: Florian Richter <Florian_Richter@gmx.de>

pkgname='python-cherrypy'
_pkgname="${pkgname#python-}"
pkgver=18.10.0
pkgrel=2
pkgdesc='A pythonic, object-oriented web development framework'
arch=('any')
url='https://cherrypy.dev'
license=('BSD-3-Clause')
depends=(
  'python'
  'python-cheroot'
  'python-jaraco.collections'
  'python-more-itertools'
  'python-portend'
  'python-zc.lockfile'
)
makedepends=(
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-setuptools-scm'
  'python-wheel'
)
checkdepends=(
  'python-objgraph'
  'python-path'
  'python-pytest'
  'python-pytest-forked'
  'python-pytest-services'
  'python-pytest-sugar'
  'python-requests-toolbelt'
)
optdepends=(
  'python-flup: for xcgi support'
  'python-memcached: for memcached session support'
  'python-pyopenssl: for TLS support'
  'python-routes: for routes_dispatcher support'
  'python-simplejson: for JSON support'
)
source=("$pkgname-$pkgver.tar.gz::https://github.com/cherrypy/cherrypy/archive/v$pkgver.tar.gz")
sha512sums=('68d44e45037f924c0d3eda93780ee822087a28c9b0dae966e6e8b673479981d6fee0b75d819bc8c863d5085402625bb90afb32ef0ad4ab2f22fdb62ac0341a91')

build() {
  cd "$_pkgname-$pkgver"
  export SETUPTOOLS_SCM_PRETEND_VERSION="$pkgver"
  python -m build --wheel --no-isolation --skip-dependency-check
}

check() {
  cd "$_pkgname-$pkgver"
  local pytest_options=(
    -vv
    -o addopts=''        # we are not interested in coverage
    -o filterwarnings='' # we don't want to fail on warnings
    # fails with Python 3.12
    --deselect cherrypy/test/test_states.py::test_safe_wait_INADDR_ANY
  )
  pytest "${pytest_options[@]}"
}

package() {
  cd "$_pkgname-$pkgver"
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE.md
}
