# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=requests-unixsocket
pkgbase=mingw-w64-python-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-${_realname}
pkgver=0.4.1
pkgrel=1
pkgdesc='Use requests to talk HTTP via a UNIX domain socket (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/msabramo/requests-unixsocket'
msys2_references=(
  'purl: pkg:pypi/requests-unixsocket'
)
license=('spdx:Apache-2.0')
depends=(
    ${MINGW_PACKAGE_PREFIX}-python
    ${MINGW_PACKAGE_PREFIX}-python-requests
    ${MINGW_PACKAGE_PREFIX}-python-urllib3)
makedepends=(
    "${MINGW_PACKAGE_PREFIX}-python-build"
    "${MINGW_PACKAGE_PREFIX}-python-installer"
    "${MINGW_PACKAGE_PREFIX}-python-setuptools"
    "${MINGW_PACKAGE_PREFIX}-python-setuptools-scm"
)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname/-/_}/${_realname/-/_}-${pkgver}.tar.gz")
sha256sums=('b2596158c356ecee68d27ba469a52211230ac6fb0cde8b66afb19f0ed47a1995')

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

  export SETUPTOOLS_SCM_PRETEND_VERSION="${pkgver}"

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

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"
}
