SUMMARY="A library for manipulating fonts"
DESCRIPTION="FontTools is a library for manipulating fonts, written in Python.\
 It supports TrueType, OpenType, AFM and to an extent Type 1 and some \
Mac-specific formats."
HOMEPAGE="https://github.com/behdad/fonttools"
COPYRIGHT="1999-2004 Just van Rossum, Letterror, The Netherlands."
LICENSE="FONTTOOLS"
REVISION="1"
SOURCE_URI="https://github.com/fonttools/fonttools/archive/$portVersion.tar.gz"
SOURCE_FILENAME="fonttools-$portVersion.tar.gz"
CHECKSUM_SHA256="0c92b058ccbcd44f71fe094c06bba105c989ae552852486411cd19a3763eed2c"

ARCHITECTURES="any"

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

BUILD_REQUIRES="
	haiku_devel
	"

PYTHON_PACKAGES=(python3)
PYTHON_VERSIONS=(3.7)
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\n\
	setuptools_$pythonPackage\n\
	\""
BUILD_REQUIRES="$BUILD_REQUIRES
	setuptools_$pythonPackage"
BUILD_PREREQUIRES="$BUILD_PREREQUIRES
	cmd:python$pythonVersion"
done

PROVIDES_python3="$PROVIDES_python3
	cmd:fonttools
	cmd:pyftinspect
	cmd:pyftmerge
	cmd:pyftsubset
	cmd:ttx
	"
REPLACES_python3="
	python3_fonttools
	"

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* \
			$binDir
	done

	mkdir -p $(dirname $manDir)
	mv $prefix/share/man $manDir
	rmdir $prefix/share
}
