# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname='setuptools'
pkgbase="python-${_realname}"
pkgname="python-${_realname}"
pkgver=84.0.0
pkgrel=1
pkgdesc='Easily download, build, install, upgrade, and uninstall Python packages'
arch=('any')
url='https://setuptools.pypa.io'
msys2_repository_url='https://github.com/pypa/setuptools'
msys2_documentation_url='https://setuptools.pypa.io'
msys2_changelog_url='https://setuptools.pypa.io/en/latest/history.html'
msys2_references=(
  'anitya: 4021'
  'archlinux: python-setuptools'
  'cpe: cpe:/a:python:setuptools'
  'gentoo: dev-python/setuptools'
  'purl: pkg:pypi/setuptools'
)
license=('spdx:MIT')
depends=('python')
source=("${_realname}-${pkgver}.tar.gz::https://github.com/pypa/setuptools/archive/v${pkgver}.tar.gz")
sha256sums=('1cdd0d67229315c742282343f265cac91bb0976f83b2cf78dfa2f4a14343fe2a')

build() {
  cd "${_realname}-${pkgver}"

  python setup.py egg_info
  python setup.py build
}

check() {
  # create a subshell
  (
    # Workaround UTF-8 tests by setting LC_CTYPE
    export LC_CTYPE=en_US.UTF-8

    # https://github.com/pypa/setuptools/pull/810
    export PYTHONDONTWRITEBYTECODE=1

    # Check python module
    # cd "${_realname}-${pkgver}"
    # /usr/bin/python setup.py pytest
  )
}

package() {
  cd "${_realname}-${pkgver}"

  python setup.py install --prefix=/usr --root="${pkgdir}" --skip-build

  # Remove all .exe files
  find "${pkgdir}" -type f -name '*.exe' -delete
}
