# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.su>

_realname=jsonrpc-server
_pyname=python-jsonrpc-server
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.4.0
pkgrel=9
pkgdesc="Python library implementing asynchronous JSON RPC server (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/palantir/python-jsonrpc-server"
msys2_references=(
  'purl: pkg:pypi/python-jsonrpc-server'
)
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-future"
         "${MINGW_PACKAGE_PREFIX}-python-ujson")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-versioneer")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-coverage"
              "${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-cov"
              "${MINGW_PACKAGE_PREFIX}-python-pyflakes"
              "${MINGW_PACKAGE_PREFIX}-python-mock")
source=("https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz"
        "002-python-jsonrpc-server-0.4.0-fix-test.patch")
sha256sums=('62c543e541f101ec5b57dc654efc212d2c2e3ea47ff6f54b2e7dcb36ecf20595'
            '417deed5e3bf6c04868bb7c567f664c40be8a400dabc6594d593d803d292a7ce')

prepare() {
  cd "${srcdir}"/${_pyname}-${pkgver}
  patch -p1 -i "${srcdir}/002-python-jsonrpc-server-0.4.0-fix-test.patch"

  rm -rf "versioneer.py" | true
}

build() {
  cp -r "${_pyname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  PYTHONPATH="build/lib" pytest
}

package() {
  cd "${srcdir}"/python-build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}

# vim: ts=2 sw=2 et:
