# Maintainer: Peter Budai <peterbudai@hotmail.com>

_realname=ptyprocess
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.7.0
pkgrel=6
pkgdesc="Run a subprocess in a pseudo terminal (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/pexpect/ptyprocess"
msys2_references=(
  'purl: pkg:pypi/ptyprocess'
)
license=('spdx:ISC')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-flit-core")
source=(https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz
        https://raw.githubusercontent.com/pexpect/ptyprocess/${pkgver}/LICENSE)
sha256sums=('5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220'
            'c822d385b1a73329846241799becf18690b5d44764c1bed69300b536a405030a')

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 -D -m644 "${srcdir}/LICENSE" "${pkgdir}"${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE
}
