# Maintainer: Bruno Pagani <archange@archlinux.org>
# Maintainer: Jakub Klinkovský <lahwaacz at archlinux dot org>

_name=partd
pkgname=python-$_name
pkgver=1.4.2
pkgrel=2
pkgdesc="Concurrent appendable key-value storage"
arch=(any)
url="https://github.com/dask/partd"
license=(BSD-3-Clause)
depends=(
  python
  python-locket
  python-toolz
)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-versioneer
)
optdepends=(
  python-blosc
  python-numpy
  python-pandas
  python-pyzmq
)
checkdepends=(
  python-pytest
  python-blosc
  python-numpy
  python-pandas
  python-pyzmq
)
source=($_name-$pkgver.tar.gz::$url/archive/refs/tags/$pkgver.tar.gz)
b2sums=('046aeead247c57060c2e4f366151af1058852953b97a943df2df7e1fefa68d0a70489b5fccc813223de0e143788b8d4f1a99ae74867064963da28448653e786b')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local pytest_options=(
    -vv
    # skip tests failing due to current pandas
    # NotImplementedError: (CategoricalDtype(categories=['x', 'y', 'z'], ordered=False, categories_dtype=object), array([0, 1, 2, 0], dtype=int8))
    # etc.
    --deselect partd/tests/test_pandas.py::test_serialize_categoricals[False]
    --deselect partd/tests/test_pandas.py::test_serialize_categoricals[True]
    --deselect partd/tests/test_pandas.py::test_serialize[base0]
    --deselect partd/tests/test_pandas.py::test_serialize[base1]
    --deselect partd/tests/test_pandas.py::test_index_non_numeric_extension_types[string[python]]
  )

  cd $_name-$pkgver
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  test-env/bin/python -m pytest "${pytest_options[@]}"
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE.txt -t "$pkgdir"/usr/share/licenses/$pkgname/
}
