# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Felix Yan <felixonmars@archlinux.org>

pkgname=python-xmlschema
_pkgname="${pkgname#python-}"
pkgver=2.5.1
pkgrel=2
epoch=1
pkgdesc='An XML Schema validator and decoder'
arch=(any)
url='https://github.com/sissaschool/xmlschema'
license=('MIT')
depends=('python' 'python-elementpath')
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-wheel'
  'python-setuptools'
)
checkdepends=('python-lxml' 'python-jinja')
optdepends=('python-jinja: for XSD based code generators')
_commit='faff4d8ca954d8722df89e1e77bc4246a36ed62c'  # refs/tags/2.5.1^{}
source=("$pkgname::git+$url#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

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

build() {
  cd "$pkgname"

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

check() {
  cd "$pkgname"

  PYTHONPATH="$PWD" python -m unittest
}

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"
}
