SUMMARY="Add a progress meter to your loops in a second"
DESCRIPTION="tqdm derives from the Arabic word *taqaddum* (تقدّم) which can mean *progress*, and \
is an abbreviation for *I love you so much* in Spanish *te quiero demasiado*.
Instantly make your loops show a smart progress meter - just wrap any iterable with \
``tqdm(iterable)``, and you're done!"
HOMEPAGE="https://github.com/tqdm/tqdm"
COPYRIGHT="2015-2021 tqdm contributors"
LICENSE="MIT
	MPL v2.0"
REVISION="1"
SOURCE_URI="$HOMEPAGE/archive/refs/tags/v$portVersion.tar.gz"
CHECKSUM_SHA256="c6c0bace914d9e7aab60b46a83f4943e0f136e572f98ab8193f98ce9cbf4ce65"
SOURCE_FILENAME="tqdm-$portVersion.tar.gz"

ARCHITECTURES="all"

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

BUILD_REQUIRES="
	haiku_devel
	"

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
		\""
	eval "REQUIRES_$pythonPackage=\"
		haiku
		cmd:python$pythonVersion
		\""
BUILD_REQUIRES="$BUILD_REQUIRES
	setuptools_scm_$pythonPackage
	pip_$pythonPackage
	wheel_$pythonPackage"
BUILD_PREREQUIRES="$BUILD_PREREQUIRES
	cmd:python$pythonVersion"
done
PROVIDES_python3+="
	cmd:tqdm
	"
PROVIDES_python38+="
	cmd:tqdm38
	"
PROVIDES_python39+="
	cmd:tqdm39
	"

export SETUPTOOLS_SCM_PRETEND_VERSION=$portVersion

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

		if [ "$pythonPackage" = python38 ]; then
			mv "$binDir"/tqdm "$binDir"/tqdm38
		fi
		if [ "$pythonPackage" = python39 ]; then
			mv "$binDir"/tqdm "$binDir"/tqdm39
		fi

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