# Maintainer: UtG pkgbase=python-requests pkgname=(python2-requests python3-requests) pkgver=2.4.0 pkgrel=1 _libname=requests pkgdesc="Requests is an Apache2 Licensed HTTP library, written in Python, for human beings." url="http://python-requests.org/" makedepends=('python2-setuptools' 'python3-setuptools') license=('Apache') arch=('any') source=(http://pypi.python.org/packages/source/${_libname:0:1}/$_libname/$_libname-$pkgver.tar.gz certs.patch 226b5c7b0aafc3cb744eb79a666d9a1bd0803a47.patch) sha256sums=('7007e03cbc73e357b5055c6ea0ad6e447e2afa00f1a1f843cd792a1ebaa3763e' '23bbd144905192edb23082c017292356eedbb3b41856c2a46505a2acb4ace831' '45cbe79fcf452eebb93444de7b78b35c679a77f268ea7286f5899bdb9ea7153a') prepare() { cd "$srcdir/$_libname-$pkgver" patch -p1 -i "$srcdir"/certs.patch patch -p1 -i "$srcdir"/226b5c7b0aafc3cb744eb79a666d9a1bd0803a47.patch sed -r 's#(\W|^)requests/cacert\.pem(\W|$)##' -i MANIFEST.in rm -f requests/cacert.pem } build() { msg2 "Starting the Python 3.x build" cd "$srcdir/$_libname-$pkgver" rm -rf ../buildpy3; mkdir ../buildpy3 python3 setup.py build -b ../buildpy3 find ../buildpy3 -name \*.py -exec sed -r 's|^#!(.*)python$|#!\1python3|' -i {} + msg2 "Starting the Python 2.x build" rm -rf ../buildpy2; mkdir ../buildpy2 python2 setup.py build -b ../buildpy2 find ../buildpy2 -name \*.py -exec sed -r 's|^#!(.*)python$|#!\1python2|' -i {} + } check() { cd "$srcdir/$_libname-$pkgver" test -f "$(python3 -m requests.certs)" } package_python3-requests() { depends=('python3') cd "$srcdir/$_libname-$pkgver" rm -rf build; ln -s ../buildpy3 build python3 setup.py install --skip-build -O1 --root="$pkgdir" install -m0644 -D "LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE" } package_python2-requests() { depends=(python2) optdepends=('python2-ndg-httpsclient: HTTPS requests with SNI support' 'python2-grequests: asynchronous requests with gevent') cd "$srcdir/$_libname-$pkgver" rm -rf build; ln -s ../buildpy2 build python2 setup.py install --skip-build -O1 --root="$pkgdir" }