# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Sherlock Holo <sherlockya@gmail.com>
# Contributor: user6553591 <Message on Reddit>

pkgname=python-websockets
pkgver=12.0
pkgrel=3
pkgdesc='Python implementation of the WebSocket Protocol (RFC 6455)'
url='https://github.com/aaugustin/websockets'
arch=('x86_64' 'aarch64')
license=('BSD-3-Clause')
depends=('python')
makedepends=(
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)
source=(https://github.com/aaugustin/websockets/archive/${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('f17943d444ce275b709cf89453b2d2cce09f5af26f0460e226c2e24cfbb425c825963352e130dcd4201587606355375b525d8e5a02eccbffbb3985a108a3ed5e')
b2sums=('cab704e0ee44a7012ee58d515a5ea7380a97a3cbb8f55d105c00c8c2b9ed992b4c87435875474de32e5969fd92256bdec830db0571399a1d2e5fb719b23c2d83')

build() {
  cd websockets-${pkgver}
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd websockets-${pkgver}
  PYTHONPATH="$PWD/src" python -m unittest discover -v
}

package() {
  cd websockets-${pkgver}
  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}/websockets-${pkgver}.dist-info/LICENSE" \
    "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

# vim: ts=2 sw=2 et:
