# Maintainer: Antoine Martin <antoine@xpra.org>
# Contributor: Jelle van der Waa <jelle@archlinux.org>
# Contributor: Maxim Andersson <thesilentboatman@gmail.com>

_realname=zeroconf
_srcname=python-zeroconf
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=0.25.1
pkgrel=1
pkgdesc="A pure python implementation of multicast DNS service discovery"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/jstasiak/python-zeroconf"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-ifaddr"
         "${MINGW_PACKAGE_PREFIX}-python-netifaces"
         "${MINGW_PACKAGE_PREFIX}-python-six")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest")
source=("${_srcname}-${pkgver}.tar.gz"::"https://github.com/jstasiak/${_srcname}/archive/${pkgver}.tar.gz")
sha256sums=('d32dbc683318e4534348d518011944467f641892574a757c19083ec6f8c25afb')

prepare() {
  rm -rf python-build-${CARCH} | true
  cp -r "${_srcname}-${pkgver}" "python-build-${CARCH}"
}

build() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
      --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 COPYING    "${pkgdir}${MINGW_PREFIX}/share/licenses/python-zeroconf/COPYING"
  install -Dm644 README.rst "${pkgdir}${MINGW_PREFIX}/share/doc/python-zeroconf/README"
}

check() {
  cd "${srcdir}/python-build-${CARCH}"
  py.test .
}
