# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=fixtures
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=4.1.0
pkgrel=2
pkgdesc="Fixtures, reusable state for writing clean tests and more (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://launchpad.net/python-fixtures"
license=('spdx:Apache-2.0 OR BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-pbr"
         "${MINGW_PACKAGE_PREFIX}-python-six"
          "${MINGW_PACKAGE_PREFIX}-python-testtools")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-subunit"
              "${MINGW_PACKAGE_PREFIX}-python-mock")
options=('staticlibs' 'strip' '!debug')
source=("https://pypi.io/packages/source/f/fixtures/fixtures-${pkgver}.tar.gz")
sha512sums=('6897449fdefd07abe7714186b366fdf4505283f6747f8fa4d17044bc45da58eb36e69d89381527ccecb98e6c62c58bc6d4f558af41cbfc87b0221ae60ba71ff6')

# Helper macros to help make tasks easier #
apply_patch_with_msg() {
  for _patch in "$@"
  do
    msg2 "Applying $_patch"
    patch -Nbp1 -i "${srcdir}/$_patch"
  done
}

del_file_exists() {
  for _fname in "$@"
  do
    if [ -f $_fname ]; then
      rm -rf $_fname
    fi
  done
}
# =========================================== #

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

  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}

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

# This doesn't seem to worky
#check() {
#  msg "Python test for ${MSYSTEM}"
#  cd "${srcdir}/python-build-${MSYSTEM}"
#  ${MINGW_PREFIX}/bin/python -m testtools.run fixtures.test_suite
#}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  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
}
