# Maintainer: Maksim Bondarenkov <maksapple2306@gmail.com>

_realname=lsprotocol
pkgbase=mingw-w64-python-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-python-${_realname}"
pkgver=2025.0.0
pkgrel=1
pkgdesc="Code generator and generated types for Language Server Protocol (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/microsoft/lsprotocol/'
msys2_references=(
  'purl: pkg:pypi/lsprotocol'
)
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python-cattrs")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-flit-core")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-jsonschema"
              "${MINGW_PACKAGE_PREFIX}-python-pyhamcrest")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('e879da2b9301e82cfc3e60d805630487ac2f7ab17492f4f5ba5aaba94fe56c29')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "python-build-${MSYSTEM}"

  python -m pytest
}

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

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

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