# $Id: PKGBUILD 144645 2015-10-22 00:08:15Z dwallace $
# Maintainer: Daniel Wallace <danielwallace at gtmanfred dot com>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>

pkgbase=python-beautifulsoup4
pkgname=('python2-beautifulsoup4' 'python-beautifulsoup4')
pkgver=4.4.1
pkgrel=1
pkgdesc="A Python HTML/XML parser designed for quick turnaround projects like screen-scraping"
arch=('any')
url="http://www.crummy.com/software/BeautifulSoup/index.html"
license=('PSF')
makedepends=('python-setuptools' 'python2-setuptools')
source=("http://www.crummy.com/software/BeautifulSoup/bs4/download/${pkgver%.*}/${pkgbase#*-}-${pkgver}.tar.gz")
md5sums=('8fbd9a7cac0704645fa20d1419036815')

build() {
  cd "${srcdir}"
  cp -a beautifulsoup4-${pkgver}{,-python2}

  # Build python 3 module
  cd "${srcdir}/beautifulsoup4-${pkgver}"
  python setup.py build

  # Build python 2 module
  cd "${srcdir}/beautifulsoup4-${pkgver}-python2"
  python2 setup.py build
}

package_python2-beautifulsoup4() {
  depends=('python2')
  optdepends=('python2-chardet: universal encoding detector'
              'python2-lxml: pythonic binding for the libxml2 and libxslt libraries')

  cd "${srcdir}/beautifulsoup4-${pkgver}-python2"
  python2 setup.py install --root="${pkgdir}/" --optimize=1 --skip-build

  rm -rf ${pkgdir}/usr/lib/python2.7/site-packages/bs4/tests
}

package_python-beautifulsoup4() {
  depends=('python')
  optdepends=('python-chardet: universal encoding detector'
              'python-lxml: pythonic binding for the libxml2 and libxslt libraries')

  cd "${srcdir}/beautifulsoup4-${pkgver}"
  python setup.py install --root="${pkgdir}/" --optimize=1 --skip-build

  rm -rf ${pkgdir}/usr/lib/python3.2/site-packages/bs4/{__pycache__,tests,builder/__pycache__}
}
