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

_realname=entrypoints
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.3
pkgrel=1
pkgdesc="Discover and load entry points from installed packages (mingw-w64)"
url="https://github.com/takluyver/entrypoints"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=(${_realname}-${pkgver}.tar.gz::https://github.com/takluyver/${_realname}/archive/${pkgver}.tar.gz
        ${_realname}-${pkgver}-whl.tar.gz::https://files.pythonhosted.org/packages/py2.py3/e/${_realname}/${_realname}-${pkgver}-py2.py3-none-any.whl)
sha256sums=('f26eddc371e37d8e9f6663b77524d6731567f005bd1e4ac950c0e33c48fbc065'
            '589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19')

package() {
  cd "${srcdir}"

  local _py3ver=$(${MINGW_PREFIX}/bin/python -c "import sys;sys.stdout.write('.'.join(map(str, sys.version_info[:2])))")
  install -Dm644 entrypoints.py "${pkgdir}${MINGW_PREFIX}/lib/python${_py3ver}/site-packages/entrypoints.py"

  local _dist="entrypoints-${pkgver}.dist-info"
  cd ${_dist}
  for _i in ./*; do
    install -Dm644 $_i "${pkgdir}${MINGW_PREFIX}/lib/python${_py3ver}/site-packages/${_dist}/${_i}"
  done

  cd "${srcdir}/${_realname}-$pkgver"
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
