# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: Jose Riha <jose1711 gmail com>

pkgname=python-littleutils
_name=${pkgname#python-}
pkgver=0.2.4
pkgrel=2
pkgdesc='Small personal collection of python utility functions'
arch=(any)
url=https://github.com/alexmojaki/littleutils
license=(MIT)
depends=(python)
makedepends=(
  git
  python-build
  python-installer
  python-setuptools
  python-setuptools-scm
  python-wheel
)
source=("git+$url.git#tag=v$pkgver")
b2sums=('35379267f3acbce59f8a650b76000d6d9389f37bb39a6bef9ede40b7aff6b8e3b45d831af6f326f2631658ae4457433558433d5b052ca7377391d37cd612b96b')

build() {
  cd "$_name"
  export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "$_name"
  python littleutils/__init__.py
}

package() {
  cd "$_name"
  python -m installer --destdir="$pkgdir" dist/*.whl

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/"$_name"-$pkgver.dist-info/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
