# Contributor: Tobi Laskowski <tobil4sk@outlook.com>

_realname=hererocks
pkgbase=mingw-w64-python-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-${_realname}
pkgver=0.25.1
pkgrel=0
pkgdesc="Python script for installing Lua/LuaJIT and LuaRocks into a local directory (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/luarocks/hererocks'
msys2_references=(
  'purl: pkg:pypi/hererocks'
)
license=('spdx:MIT')
depends=("git"
         "${MINGW_PACKAGE_PREFIX}-python"
         "unzip")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
options=('!strip')
source=($url/archive/${pkgver}/${_realname}-${pkgver}.tar.gz)
sha256sums=('bd3769fb9f7ac944f67601575a6c0aad7118e89ebba418985a126c2412f1f9e0')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && 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 -t "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}" LICENSE
}
