# Maintainer: Some One <some.one@some.email.com>
#This value is here because some python package names have capital letters
#while there is a strong preference for lowercase letters in ArchLinux and
#MSYS packages.

_realname=oslosphinx
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=4.18.0
pkgrel=7
pkgdesc="OpenStack Sphinx Extensions and Theme (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/openstack/oslosphinx'
msys2_references=(
  'purl: pkg:pypi/oslosphinx'
)
license=('spdx:Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-pbr"
         "${MINGW_PACKAGE_PREFIX}-python-six"
         "${MINGW_PACKAGE_PREFIX}-python-requests")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-sphinx")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('b3fcd7ecc8efdb80096b9a757e76300a97485e8e7899e86d953fff7d0a0aa4f6')

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

  # Set version for pbr
  export PBR_VERSION=${pkgver}
}

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "${srcdir}/${_realname}-${pkgver}"
  ${MINGW_PREFIX}/bin/python -m pytest
}

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