# $Id: PKGBUILD 145496 2015-11-02 00:48:50Z fyan $
# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgbase=python-hypothesis
pkgname=('python-hypothesis' 'python2-hypothesis')
pkgver=1.14.0
pkgrel=1
pkgdesc="Advanced Quickcheck style testing library for Python"
arch=('any')
license=('MPL')
url="https://hypothesis.readthedocs.org"
makedepends=('python-setuptools' 'python2-setuptools' 'git')
checkdepends=('python-pytest-runner' 'python2-pytest-runner' 'flake8' 'python2-flake8'
              'python-pytz' 'python2-pytz' 'python-django' 'python2-django' 'python-numpy'
              'python2-numpy' 'python-fake-factory' 'python2-fake-factory' 'python-flaky'
              'python2-flaky')
source=("git+https://github.com/DRMacIver/hypothesis.git#tag=$pkgver")
sha512sums=('SKIP')

prepare() {
  cp -a hypothesis{,-py2}
}

build() {
  cd "$srcdir/hypothesis"
  python setup.py build

  cd "$srcdir/hypothesis-py2"
  python2 setup.py build
}

check() {(
  # I dunno how to fix pytest w/django tests :/

  cd "$srcdir/hypothesis"
  PYTHONPATH="$PWD/build/lib:$PYTHONPATH" LC_CTYPE=en_US.UTF-8 python setup.py ptr

  cd "$srcdir/hypothesis-py2"
  PYTHONPATH="$PWD/build/lib:$PYTHONPATH" LC_CTYPE=en_US.UTF-8 python2 setup.py ptr
  ) || warning "Tests failed"
}

package_python-hypothesis() {
  depends=('python')
  optdepends=('python-pytz: for datetime and django module'
              'python-fake-factory: for fakefactory and django module'
              'python-django: for django module'
              'python-numpy: for numpy module'
              'python-pytest: for pytest module')

  cd hypothesis
  python setup.py install --root="${pkgdir}" --optimize=1
}

package_python2-hypothesis() {
  depends=('python2')
  optdepends=('python2-pytz: for datetime and django module'
              'python2-fake-factory: for fakefactory and django module'
              'python2-django: for django module'
              'python2-numpy: for numpy module'
              'python2-pytest: for pytest module')

  cd hypothesis-py2
  python2 setup.py install --root="${pkgdir}" --optimize=1
}
