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

_realname=requests-mock
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.9.3
pkgrel=1
pkgdesc='A mock of useful classes and functions to be used with python-requests. (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/jamielennox/requests-mock"
license=('Apache')
depends=("${MINGW_PACKAGE_PREFIX}-python-six"
         "${MINGW_PACKAGE_PREFIX}-python-requests")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-mock"
              "${MINGW_PACKAGE_PREFIX}-python-purl"
              "${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-testrepository")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-pbr")
options=('!emptydirs')
source=("https://github.com/jamielennox/requests-mock/archive/$pkgver.tar.gz")
sha256sums=('da687287a22f38f53bca0e111ec6ef35e962a2ac7537f7fc091d7812fcb85583')

export PBR_VERSION=$pkgver

prepare() {  
  cd "$srcdir"
  rm -rf python-build-${CARCH}
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python -m pytest tests/pytest || warning "Tests failed"
  ${MINGW_PREFIX}/bin/python setup.py testr || warning "Tests failed"
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
