# Maintainer: Andrzej Giniewicz <gginiu@gmail.com>
# Maintainer: Morten Linderud <foxboron@archlinux.org>
# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Keith Hughitt <khughitt@umd.edu>

pkgname=python-pandas
pkgver=1.5.3
pkgrel=3.1
pkgdesc='High-performance, easy-to-use data structures and data analysis tools for Python'
arch=(x86_64 aarch64)
url="https://pandas.pydata.org/"
license=(BSD)
depends=('python-numpy' 'python-dateutil' 'python-pytz' 'python-setuptools')
makedepends=('cython0' 'base-devel')
optdepends=(
    'python-pandas-datareader: pandas.io.data replacement (recommended)'
    'python-numexpr: accelerating certain numerical operations (recommended)'
    'python-bottleneck: accelerating certain types of nan evaluations (recommended)'
    'python-matplotlib: plotting'
    'python-jinja: conditional formatting with DataFrame.style'
    'python-tabulate: printing in Markdown-friendly format'
    'python-scipy: miscellaneous statistical functions'
    'python-numba: alternative execution engine'
    'python-xarray: pandas-like API for N-dimensional data'
    'python-xlrd: Excel XLS input'
    'python-xlwt: Excel XLS output'
    'python-openpyxl: Excel XLSX input/output'
    'python-xlsxwriter: alternative Excel XLSX output'
    # 'python-pyxlsb: XLSB input' (nowhere)
    'python-beautifulsoup4: read_html function (in any case)'
    'python-html5lib: read_html function (and/or python-lxml)'
    'python-lxml: read_xml, to_xml and read_html function (and/or python-html5lib)'
    'python-sqlalchemy: SQL database support'
    'python-psycopg2: PostgreSQL engine for sqlalchemy'
    'python-pymysql: MySQL engine for sqlalchemy'
    'python-pytables: HDF5-based reading / writing'
    'python-blosc: for msgpack compression using blosc'
    'zlib: compression for msgpack'
    # 'python-fastparquet: Parquet reading / writing' (in the AUR)
    'python-pyarrow: Parquet, ORC and feather reading/writing'
    # 'python-pyreadstat: SPSS files reading' (in the AUR)
    'python-fsspec: handling files aside from local and HTTP'
    # 'python-gcsfs: Google Cloud Storage access' (in the AUR)
    # 'python-pandas-gbq: Google BigQuery access' (nowhere)
    # 'python-s3fs: Amazon S3 access' (in the AUR)
    'python-pyqt5: read_clipboard function (only one needed)'
    'python-qtpy: read_clipboard function (only one needed)'
    'xclip: read_clipboard function (only one needed)'
    'xsel: read_clipboard function (only one needed)'
    'python-brotli: Brotli compression'
    'python-snappy: Snappy compression'
    'python-zstandard: Zstandard (zstd) compression'
)
# checkdepends=(
#     'python-pytest'
#     'python-pytest-asyncio'
#     'python-pytest-xdist'
#     'python-hypothesis'
#     'python-pandas-datareader'
#     'python-numexpr'
#     'python-bottleneck'
#     'python-matplotlib'
#     'python-jinja'
#     'python-tabulate'
#     'python-scipy'
#     'python-numba'
#     'python-xarray'
#     'python-xlrd'
#     'python-xlwt'
#     'python-openpyxl'
#     'python-xlsxwriter'
#     # 'python-pyxlsb' (nowhere)
#     'python-beautifulsoup4'
#     'python-html5lib'
#     'python-lxml'
#     'python-sqlalchemy'
#     'python-psycopg2'
#     'python-pymysql'
#     'python-pytables'
#     'python-blosc'
#     'zlib'
#     # 'python-fastparquet' (in the AUR)
#     'python-pyarrow'
#     # 'python-pyreadstat' (in the AUR)
#     'python-fsspec'
#     # 'python-gcsfs' (in the AUR)
#     # 'python-pandas-gbq' (nowhere)
#     # 'python-s3fs' (in the AUR)
#     'python-pyqt5'
#     'python-qtpy'
#     'xclip'
#     'xsel'
#     'python-brotli'
#     'python-snappy'
#     'python-zstandard'
#     'python-dask'
#     'python-toolz'
#     'python-cftime'
#     'python-statsmodels'
#     'python-scikit-learn'
#     'python-seaborn'
#     'python-geopandas'
#     'python-odfpy'
#     'ipython'
#     'python-botocore'
#     'python-numba'
# )
# No test data in upstream crafted tarball
#source=(https://github.com/pandas-dev/pandas/releases/download/v${pkgver}/pandas-${pkgver}.tar.gz)
source=(https://github.com/pandas-dev/pandas/archive/refs/tags/v${pkgver}/${pkgname}-${pkgver}.tar.gz
        fix-pyarrow-10.patch)
sha256sums=('d8abf9c2bf33cac75b28f32c174c29778414eb249e5e2ccb69b1079b97a8fc66'
            '65008439d0eeef47ef4dca98ef7469b548f3d2f3b1666809cb846b84b07c05f4')

prepare() {
  cd pandas-${pkgver}
  # https://github.com/pandas-dev/pandas/commit/4878dfe551da2fa8e2bc33e774b595f099bfa74e
  patch -p1 < ../fix-pyarrow-10.patch
}

build() {
  cd pandas-${pkgver}
  python setup.py build_ext --inplace
  python setup.py build
}

# check() {
#   cd pandas-${pkgver}
#   # TODO: Revisit after new release with better python3.11 support
#   # pytest pandas --skip-slow --skip-network --skip-db -m "not clipboard and not single_cpu" -n 4 -r sxX || true
# }

package() {
  cd pandas-${pkgver}
  python setup.py install --skip-build --root="$pkgdir" --optimize=1
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
