# Maintainer: Marcelo Duarte https://github.com/marcelotduarte

_realname=pytest-datafiles
_pyname=pytest_datafiles
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.0.1
pkgrel=1
pkgdesc='A pytest plugin to create a tmp_path containing a preconfigured set of files and/or directories (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'purl: pkg:pypi/pytest-datafiles'
)
url="https://github.com/omarkohl/pytest-datafiles"
msys2_repository_url='https://github.com/omarkohl/pytest-datafiles'
license=('spdx:MIT')
depends=(
  "${MINGW_PACKAGE_PREFIX}-python"
  "${MINGW_PACKAGE_PREFIX}-python-pytest"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
  "${MINGW_PACKAGE_PREFIX}-python-hatchling"
)
source=(https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz)
sha256sums=('05fc3eef2429fe26ae42283cccb1f3831b53b12d4bd8b4734bf42973d4af6e16')

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

build() {
  cd "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 "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
