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

_realname=fastapi
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.127.0
pkgrel=1
pkgdesc='FastAPI framework, high performance, easy to learn, fast to code, ready for production (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/fastapi/fastapi'
msys2_changelog_url='https://fastapi.tiangolo.com/release-notes/'
msys2_references=(
  'purl: pkg:pypi/fastapi'
  "cpe: cpe:2.3:a:fastapi_project:fastapi"
)
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-annotated-doc"
         "${MINGW_PACKAGE_PREFIX}-python-anyio" # implicitly required for concurrency
         "${MINGW_PACKAGE_PREFIX}-python-pydantic"
         "${MINGW_PACKAGE_PREFIX}-python-starlette")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-pdm-backend")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-email-validator: for email validation"
            "${MINGW_PACKAGE_PREFIX}-python-itsdangerous: for SessionMiddleware support"
            "${MINGW_PACKAGE_PREFIX}-python-jinja: for default starlette template configuration"
            "${MINGW_PACKAGE_PREFIX}-python-pyyaml: for starlette SchemaGenerator support"
            "${MINGW_PACKAGE_PREFIX}-python-ujson: for faster JSON parsing and UJSONResponse"
            "${MINGW_PACKAGE_PREFIX}-python-websockets: for WebSockets support"
            "${MINGW_PACKAGE_PREFIX}-uvicorn: for Uvicorn as ASGI server")
options=('!strip')
source=("${url}/archive/${pkgver}/${_realname}-$pkgver.tar.gz")
sha256sums=('0ddf27d42a3edf696aeda05dc1fbd21d0ed9c9758f4f4342c664b4aa0fc069e9')

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

build() {
  cd "${srcdir}/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"
}
