# Maintainer: Jelle van der Waa <jelle@archlinux.org>
# Maintainer: daurnimator <daurnimator@archlinux.org>
# Contributor: Daniel Micay <danielmicay@gmail.com>
# Contributor: Thomas Weißschuh <thomas_weissschuh lavabit com>

pkgname=httpie
pkgver=2.6.0
pkgrel=1
pkgdesc="human-friendly CLI HTTP client for the API era"
url="https://github.com/httpie/cli"
depends=('python-defusedxml'
         'python-pygments'
         'python-pysocks'
         'python-requests'
         'python-requests-toolbelt'
         'python-charset-normalizer')
makedepends=('python-setuptools')
checkdepends=('python-pytest'
              'python-pytest-httpbin'
              'python-responses')
conflicts=(python-httpie)
replaces=(python-httpie python2-httpie)
license=('BSD')
arch=('any')
source=($pkgname-$pkgver.tar.gz::"https://github.com/httpie/cli/archive/$pkgver.tar.gz")
sha256sums=('3bcd9a8cb2b11299da12d3af36c095c6d4b665e41c395898a07f1ae4d99fc14a')

build() {
  cd $pkgname-$pkgver
  python3 setup.py build
}

package() {
  cd $pkgname-$pkgver
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/httpie/LICENSE"
  python3 setup.py install --root="$pkgdir" --optimize=1

  # Fix upstream, include them in MANIFEST.in and use data_files in setup.py to install them automatically
  # TODO: add zsh support
  install -Dm644 extras/httpie-completion.bash "$pkgdir"/usr/share/bash-completion/completions/http
  install -Dm644 extras/httpie-completion.fish "$pkgdir"/usr/share/fish/vendor_completions.d/http.fish
}

check() {
  cd $pkgname-$pkgver
  PYTHONDONTWRITEBYTECODE=1 pytest tests
}
