# Maintainer: fauxpark <fauxpark@gmail.com>

_realname=qmk
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.1.2
pkgrel=2
pkgdesc="CLI tool for customizing supported mechanical keyboards. (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
url='https://github.com/qmk/qmk_cli'
license=('MIT')
options=('!strip')
depends=("git"
         "${MINGW_PACKAGE_PREFIX}-python-dotty-dict"
         "${MINGW_PACKAGE_PREFIX}-python-hid"
         "${MINGW_PACKAGE_PREFIX}-python-hjson"
         "${MINGW_PACKAGE_PREFIX}-python-jsonschema"
         "${MINGW_PACKAGE_PREFIX}-python-milc"
         "${MINGW_PACKAGE_PREFIX}-python-pillow"
         "${MINGW_PACKAGE_PREFIX}-python-pygments"
         "${MINGW_PACKAGE_PREFIX}-python-pyserial"
         "${MINGW_PACKAGE_PREFIX}-python-pyusb")
makedepends=("${MINGW_PACKAGE_PREFIX}-python"
             "${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-wheel")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('f871f88f1a0ca31ba31a009d716417e46bc538a4f8df8ede6a801c9076c22998')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
}

build() {
  cd "${srcdir}"
  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=;--install-scripts=;--install-platlib=" \
    "${MINGW_PREFIX}"/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
