# Maintainer: bill-auger <bill-auger@programmer.net>
# Maintainer (AUR): tocic <tocic at protonmail dot ch>
# Contributor: Carl George < arch at cgtx dot us >


#_check=1

pkgname=('python-falcon' 'python2-falcon')
pkgver=1.4.1
pkgrel=1
pkgdesc="An unladen web framework for building APIs and app backends."
arch=('i686' 'x86_64')
url=https://falconframework.org
license=('Apache')

makedepends=('cython' 'python-setuptools' 'cython2' 'python2-setuptools')
[[ -v ${_run_check} ]] && checkdepends=('python-pytest>=3.0.1' 'python-jsonschema'
                                        'python-msgpack' 'python-requests'
                                        'python-six>=1.4.0' 'python-testtools' 'python-yaml'
                                        'python2-pytest>=3.0.1' 'python2-jsonschema'
                                        'python2-msgpack' 'python2-requests'
                                        'python2-six>=1.4.0' 'python2-testtools' 'python2-yaml')

_upstream_name='falcon'
_release=${_upstream_name}-${pkgver}
source=(https://files.pythonhosted.org/packages/source/${_upstream_name:0:1}/${_upstream_name}/${_release}.tar.gz)
sha256sums=('3981f609c0358a9fcdb25b0e7fab3d9e23019356fb429c635ce4133135ae1bc4')


build()
{
  cd "${srcdir}/${_release}"

  python setup.py build
  python2 setup.py build
}

check()
{
  cd "${srcdir}/${_release}"

  if [[ -v _check ]] ; then pytest tests ; pytest2 tests ; fi ;
}

package_python-falcon()
{
  depends=('python-six>=1.4.0' 'python-mimeparse>=1.5.2')

  cd "${srcdir}/${_release}"

  python setup.py install --skip-build --root="${pkgdir}" --optimize=1
}

package_python2-falcon()
{
  depends=('python2-six>=1.4.0' 'python2-mimeparse>=1.5.2')

  cd "${srcdir}/${_release}"

  python2 setup.py install --skip-build --root="${pkgdir}" --optimize=1
  mv "${pkgdir}/usr/bin/falcon-bench"        "${pkgdir}/usr/bin/falcon-bench-python2"
  mv "${pkgdir}/usr/bin/falcon-print-routes" "${pkgdir}/usr/bin/falcon-print-routes-python2"
}
