SUMMARY="Internationalized Domain Names in Applications (IDNA)"
DESCRIPTION="Support for the Internationalised Domain Names in Applications \
(IDNA) protocol as specified in RFC 5891 <http://tools.ietf.org/html/rfc5891>."
HOMEPAGE="https://pypi.python.org/pypi/idna"
COPYRIGHT="2013-2019 Kim Davie"
LICENSE="BSD (3-clause)"
REVISION="2"
SOURCE_URI="https://pypi.io/packages/source/i/idna/idna-$portVersion.tar.gz"
CHECKSUM_SHA256="c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407"

ARCHITECTURES="any"

PROVIDES="
	idna = $portVersion
	"
REQUIRES="
	haiku
	"

BUILD_REQUIRES="
	haiku_devel
	setuptools_python
	setuptools_python3
	setuptools_python38
	setuptools_python39
	"
BUILD_PREREQUIRES="
	cmd:python
	cmd:python3
	cmd:python3.8
	cmd:python3.9
	"

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
		\""
	eval "REQUIRES_$pythonPackage=\"
		haiku
		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

		install -m 755 -d "$dataDir"/licenses
		install -m 644 -T LICENSE.rst "$dataDir"/licenses/idna.rst

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

	install -m 755 -d "$dataDir"/licenses "$docDir"
	install -m 644 -T LICENSE.rst "$dataDir"/licenses/idna.rst
	install -m 644 -t "$docDir" README.rst
}

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

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