# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Andrey Mikhaylenko <neithere at gmail dot com>
# Contributor: JisuWoniu <jswn@jswn9945.xyz>

pkgname=python-argcomplete
_pyname=argcomplete
pkgver=3.6.2
pkgrel=1
pkgdesc='Easy, extensible command line tab completion of arguments for your Python script'
url='https://github.com/kislyuk/argcomplete'
arch=('any')
license=('Apache-2.0')
depends=('python')
makedepends=('git' 'python-build' 'python-hatch-vcs' 'python-hatchling' 'python-installer' 'python-wheel')
checkdepends=('fish' 'python-pexpect' 'python-pip' 'tcsh' 'zsh')
source=(${_pyname}::"git+$url#tag=v$pkgver")
sha512sums=('5538bdddc792f6f83692b1a239e0283863ae2e81e22d1d3e699d57e11b4efcc12100382b73cbf8f5ad0a88f850365c71ffe6c3885cac8d606c8308360fd53872')
validpgpkeys=('29BCBADB4ECAAAC2382699388AFAFCD242818A52') # Andrey Kislyuk <kislyuk@gmail.com>

build() {
  cd ${_pyname}
  python -m build --wheel --no-isolation
}

check() {
  cd ${_pyname}
  python -m venv --system-site-packages test-venv
  test-venv/bin/python -m installer dist/*.whl
  PATH="$PWD/test-venv/bin/:$PATH" test-venv/bin/python test/test.py -v

}

package() {
  cd ${_pyname}
  python -m installer --destdir="$pkgdir" dist/*.whl

  # Disabled again, see https://gitlab.archlinux.org/archlinux/packaging/packages/python-argcomplete/-/issues/3
  # local _site_packages=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
  # install -dm755 "$pkgdir"/usr/share/bash-completion/completions "$pkgdir"/usr/share/zsh/site-functions
  # ln -s ../../../..${_site_packages}/argcomplete/bash_completion.d/_python-argcomplete -t "$pkgdir"/usr/share/bash-completion/completions/
  # ln -s ../../../..${_site_packages}/argcomplete/bash_completion.d/_python-argcomplete -t "$pkgdir"/usr/share/zsh/site-functions/
}

# vim: ts=2 sw=2 et:
