# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer:
pkgname=liquidctl
pkgver=1.13.0
pkgrel=1
pkgdesc="Liquid Cooler Control"
url="https://github.com/liquidctl/liquidctl"
options="!check" # Requires writable /var/run
arch="noarch"
license="GPL-3.0-or-later"
depends="
	py3-colorlog
	py3-crcmod
	py3-docopt
	py3-hidapi
	py3-pillow
	py3-smbus
	py3-usb
	"
makedepends="
	py3-gpep517
	py3-installer
	py3-setuptools
	py3-setuptools_scm
	py3-wheel
	"
checkdepends="py3-pytest"
subpackages="$pkgname-doc $pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/liquidctl/liquidctl/archive/v$pkgver.tar.gz"

prepare() {
	default_prepare

	# `uaccess` is (e)logind-specific.
	sed -i 's/TAG+="uaccess"/GROUP="plugdev"/' extra/linux/71-liquidctl.rules
}

build() {
	export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" .dist/*.whl
	install -Dm644 extra/linux/71-liquidctl.rules -t "$pkgdir/usr/lib/udev/rules.d/"
	install -Dm644 liquidctl.8 -t "$pkgdir/usr/share/man/man8/"
}

sha512sums="
b909e31d892519d88be09d4bab94a864b4fe4bc83fe965c94fbfe2f6867ee423e0dd781942612a188dd787c5e6ff0cf27981d0ce13c266ba98543b23a4da09de  liquidctl-1.13.0.tar.gz
"
