# Contributor: Marian Buschsieweke <marian.buschsieweke@posteo.net>
# Maintainer: Marian Buschsieweke <marian.buschsieweke@posteo.net>
pkgname=py3-simplesat
pkgver=0.8.2
pkgrel=0
pkgdesc="Prototype for SAT-based dependency handling"
url="https://github.com/enthought/sat-solver"
license="BSD-3-Clause"
arch="all"
depends="
	py3-okonomiyaki
	py3-yaml
	python3
	"
makedepends="
	py3-gpep517
	py3-installer
	py3-setuptools
	py3-wheel
	"
checkdepends="
	py3-mock
	py3-pytest
	"
subpackages="
	$pkgname-pyc
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/enthought/sat-solver/archive/refs/tags/v$pkgver.tar.gz

	0001-fix-use-of-assertraisesregexp.patch
	"
builddir="$srcdir/sat-solver-$pkgver"

prepare() {
	default_prepare
	echo "version = '$pkgver'" > simplesat/_version.py
	echo "version_tuple = ($(echo $pkgver | sed -e 's/\./, /g'))" >> simplesat/_version.py

	rm -r old
}

build() {
	gpep517 build-wheel \
		--wheel-dir dist \
		--output-fd 3 3>&1 >&2
}

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

	# See https://github.com/enthought/sat-solver/issues/283
	PATH="$srcdir/testenv/bin:$PATH" "$srcdir"/testenv/bin/python3 \
		-m pytest -v \
		--deselect simplesat/utils/tests/test_collections.py::TestDefaultOrderedDict::test_simple
}

package() {
	python3 -m installer -d "$pkgdir" \
		"$builddir"/dist/*.whl
}

sha512sums="
fb5629af9791a2c071da6e7d2aec0591528390aff00a319bc79c8906937cfe73908e8bb2fa68ff24484d523fa0e1e0b23297b12613f2fe501791580cfd13afe2  py3-simplesat-0.8.2.tar.gz
65e1efc1d17567cfc7531d89f9a2111071d7cd5bec7419a1b81bc234f604dcd32daddac9d9b4f8bbbd9da18c32fc1207311374d298d73fd01b2fff65cc760269  0001-fix-use-of-assertraisesregexp.patch
"
