# Contributor: Dirk Stolle

_realname=flasgger
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.9.7.1
pkgrel=1
pkgdesc="Extract swagger specs from your flask project (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/flasgger/flasgger'
msys2_references=(
  'archlinux: python-flasgger'
  'gentoo: dev-python/flasgger'
  'purl: pkg:pypi/flasgger'
)
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python-flask"
         "${MINGW_PACKAGE_PREFIX}-python-jsonschema"
         "${MINGW_PACKAGE_PREFIX}-python-mistune"
         "${MINGW_PACKAGE_PREFIX}-python-packaging"
         "${MINGW_PACKAGE_PREFIX}-python-six"
         "${MINGW_PACKAGE_PREFIX}-python-werkzeug"
         "${MINGW_PACKAGE_PREFIX}-python-yaml")
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=('ca098e10bfbb12f047acc6299cc70a33851943a746e550d86e65e60d4df245fb')

prepare() {
  cd "${_realname}-${pkgver}"

  # Remove superfluous files which might end up in package.
  unlink ./etc/.DS_Store
  unlink ./flasgger/.DS_Store
}

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

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

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