# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=python-lsp-ruff
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=2.3.0
pkgrel=1
pkgdesc='Ruff linting plugin for pylsp. (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'purl: pkg:pypi/python-lsp-ruff'
)
license=('spdx:MIT')
url='https://github.com/python-lsp/python-lsp-ruff'
depends=(
    "${MINGW_PACKAGE_PREFIX}-python"
    "${MINGW_PACKAGE_PREFIX}-python-cattrs"
    "${MINGW_PACKAGE_PREFIX}-python-lsp-server"
    "${MINGW_PACKAGE_PREFIX}-python-lsprotocol"
    "${MINGW_PACKAGE_PREFIX}-python-ruff"
)
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
options=(!strip)
source=(https://pypi.org/packages/source/${_realname::1}/${_realname//-/_}/${_realname//-/_}-${pkgver}.tar.gz)
sha256sums=('647745b7f3010ac101e3c53a797b8f9deb1f52228b608d70ad0e8e056978c3b7')

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

  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

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