# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Andy Weidenbaum <archbaum@gmail.com>

pkgname=python-requests-unixsocket
pkgver=0.4.1
pkgrel=1
pkgdesc='Use requests to talk HTTP via a UNIX domain socket'
arch=('any')
url='https://github.com/msabramo/requests-unixsocket'
license=('Apache-2.0')
depends=(
  'python'
  'python-requests'
  'python-urllib3'
)
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-setuptools-scm'
  'python-wheel'
)
options=('!emptydirs')
source=("$pkgname::git+$url#tag=v$pkgver")
sha512sums=('0240a2e4beccef0110b19d7b04a393472da180b2e07c4d7dd2341ba14d405968ff252ece4cc276c38629a1e7c269a3f820bda0969b07b2f12275180c9d68fba7')
b2sums=('b20ba95f7c08452895583c913e456de06eb950762f32af9f32d208a7f30cb339660e268806f5e127f8fc3b9e8f6cd2dc6e0ce9e4ef472d0b07e8368c5a9f45c1')

build() {
  cd "$pkgname"

  export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver

  python -m build --wheel --no-isolation
}

package() {
  cd "$pkgname"

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

  # remove tests folder from package
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  rm -rf "$pkgdir$site_packages/${_pkgname/-/_}/"{tests,testutils.py}
}
