# Maintainer: Sarah Ottinger <schalaalexizeal@gmail.com>

_realname=responses
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.25.8
pkgrel=1
pkgdesc='A utility library for mocking out the `requests` Python library. (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/getsentry/responses"
msys2_repository_url='https://github.com/getsentry/responses'
msys2_changelog_url='https://github.com/getsentry/responses/blob/master/CHANGES'
msys2_documentation_url='https://github.com/getsentry/responses/blob/master/README.rst'
msys2_issue_tracker_url='https://github.com/getsentry/responses/issues'
msys2_references=(
  'archlinux: python-responses'
  'gentoo: dev-python/responses'
  'purl: pkg:pypi/responses'
)
license=('spdx:Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-requests"
         "${MINGW_PACKAGE_PREFIX}-python-urllib3"
         "${MINGW_PACKAGE_PREFIX}-python-yaml")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-mypy"
              "${MINGW_PACKAGE_PREFIX}-python-flake8"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-cov"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-localserver"
              "${MINGW_PACKAGE_PREFIX}-python-pytest")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname/-/_}-${pkgver}.tar.gz")
sha256sums=('9374d047a575c8f781b94454db5cab590b6029505f488d12899ddb10a4af1cf4')

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}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m pytest || warning "Tests failed"
}

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