SUMMARY="A fast implementation of the Cassowary constraint solver"
DESCRIPTION="Kiwi is an efficient C++ implementation of the Cassowary \
constraint solving algorithm. Kiwi is an implementation of the algorithm \
based on the seminal Cassowary paper. It is not a refactoring of the original \
C++ solver. Kiwi has been designed from the ground up to be lightweight and \
fast. Kiwi ranges from 10x to 500x faster than the original Cassowary solver \
with typical use cases gaining a 40x improvement. Memory savings are consistently > 5x."
HOMEPAGE="https://github.com/nucleic/kiwi"
COPYRIGHT="2018-2020, Nucleic team"
LICENSE="BSD (3-clause)"
REVISION="2"
SOURCE_URI="https://github.com/nucleic/kiwi/archive/refs/tags/$portVersion.tar.gz"
CHECKSUM_SHA256="91d56ec628be2513a02c3721d4d8173416daf37c49423fe7a41a0e30c1101269"
SOURCE_DIR="kiwi-$portVersion"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	$portName = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:pkg_config$secondaryArchSuffix
	"

PYTHON_PACKAGES=(python3 python38 python39)
PYTHON_VERSIONS=(3.7 3.8 3.9)
for i in "${!PYTHON_PACKAGES[@]}"; do
pythonPackage=${PYTHON_PACKAGES[i]}
pythonVersion=${PYTHON_VERSIONS[$i]}
eval "PROVIDES_${pythonPackage}=\"\
	${portName}_$pythonPackage = $portVersion\n\
	\"; \
REQUIRES_$pythonPackage=\"\
	haiku$secondaryArchSuffix\n\
	cmd:python$pythonVersion\
	\""
BUILD_REQUIRES="$BUILD_REQUIRES
	setuptools_$pythonPackage
	"
BUILD_PREREQUIRES="$BUILD_PREREQUIRES
	cmd:python$pythonVersion
	"
done


INSTALL()
{
	for i in "${!PYTHON_PACKAGES[@]}"; do
		pythonPackage=${PYTHON_PACKAGES[i]}
		pythonVersion=${PYTHON_VERSIONS[$i]}

		python=python$pythonVersion
		installLocation=$prefix/lib/$python/vendor-packages/
		export PYTHONPATH=$installLocation:$PYTHONPATH
		mkdir -p $installLocation
		rm -rf build
		$python setup.py build install \
			--root=/ --prefix=$prefix

		packageEntries  $pythonPackage \
			$prefix/lib/python*
	done
}
