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

_realname=annotated-doc
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.0.4
pkgrel=1
pkgdesc='Document parameters, class attributes, return types, and variables inline, with Annotated (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/fastapi/annotated-doc'
msys2_changelog_url='https://github.com/fastapi/annotated-doc/blob/main/release-notes.md'
msys2_references=(
  'purl: pkg:pypi/annotated-doc'
)
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-uv"
             "${MINGW_PACKAGE_PREFIX}-python-pdm-backend"
             "${MINGW_PACKAGE_PREFIX}-python-wheel")
options=('!strip')
source=("${url}/archive/${pkgver}/${_realname}-$pkgver.tar.gz")
sha256sums=('f23767d1df005c26f25a1fc203d89b5d46b75a120227c97dd1094d1e16733336')

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