# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Jingbei Li <i@jingbei.li>
# Contributor: Jose Riha <jose1711 gmail com>

pkgname=python-pooch
_pyname=pooch
pkgver=1.8.2
pkgrel=4
pkgdesc='Python library for fetching and caching data files'
arch=(any)
url='https://www.fatiando.org/pooch/latest/'
license=(LicenseRef-pooch)
depends=(python
         python-packaging
         python-platformdirs
         python-requests)
optdepends=('python-paramiko: for SFTP downloads'
            'python-tqdm: for printing a download progress bar')
makedepends=(git
             python-build
             python-installer
             python-setuptools-scm
             python-wheel)
checkdepends=(python-pytest
              python-pytest-httpserver)
source=(git+https://github.com/fatiando/pooch#tag=v$pkgver
        https://github.com/fatiando/pooch/commit/96bd5437.patch)
sha256sums=('f297312c457a5201ba95afbe47e4ac848d04460a61fa631cae412dd0ce3cb41a'
            'ae8db79fa3c5fec2e7321691df7fb5fcdd045d50eaa4a856b2e1e0fea430c964')

prepare() {
  cd $_pyname
  patch -p1 -i ../96bd5437.patch # Exclude doc dir from wheel
}

build() {
  cd $_pyname
  SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver \
  python -m build --wheel --no-isolation
}

check() {
  cd $_pyname
  pytest -v -k 'not test_check_availability_on_ftp and not test_ftp_downloader'
}

package() {
  cd $_pyname
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE.txt "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
