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

_realname=setuptools
pkgbase="python-${_realname}"
pkgname=("python-${_realname}")
pkgver=69.0.3
pkgrel=1
pkgdesc="Easily download, build, install, upgrade, and uninstall Python packages"
arch=('any')
license=('PSF')
url="https://pypi.python.org/pypi/setuptools"
depends=('python')
makedepends=(
  "python-wheel"
  "python-build"
  "python-installer"
)
provides=("python3-${_realname}" 'python3-distribute')
replaces=("python3-${_realname}" 'python3-distribute')
conflicts=("python3-${_realname}")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/pypa/setuptools/archive/v${pkgver}.tar.gz")
sha256sums=('1b3b43e613f07b94fbea7ce37653616d81247e0e49833521aa309c494354947e')

prepare() {
  export SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES=0
}

build() {
  cd "${srcdir}/setuptools-${pkgver}"

  python setup.py egg_info
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() { (
  # 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 "${srcdir}/setuptools-${pkgver}"
  # /usr/bin/python setup.py pytest
)}

package() {
  cd "${srcdir}/setuptools-${pkgver}"

  python -m installer --destdir="${pkgdir}" dist/*.whl
}
