# $Id: PKGBUILD 115467 2014-07-11 17:19:24Z fyan $
# Maintainer: Felix Yan <felixonmars@gmail.com>
# Contributor: Patrice Peterson <runiq at archlinux dot us>
# Contributor: Chris Brannon <cmbrannon79@gmail.com>
# Contributor: BorgHunter <borghunter at gmail dot com>

pkgname=(python-urllib3 python2-urllib3)
pkgver=1.9
pkgrel=1
pkgdesc="HTTP library with thread-safe connection pooling and file post support"
arch=("any")
url="https://github.com/shazow/urllib3"
license=("MIT")
makedepends=('python-setuptools' 'python2-setuptools' 'git')
checkdepends=('python-nose' 'python2-nose' 'python-mock' 'python2-mock' 'python-pyopenssl' 'python2-pyopenssl'
              'python-tornado' 'python2-tornado' 'python2-ndg-httpsclient' 'python-coverage' 'python2-coverage')
source=("https://github.com/shazow/urllib3/archive/$pkgver.tar.gz" 
        LICENSE)
md5sums=('e383d5ff4d3a02eff82735f9f120958c'
         '350846ab4dd11ce105b570c15c1b0764')

prepare() {
  # Hack version requirements for test requirements to run tests - Disabled due to tests not runable
  #sed -e "s/==.*//" -i $_pkgname/test-requirements.txt

  cp -a urllib3-$pkgver{,-py2}
}

build() {
  cd urllib3-$pkgver
  python setup.py build

  cd ../urllib3-$pkgver-py2
  python2 setup.py build
}

check() {
  # Tests stuck

  cd urllib3-$pkgver
#  nosetests3 -e "pyopenssl"  # No ndg-httpsclient module to test with

  cd ../urllib3-$pkgver-py2
#  nosetests2
}

package_python-urllib3() {
  depends=('python')

  cd urllib3-$pkgver
  python setup.py install --root="${pkgdir}"
  install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

package_python2-urllib3() {
  depends=('python2')

  cd urllib3-$pkgver-py2
  python2 setup.py install --root="${pkgdir}"
  install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
