# 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=2.2.2
pkgrel=2
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')
makedepends=('cython' 'python-build' 'python-installer' 'meson-python' 'python-versioneer')
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)
sha256sums=('79bc6fb5505afd27875c93fec27cece74318470c4e274ec7ef48b16f046dc006')

prepare() {
  cd pandas-${pkgver}
  sed -e 's|2.0.0|1.0.0|' -i pandas/compat/_optional.py # Restore sqlalchemy 1.x support
}

build() {
  cd pandas-${pkgver}
  python -m build --wheel --no-isolation --skip-dependency-check
}

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 -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
