# $Id: PKGBUILD 137794 2015-08-03 07:58:41Z fyan $
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Florian Bruhin (The Compiler) <archlinux.org@the-compiler.org>
# Contributor: Brecht Machiels <brecht at mos6581 dot org>

pkgbase=pyprof2calltree
pkgname=(pyprof2calltree python2-pyprof2calltree)
pkgver=1.3.2
pkgrel=2
pkgdesc="Help visualize profiling data from cProfile with kcachegrind"
url="https://pypi.python.org/pypi/pyprof2calltree/"
arch=('any')
license=('BSD')
makedepends=('python-setuptools' 'python2-setuptools')
source=(http://pypi.python.org/packages/source/p/pyprof2calltree/pyprof2calltree-${pkgver}.tar.gz)
sha1sums=('ef2d80d3da4cf70d8550464fd8d506c37f4e13f3')

prepare() {
  sed -n '/# Copyright/,/# THE SOFTWARE\./p' pyprof2calltree-$pkgver/pyprof2calltree.py > LICENSE
  cp -a pyprof2calltree-$pkgver{,-py2}
}

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

package_pyprof2calltree() {
  depends=('python-setuptools')

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

package_python2-pyprof2calltree() {
  depends=('python2-setuptools')

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

  mv "$pkgdir/usr/bin/pyprof2calltree"{,2}
}
