SUMMARY="Python library for working with RDF"
DESCRIPTION="RDFLib is a Python library for working with RDF, a simple \
yet powerful language for representing information as graphs."
HOMEPAGE="https://github.com/RDFLib/rdflib"
COPYRIGHT="2002-2017 RDFLib Team"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://pypi.io/packages/source/r/rdflib/rdflib-$portVersion.tar.gz"
CHECKSUM_SHA256="78149dd49d385efec3b3adfbd61c87afaf1281c30d3fcaf1b323b34f603fb155"

ARCHITECTURES="any"

PROVIDES="
	rdflib = $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
		cmd:csv2rdf_$pythonVersion
		cmd:rdf2dot_$pythonVersion
		cmd:rdfgraphisomorphism_$pythonVersion
		cmd:rdfpipe_$pythonVersion
		cmd:rdfs2dot_$pythonVersion
		\""
	eval "REQUIRES_$pythonPackage=\"
		haiku
		cmd:python$pythonVersion
		\""
	if [ $pythonPackage = python3 ]; then
		PROVIDES_python3+="
			cmd:csv2rdf
			cmd:rdf2dot
			cmd:rdfgraphisomorphism
			cmd:rdfpipe
			cmd:rdfs2dot
			"
	fi
	BUILD_REQUIRES="$BUILD_REQUIRES
		setuptools_$pythonPackage"
	BUILD_PREREQUIRES="$BUILD_PREREQUIRES
		cmd:python$pythonVersion"
	TEST_REQUIRES="$TEST_REQUIRES
		nose_$pythonPackage"
done

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

		rm -rf "$sourceDir"-$pythonPackage
		cp -a "$sourceDir" "$sourceDir"-$pythonPackage
		cd "$sourceDir"-$pythonPackage

		python=python$pythonVersion
		$python setup.py build
	done
}

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

		cd "$sourceDir"-$pythonPackage

		python=python$pythonVersion
		installLocation=$prefix/lib/$python/vendor-packages/
		export PYTHONPATH=$installLocation
		mkdir -p "$installLocation"
		$python setup.py install \
			--root=/ --prefix="$prefix"

		maybeBinDir="$binDir"
		if [ "$pythonPackage" != python3 ]; then
			rm -rf "$binDir"
			maybeBinDir=
		fi

		packageEntries $pythonPackage \
			"$prefix"/lib/$python \
			$maybeBinDir
	done
}

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

		cd "$sourceDir"-$pythonPackage

		python=python$pythonVersion
		$python setup.py test
	done
}
