SUMMARY="Python SQL Toolkit and Object Relational Mapper"
DESCRIPTION="Python SQL toolkit and Object Relational Mapper that gives \
application developers the full power and flexibility of SQL.

It provides a full suite of well known enterprise-level persistence patterns, \
designed for efficient and high-performing database access, adapted into a \
simple and Pythonic domain language."
HOMEPAGE="https://www.sqlalchemy.org/"
COPYRIGHT="2006-2019 SQLAlchemy authors and contributors"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://pypi.org/packages/source/S/SQLAlchemy/SQLAlchemy-$portVersion.tar.gz"
CHECKSUM_SHA256="758fc8c4d6c0336e617f9f6919f9daea3ab6bb9b07005eda9a1a682e24a6cacc"
SOURCE_DIR="SQLAlchemy-$portVersion"

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

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

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	gcc$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\
	cmd:alembic$pythonVersion\n\
	\"; \
REQUIRES_$pythonPackage=\"\
	haiku$secondaryArchSuffix\n\
	cmd:python$pythonVersion\
	\""
BUILD_REQUIRES="$BUILD_REQUIRES
	setuptools_$pythonPackage"
BUILD_PREREQUIRES="$BUILD_PREREQUIRES
	cmd:python$pythonVersion"
done

if [ "$targetArchitecture" = "x86_gcc2" ]; then
	PROVIDES_python3+="
		sqlalchemy_python3 = $portVersion
		"
	PROVIDES_python38+="
		sqlalchemy_python38 = $portVersion
		"
	PROVIDES_python39+="
		sqlalchemy_python39 = $portVersion
		"
fi

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

		rm -rf "$sourceDir"-$pythonPackage
		cp -a "$sourceDir" "$sourceDir"-$pythonPackage
		cd "$sourceDir"-$pythonPackage

		python=python$pythonVersion
		$python setup.py build
	done
}

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

		cd "$sourceDir"-$pythonPackage

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

		install -m 755 -d "$docDir"
		install -m 644 -t "$docDir" LICENSE

		packageEntries $pythonPackage \
			"$docDir" \
			"$prefix"/lib/$python
	done

	cd "$sourceDir"
	install -m 755 -d "$docDir"
	install -m 644 -t "$docDir" AUTHORS LICENSE README.*
}
