# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Kyle Keen <keenerd@gmail.com>
# Contributor: wenLiangcan <boxeed at gmail dot com>

pkgname=python-wcwidth
pkgver=0.2.13
pkgrel=2
pkgdesc='Python library that measures the width of unicode strings rendered to a terminal'
arch=('any')
url='https://github.com/jquast/wcwidth'
license=('MIT')
depends=('python')
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)
checkdepends=('python-pytest')
#optdepends=('')
_commit='36a625179ed2675287fe6b61c2ad319406449e60'
source=("$pkgname::git+$url#commit=$_commit")
b2sums=('cd167cc474e8e36d9b9dea7c8738df38b137aaa889cff02ed05a74af0e0ffaac8c2151e31c4e0fde0362735fe37f98135ef8059df6dfc62873940b7065662490')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

build() {
  cd "$pkgname"

  python -m build --wheel --no-isolation
}

check() {
  cd "$pkgname"

  rm -v tox.ini

  export PYTHONPATH=.
  pytest -v
}

package() {
  cd "$pkgname"

  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/${pkgname#python-}-$pkgver.dist-info/LICENSE" \
    "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
