SUMMARY="Python library to read and write audio tags for many formats"
DESCRIPTION="Mutagen is a Python module to handle audio metadata. It supports \
ASF, FLAC, MP4, Monkey's Audio, MP3, Musepack, Ogg Opus, Ogg FLAC, Ogg Speex, \
Ogg Theora, Ogg Vorbis, True Audio, WavPack, OptimFROG, and AIFF audio files. \
All versions of ID3v2 are supported, and all standard ID3v2.4 frames are parsed. \
It can read Xing headers to accurately calculate the bitrate and length of MP3s. \
ID3 and APEv2 tags can be edited regardless of audio format. It can also manipulate \
Ogg streams on an individual packet/page level."
HOMEPAGE="https://github.com/quodlibet/mutagen"
COPYRIGHT="Joe Wreschnig, Michael Urman, Lukáš Lalinský, Christoph Reiter, Ben Ockmore & others"
LICENSE="GNU GPL v2"
REVISION="2"
SOURCE_URI="https://files.pythonhosted.org/packages/source/m/$portName/$portName-$portVersion.tar.gz"
CHECKSUM_SHA256="6397602efb3c2d7baebd2166ed85731ae1c1d475abca22090b7141ff5034b3e1"
SOURCE_DIR="mutagen-$portVersion"

ARCHITECTURES="any"

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

BUILD_REQUIRES="
	haiku_devel
	"

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_$pythonPackage"
BUILD_PREREQUIRES="$BUILD_PREREQUIRES
	cmd:python$pythonVersion"
done

PROVIDES_python3="$PROVIDES_python3
	cmd:mid3cp
	cmd:mid3iconv
	cmd:mid3v2
	cmd:moggsplit
	cmd:mutagen_inspect
	cmd:mutagen_pony
	"

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-data=$dataDir

		if [ $pythonPackage == python3 ]; then
			packageEntries $pythonPackage \
				$prefix/lib/python* \
				$binDir
		else
			rm -rf $binDir
			packageEntries $pythonPackage \
				$prefix/lib/python*
		fi
	done
}
