SUMMARY="A generic syntax highlighter"
DESCRIPTION="It is a generic syntax highlighter for general use in all kinds \
of software such as forum systems, wikis or other applications that need to \
prettify source code. Highlights are:

* a wide range of common languages and markup formats is supported
* special attention is paid to details that increase highlighting quality
* support for new languages and formats are added easily; most languages use a \
simple regex-based lexing mechanism
* a number of output formats is available, among them HTML, RTF, LaTeX and \
ANSI sequences
* it is usable as a command-line tool and as a library
* ... and it highlights even Brainf*ck!"
HOMEPAGE="https://pygments.org/"
COPYRIGHT="2006-2022 by the Pygments team"
LICENSE="BSD (2-clause)"
REVISION="1"
SOURCE_URI="https://pypi.org/packages/source/P/Pygments/Pygments-$portVersion.tar.gz"
CHECKSUM_SHA256="4e426f72023d88d03b2fa258de560726ce890ff3b630f88c21cbb8b2503b8c6a"
SOURCE_DIR="Pygments-$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

PROVIDES_python="$PROVIDES_python
	cmd:pygmentize = $portVersion
	"
PROVIDES_python3="$PROVIDES_python3
	cmd:pygmentize3 = $portVersion
	"
PROVIDES_python38="$PROVIDES_python38
	cmd:pygmentize3.8 = $portVersion
	"
PROVIDES_python39="$PROVIDES_python39
	cmd:pygmentize3.9 = $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 = python3 ]; then
			mv $binDir/pygmentize $binDir/pygmentize3
		fi
		if [ $pythonPackage = python38 ]; then
			mv $binDir/pygmentize $binDir/pygmentize3.8
		fi
		if [ $pythonPackage = python39 ]; then
			mv $binDir/pygmentize $binDir/pygmentize3.9
		fi
		packageEntries  $pythonPackage \
			$prefix/lib/python* \
			$binDir
	done
}
