SUMMARY="Another Python SQLite Wrapper"
DESCRIPTION="A Python wrapper for the SQLite embedded relational database \
engine. In contrast to other wrappers such as pysqlite it focuses on being a \
minimal layer over SQLite attempting just to translate the complete SQLite \
API into Python."
HOMEPAGE="https://github.com/rogerbinns/apsw/
	https://pypi.org/project/apsw/"
COPYRIGHT="2004-2021 Roger Binns"
LICENSE="OSI"
REVISION="1"
SOURCE_URI="https://github.com/rogerbinns/apsw/archive/3.36.0-r1.tar.gz"
CHECKSUM_SHA256="133ee2291851e0144661eba25517c7feb026c6d5896df90ef7ea0feddf03a842"
SOURCE_DIR="apsw-3.36.0-r1"

ARCHITECTURES="all"

PROVIDES="
	$portName = $portVersion
	"
REQUIRES="
	haiku
	lib:libsqlite3$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku_devel
	sqlite_devel >= 3.36
	"

PYTHON_PACKAGES=(python python3 python38 python39)
PYTHON_VERSIONS=(2.7 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\
	\"; \
REQUIRES_$pythonPackage=\"\
	haiku\n\
	cmd:python$pythonVersion\
	\""
BUILD_REQUIRES="$BUILD_REQUIRES
	setuptools_$pythonPackage
	devel:libsqlite3$secondaryArchSuffix"
BUILD_PREREQUIRES="$BUILD_PREREQUIRES
	cmd:python$pythonVersion
	cmd:gcc$secondaryArchSuffix"
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_ext --enable=load_extension install \
			--root=/ --prefix=$prefix

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