SUMMARY="Python implementation of the WHATWG Encoding standard"
DESCRIPTION="In order to be compatible with legacy web content when \
interpreting something like Content-Type: text/html; charset=latin1, tools \
need to use a particular set of aliases for encoding labels as well as some \
overriding rules. For example, US-ASCII and iso-8859-1 on the web are actually \
aliases for windows-1252, and an UTF-8 or UTF-16 BOM takes precedence over \
any other encoding declaration. The Encoding standard defines all such details \
so that implementations do not have to reverse-engineer each other."
HOMEPAGE="https://github.com/gsnedders/python-webencodings"
COPYRIGHT="2012 Simon Sapin"
LICENSE="BSD (3-clause)"
REVISION="3"
SOURCE_URI="https://github.com/gsnedders/python-webencodings/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="082367f568a7812aa5f6922ffe3d9d027cd83829dc32bcaac4c874eeed618000"
SOURCE_DIR="python-webencodings-$portVersion"

ARCHITECTURES="any"

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

BUILD_REQUIRES="
	haiku_devel
	"

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"
BUILD_PREREQUIRES="$BUILD_PREREQUIRES
	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

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