# Description: WeeChat Matrix protocol script written in Python
# URL: https://github.com/poljar/weechat-Matrix
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: python3-matrix-nio python3-webcolors weechat

name=weechat-matrix
version=0.3.0
release=1
source=(https://github.com/poljar/weechat-matrix/archive/$version/$name-$version.tar.gz
  0001-Switch-to-correct-build-system-definition.patch)

build() {
  cd $name-$version

  patch -Np1 -i $SRC/0001-Switch-to-correct-build-system-definition.patch

  /usr/bin/python3 -m build --wheel --skip-dependency-check --no-isolation
  /usr/bin/python3 -m installer --compile-bytecode 2 --destdir=$PKG dist/*.whl

  install -Dm755 main.py $PKG/usr/share/weechat/python/weechat-matrix.py
  for _script in matrix_decrypt matrix_sso_helper matrix_upload
  do
    install -Dm755 contrib/$_script.py $PKG/usr/bin/$_script
  done
}
