SUMMARY="Backport of new features in Python's tempfile module"
DESCRIPTION="This package provides backports of new features in Python's \
tempfile_ module under the backports_ namespace."
HOMEPAGE="https://github.com/pjdelport/backports.tempfile/"
COPYRIGHT="2016-2017 Pi Delport"
LICENSE="PSF-2.3"
REVISION="1"
SOURCE_URI="https://github.com/PiDelport/backports.tempfile/archive/refs/tags/v$portVersion.tar.gz"
CHECKSUM_SHA256="597de6793dd1abcf2aea80ae81e8cbf0af4afb117cd48fa1dc3862f85f48c389"
SOURCE_FILENAME="backports-tempfile-v$portVersion.tar.gz"
SOURCE_DIR="backports.tempfile-$portVersion"

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

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

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

PROVIDES_python3="$PROVIDES_python3
	cmd:qr3.7
	"
PROVIDES_python38="$PROVIDES_python38
	cmd:qr3.8
	"
PROVIDES_python39="$PROVIDES_python39
	cmd:qr3.9
	"

SETUPTOOLS_SCM_PRETEND_VERSION=$portVersion
export SETUPTOOLS_SCM_PRETEND_VERSION

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
}
