# Maintainer: Philipp Smirnov https://github.com/sad-poet

_realname=pynput
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.8.1
pkgrel=1
pkgdesc="Python library to monitor and control user input devices (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/moses-palmer/pynput'
msys2_references=(
  'aur: python-pynput'
  'purl: pkg:pypi/pynput'
)
license=('spdx:LGPL-3.0-only')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-six")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
options=('!strip')
source=("https://github.com/moses-palmer/pynput/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('72682ecdc4f2c8ac25eecaee80d068f68b5cd6966d07b8915bc9f5e8a39d6a59')

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 COPYING.LGPL "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/COPYING.LGPL"
}
