# $Id: PKGBUILD 145196 2015-10-28 13:05:28Z fyan $
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Stéphane Gaudreault <stephane@archlinux.org>
# Contributor: Thomas Dziedzic < gostrc at gmail >
# Contributor: Angel 'angvp' Velasquez <angvp[at]archlinux.com.ve>  
# Contributor: Peter Garceau <RockyChimp@gmail.com>

pkgbase=python-sympy
pkgname=('python2-sympy' 'python-sympy')
pkgver=0.7.6.1.20151028
_commit=6ccadc06eb33390d190d6f834261a3a82018541d
pkgrel=1
arch=('any')
pkgdesc='Symbolic manipulation package (Computer Algebra System), written in pure Python'
url='http://sympy.org/en/index.html'
license=('BSD')
makedepends=('python2-mpmath' 'python-mpmath' 'python-setuptools' 'python2-setuptools' 'git')
#source=("git+https://github.com/sympy/sympy.git#tag=sympy-${pkgver}"
source=("git+https://github.com/sympy/sympy.git#commit=$_commit")
sha512sums=('SKIP')

prepare() {
  cp -a sympy py3-sympy
}

build() {
  cd sympy
  python2 setup.py build

  cd ../py3-sympy
  python3 setup.py build
}

check() {
  # Broken, waiting for upstream fixes.

  cd sympy
  python2 setup.py test || warning "Exit code: $?"

  cd ../py3-sympy
  python3 setup.py test || warning "Exit code: $?"
}

package_python2-sympy() {
  depends=('python2-mpmath')
  optdepends=('python2-pyglet: plotting'
              'ipython2: user friendly interface for isympy')

  cd sympy

  python2 setup.py install --root "${pkgdir}" --optimize=1

  install -D -m644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}

package_python-sympy() {
  depends=('python-mpmath')
  optdepends=('ipython: user friendly interface for isympy')

  cd py3-sympy

  python3 setup.py install --root "${pkgdir}" --optimize=1

  # rename files that exists in both 'python2-sympy' and 'python-sympy'
  mv "${pkgdir}"/usr/bin/isympy{,-py3}
  mv "${pkgdir}"/usr/share/man/man1/isympy{,-py3}.1

  install -D -m644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}
