# $Id: PKGBUILD 130126 2015-03-28 14:30:59Z fyan $
# Maintainer: Sébastien Luttringer

pkgbase=python-psutil
pkgname=('python-psutil' 'python2-psutil')
pkgver=2.2.1
pkgrel=2
arch=('i686' 'x86_64')
url='http://code.google.com/p/psutil/'
license=('custom: BSD')
makedepends=('python' 'python-setuptools' 'python2' 'python2-setuptools')
checkdepends=('net-tools' 'procps-ng')
source=("https://pypi.python.org/packages/source/p/psutil/psutil-$pkgver.tar.gz")
md5sums=('1a2b58cd9e3a53528bb6148f0c4d5244')

build() {
  cd psutil-$pkgver

  msg2 python
  python setup.py build --build-lib=build/python

  msg2 python2
  python2 setup.py build --build-lib=build/python2
  find build/python2 -type f -exec \
    sed -i '1s,^#! \?/usr/bin/\(env \|\)python$,#!/usr/bin/python2,' {} \;
}

check() {
  cd psutil-$pkgver

  msg2 python
  export PYTHONPATH="$PWD/build/python"
  #python test/test_psutil.py
  python test/test_memory_leaks.py

  msg2 python2
  export PYTHONPATH="$PWD/build/python2"
  #python2 test/test_psutil.py
  python2 test/test_memory_leaks.py
}

package_python-psutil() {
  pkgdesc='A cross-platform process and system utilities module for Python'
  depends=('glibc' 'python')

  cd psutil-$pkgver
  python setup.py build --build-lib=build/python \
                  install --root="$pkgdir" --optimize=1
  install -D -m 644 LICENSE "$pkgdir/"usr/share/licenses/$pkgname/LICENSE
}

package_python2-psutil() {
  pkgdesc='A cross-platform process and system utilities module for Python2'
  depends=('glibc' 'python2')

  cd psutil-$pkgver
  python2 setup.py build --build-lib=build/python2 \
                   install --root="$pkgdir" --optimize=1
  install -D -m 644 LICENSE "$pkgdir/"usr/share/licenses/$pkgname/LICENSE
}

# vim:set ts=2 sw=2 et:
