# $Id: PKGBUILD 142504 2015-10-01 16:07:42Z fyan $
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Blackleg <blacklg@openaliasbox.org>
# Contributor: Nidhogg
# Contributor: juantascon

pkgname=python-peewee
pkgname=('python-peewee' 'python2-peewee')
pkgver=2.6.4
pkgrel=1
pkgdesc="a little orm"
url="https://pypi.python.org/pypi/peewee/"
arch=('i686' 'x86_64')
license=('MIT')
makedepends=('python-setuptools' 'python2-setuptools' 'cython' 'cython2' 'git')
checkdepends=('python-apsw' 'python2-apsw' 'python-flask' 'python2-flask')
source=("git+https://github.com/coleifer/peewee.git#tag=$pkgver")
sha256sums=('SKIP')

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

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

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

check() {
  cd "$srcdir/peewee"
  python runtests.py -a

  cd "$srcdir/peewee-py2"
  python2 runtests.py -a
}

package_python-peewee() {
  depends=('python')
  optdepends=('python-psycopg2: for PostgreSQL database support'
              'mysql-python: for MySQL database support')

  cd "$srcdir/peewee"
  python setup.py install --root="$pkgdir" --optimize=1
  install -D -m644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

package_python2-peewee() {
  depends=('python2')
  optdepends=('python2-psycopg2: for PostgreSQL database support')

  cd "$srcdir/peewee-py2"
  python2 setup.py install --root="$pkgdir" --optimize=1
  install -D -m644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  mv "$pkgdir/usr/bin/"pwiz{,2}.py
}
