# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=archinfo
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=9.2.175
pkgrel=1
pkgdesc="Classes with architecture-specific information useful to other projects (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/angr/archinfo"
msys2_references=(
  'anitya: 34908'
  'archlinux: python-archinfo'
  'aur: python-archinfo-git'
  'purl: pkg:pypi/archinfo'
)
license=('spdx:BSD-2-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
  "${MINGW_PACKAGE_PREFIX}-python-setuptools"
)
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest")
optdepends=(
  "${MINGW_PACKAGE_PREFIX}-python-capstone"
  "${MINGW_PACKAGE_PREFIX}-python-unicorn"
  "${MINGW_PACKAGE_PREFIX}-python-keystone"
  "${MINGW_PACKAGE_PREFIX}-python-pyvex"
)
source=("${url}/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha512sums=('82bf8b2ef9517429cf906e738b50c44df5393c6b38b22782b2ad2b5810fad0e181b538df39785f11ec277129853e9c93e59760fb59c92a86e2cc2a9bdececcb8')


build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "python-build-${MSYSTEM}"

  python -m pytest
}

package() {
  cd "python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
  install -Dm644 README.md "${pkgdir}${MINGW_PREFIX}/share/doc/python-${_realname}/README.md"
}

