SUMMARY="A Python lib for parsing .editorconfig"
DESCRIPTION="EditorConfig makes it easy to maintain the correct  \
coding style when switching between different text editors and \
between different projects. The EditorConfig project maintains \
a file format and plugins for various text editors which allow this \
file format to be read and used by those editors. For information \
on the file format and supported text editors, see the EditorConfig \
website."
HOMEPAGE="https://editorconfig.org/"
COPYRIGHT="2011-2018 EditorConfig Team"
LICENSE="BSD (2-clause)"
REVISION="1"
pyName="EditorConfig"
SOURCE_URI="https://pypi.io/packages/source/${pyName:0:1}/$pyName/$pyName-$portVersion.tar.gz"
CHECKSUM_SHA256="57f8ce78afcba15c8b18d46b5170848c88d56fd38f05c2ec60dbbfcb8996e89e"
SOURCE_DIR="$pyName-$portVersion"

ARCHITECTURES="any"

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

BUILD_REQUIRES="
	haiku_devel
	cmd:cmake
	"

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\n\
	cmd:editorconfig${pythonVersion}\n\
	\"; \
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
		mv $prefix/bin/editorconfig $prefix/bin/editorconfig${pythonVersion}

		packageEntries  $pythonPackage \
			$prefix/lib/python* \
			$prefix/bin

	done
}

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

		cd "$sourceDir"-$pythonPackage

		python=python$pythonVersion

		cmake -DPYTHON_EXECUTABLE=/usr/bin/$python
		ctest .

	done
}
