# $Id: PKGBUILD 122344 2014-11-11 08:16:49Z fyan $
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Sebastien Leduc <sebastien@sleduc.fr>
# Contributor: Roberto Catini <roberto.catini@gmail.com>

pkgbase=python-requests-oauthlib
pkgname=('python-requests-oauthlib' 'python2-requests-oauthlib')
_pkgname=requests-oauthlib
pkgver=0.5.0
pkgrel=1
pkgdesc="First-class OAuth library support for Requests"
arch=('any')
url="https://pypi.python.org/pypi/requests-oauthlib"
license=('custom:ISC')
makedepends=('python-setuptools' 'python2-setuptools' 'python-requests' 'python2-requests' 'python-oauthlib' 'python2-oauthlib')
checkdepends=('python-pytest' 'python2-pytest' 'python-mock' 'python2-mock')
source=("https://pypi.python.org/packages/source/r/${_pkgname}/${_pkgname}-${pkgver}.tar.gz")
md5sums=('139a17c495fb593b5842634faf72ebb0')

prepare() {
  cp -a ${_pkgname}-$pkgver{,-py2}
}

build() {
  cd "$srcdir/${_pkgname}-$pkgver"
  python setup.py build

  cd "$srcdir/${_pkgname}-$pkgver-py2"
  python2 setup.py build
}

check() {
  cd "$srcdir/${_pkgname}-$pkgver"
  py.test

  cd "$srcdir/${_pkgname}-$pkgver-py2"
  py.test2
}

package_python-requests-oauthlib() {
  depends=('python-requests' 'python-oauthlib')

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

package_python2-requests-oauthlib() {
  depends=('python2-requests' 'python2-oauthlib')

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