# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=virtualenv
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-virtualenv")
pkgver=20.35.4
pkgrel=1
pkgdesc="Virtual Python Environment builder (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: python-virtualenv'
  'gentoo: dev-python/virtualenv'
  'purl: pkg:pypi/virtualenv'
  "cpe: cpe:/a:python:virtualenv"
)
msys2_repository_url='https://github.com/pypa/virtualenv/'
url="https://virtualenv.pypa.io/"
msys2_changelog_url='https://virtualenv.pypa.io/en/latest/changelog.html'
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python-platformdirs"
         "${MINGW_PACKAGE_PREFIX}-python-distlib"
         "${MINGW_PACKAGE_PREFIX}-python-filelock")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-hatchling"
             "${MINGW_PACKAGE_PREFIX}-python-hatch-vcs")
options=('!strip')
source=(https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz)
sha256sums=('643d3914d73d3eeb0c552cbb12d7e82adf0e504dbf86a3182f8771a153a1971c')

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 LICENSE -t "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}"
}
