# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=numpydoc
pkgbase=mingw-w64-python-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-${_realname}
pkgver=1.9.0
pkgrel=1
pkgdesc='Sphinx extensions for Numpy (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
license=('spdx:BSD-2-Clause')
url='https://numpydoc.readthedocs.io/'
msys2_repository_url="https://github.com/numpy/numpydoc"
msys2_changelog_url='https://numpydoc.readthedocs.io/en/latest/release/notes.html'
msys2_references=(
  'archlinux: python-numpydoc'
  'gentoo: dev-python/numpydoc'
  'purl: pkg:pypi/numpydoc'
)
depends=(
    "${MINGW_PACKAGE_PREFIX}-python-jinja"
    "${MINGW_PACKAGE_PREFIX}-python-sphinx"
    "${MINGW_PACKAGE_PREFIX}-python-tabulate")
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=('5fec64908fe041acc4b3afc2a32c49aab1540cf581876f5563d68bb129e27c5b')

prepare() {
  rm -rf "${srcdir}/python-build-${MSYSTEM}" | true
  cp -r "${srcdir}/${_realname}-${pkgver}" "${srcdir}/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.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
}
