SUMMARY="The PEP 517 Compliant PyQt Build System"
DESCRIPTION="\
PyQt-builder is the PEP 517 compliant build system for PyQt and projects that \
extend PyQt.  It extends the sip build system and uses Qt's ``qmake`` to \
perform the actual compilation and installation of extension modules."
HOMEPAGE="https://www.riverbankcomputing.com/software/pyqt/"
COPYRIGHT="2020 Riverbank Computing Limited"
LICENSE="BSD (2-clause)"
REVISION="1"
SOURCE_URI="https://pypi.io/packages/source/P/PyQt5-sip/PyQt5_sip-$portVersion.tar.gz"
CHECKSUM_SHA256="d3e4489d7c2b0ece9d203ae66e573939f7f60d4d29e089c9f11daa17cfeaae32"
SOURCE_DIR="PyQt5_sip-$portVersion"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	pyqt5_sip$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"

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

	eval "PROVIDES_$pythonPackage=\"
		${portName}_$pythonPackage = $portVersion
		\""
	eval "REQUIRES_$pythonPackage=\"
		haiku$secondaryArchSuffix
		cmd:python$pythonVersion
		\""
BUILD_REQUIRES="$BUILD_REQUIRES
	setuptools_$pythonPackage"
BUILD_PREREQUIRES="$BUILD_PREREQUIRES
	cmd:python$pythonVersion"
done
BUILD_PREREQUIRES+="
	cmd:gcc$secondaryArchSuffix
	"

if [ "$targetArchitecture" = "x86_gcc2" ]; then
	PROVIDES_python38+="
		pyqt5_sip_python38 = $portVersion
		"
	PROVIDES_python39+="
		pyqt5_sip_python39 = $portVersion
		"
fi

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"

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