# Maintainer: lilydjwg <lilydjwg@gmail.com>

_name=aioxmpp
pkgname=python-aioxmpp-git
pkgver=0.14.0a0.20260324
pkgrel=1
pkgdesc="Pure-python XMPP library for asyncio"
arch=(any)
url="https://codeberg.org/jssfr/aioxmpp"
license=('LGPL-3.0-or-later')
depends=('python-aiosasl' 'python-aioopenssl' 'python-babel' 'python-dnspython' 'python-lxml' 'python-multidict' 'python-sortedcollections' 'python-pyopenssl' 'python-pyasn1' 'python-pyasn1-modules' 'python-tzlocal')
makedepends=('python-setuptools' 'git')
source=("git+https://codeberg.org/jssfr/aioxmpp.git")
sha256sums=('SKIP')
conflicts=('python-aioxmpp')
provides=("python-aioxmpp=$pkgver")

pkgver() {
  cd "$srcdir/$_name"
  echo $(PYTHONPATH=$PWD python3 -c '
import runpy
version_mod = runpy.run_path("aioxmpp/_version.py")
print(version_mod["__version__"].replace("-", ""))
').$(TZ=UTC git log -1 --pretty='%cd' --date=short-local | tr -d '-')
}

build() {
  cd "$srcdir/$_name"
  python3 setup.py build
}

package() {
  cd "$srcdir/$_name"
  python3 setup.py install --root=$pkgdir --optimize=1 --skip-build

  # make sure we don't install any world-writable or root-readable-only files
  # we shouldn't need to fix ownership as we extract tarballs as a non-root user
  # https://github.com/pypa/setuptools/issues/1328
  # https://github.com/LonamiWebs/Telethon/issues/1605
  chmod u=rwX,go=rX -R "$pkgdir"
  # make sure we don't install annoying files
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  rm -rf "$pkgdir/$_site_packages/tests/"
}

