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

_realname=uvicorn
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.40.0
pkgrel=1
pkgdesc='The lightning-fast ASGI server (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://www.uvicorn.org/'
msys2_repository_url='https://github.com/encode/uvicorn'
msys2_changelog_url='https://uvicorn.dev/release-notes/'
msys2_references=(
  'archlinux: uvicorn'
  'cpe: cpe:2.3:a:encode:uvicorn'
  'gentoo: dev-python/uvicorn'
  'purl: pkg:pypi/uvicorn'
)
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-click"
         "${MINGW_PACKAGE_PREFIX}-python-h11")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-hatchling")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('839676675e87e73694518b5574fd0f24c9d97b46bea16df7b8c05ea1a51071ea')

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.md "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE.md"
}
