# $Id: PKGBUILD 116930 2014-08-06 18:16:48Z aginiewicz $
# Maintainer: Andrzej Giniewicz <gginiu@gmail.com>
# Contributor: Keith Hughitt <khughitt@umd.edu>

pkgbase=python-pandas
pkgname=('python2-pandas' 'python-pandas')
pkgver=0.14.1
pkgrel=3
pkgdesc="Cross-section and time series data analysis toolkit"
arch=('i686' 'x86_64')
url="http://pandas.pydata.org/"
license=('BSD')
makedepends=('python-setuptools' 'python-dateutil' 'python-numpy' 'python-pytz'
             'python2-setuptools' 'python2-dateutil' 'python2-numpy' 'python2-pytz')
source=("https://pypi.python.org/packages/source/p/pandas/pandas-${pkgver}.tar.gz")
md5sums=('393dd8f35411e4022177aa64b2da46f4')

build() {
  cd "$srcdir"
  cp -a pandas-${pkgver} pandas-py2-${pkgver}

  msg "Building Python2"
  cd "$srcdir"/pandas-py2-${pkgver}
  python2 setup.py build_ext --inplace
  python2 setup.py build

  msg "Building Python3"
  cd "$srcdir"/pandas-${pkgver}
  python setup.py build_ext --inplace
  python setup.py build
}

package_python2-pandas() {
  depends=('python2-numpy' 'python2-dateutil' 'python2-pytz' 'python2-setuptools')
  optdepends=('python2-numexpr: needed for accelerating certain numerical operations (recommended)'
              'python2-bottleneck: needed for accelerating certain types of nan evaluations (recommended)'
              'python2-scipy: needed for miscellaneous statistical functions'
              'python2-pytables: needed for HDF5-based storage'
              'python2-sqlalchemy: needed for SQL database support'
              'python2-matplotlib: needed for plotting'
              'python2-statsmodels: needed for parts of pandas.stats'
              'python2-openpyxl1: needed for Excel XLSX input/output'
              'python2-xlsxwriter: alternative Excel XLSX output'
              'python2-xlrd: needed for Excel XLS input'
              'python2-xlwt: needed for Excel XLS output'
              'python2-boto: needed for access to Amazon S3 storage'
              'python2-beautifulsoup4: needed for read_html function'
              'python2-lxml: needed for read_html function (and/or python2-html5lib)'
              'python2-html5lib: needed for read_hmlt function (and/or python2-lxml)'
              'python2-httplib2: needed for gbq'
              'python2-google-api-python-client: needed for gbq'
              'python2-gflags: needed for gbq'
              'xsel: needed for read_clipboard function (or xclip)'
              'xclip: needed for read_clipboard function (or xsel)')

  cd "$srcdir"/pandas-py2-${pkgver}

  python2 setup.py install --skip-build --root="$pkgdir" --optimize=1

  sed -i -e "s|#![ ]*/usr/bin/env python$|#!/usr/bin/env python2|" $(find "${pkgdir}" -name '*.py')
  sed -i -e "s|#![ ]*/usr/bin/python$|#!/usr/bin/python2|" $(find "${pkgdir}" -name '*.py')

  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

package_python-pandas() {
  depends=('python-numpy' 'python-dateutil' 'python-pytz' 'python-setuptools')
  optdepends=('python-numexpr: needed for accelerating certain numerical operations (recommended)'
              'python-bottleneck: needed for accelerating certain types of nan evaluations (recommended)'
              'python-scipy: needed for miscellaneous statistical functions'
              'python-pytables: needed for HDF5-based storage'
              'python-sqlalchemy: needed for SQL database support'
              'python-matplotlib: needed for plotting'
              'python-statsmodels: needed for parts of pandas.stats'
              'python-openpyxl1: needed for Excel XLSX input/output'
              'python-xlsxwriter: alternative Excel XLSX output'
              'python-xlrd: needed for Excel XLS input'
              'python-beautifulsoup4: needed for read_html function'
              'python-lxml: needed for read_html function (and/or python-html5lib)'
              'python-html5lib: needed for read_hmlt function (and/or python-lxml)'
              'xsel: needed for read_clipboard function (or xclip)'
              'xclip: needed for read_clipboard function (or xsel)')

  cd "$srcdir"/pandas-${pkgver}

  python setup.py install --skip-build --root="$pkgdir" --optimize=1

  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

