SUMMARY="Pure python QR Code generator"
DESCRIPTION="This module uses the Python Imaging Library (PIL) to allow for \
the generation of QR Codes."
HOMEPAGE="https://github.com/lincolnloop/python-qrcode/"
COPYRIGHT="2011 Lincoln Loop"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://github.com/lincolnloop/python-qrcode/archive/refs/tags/v$portVersion.tar.gz"
CHECKSUM_SHA256="051935ae06d8180a5a2413192dd236fdc6a2f3da3ef04af682afbe9d5c3286f4"
SOURCE_FILENAME="qrcode-v$portVersion.tar.gz"
SOURCE_DIR="python-qrcode-$portVersion"

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

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

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	"

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
	lxml_$pythonPackage
	pillow${secondaryArchSuffix}_$pythonPackage
	setuptools_$pythonPackage"
BUILD_PREREQUIRES="$BUILD_PREREQUIRES
	cmd:python$pythonVersion"
done

PROVIDES_python3="$PROVIDES_python3
	cmd:qr3.7
	"
PROVIDES_python38="$PROVIDES_python38
	cmd:qr3.8
	"
PROVIDES_python39="$PROVIDES_python39
	cmd:qr3.9
	"

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/qr $prefix/bin/qr$pythonVersion

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

		packageEntries  $pythonPackage \
			$prefix/bin \
			$prefix/lib/python* \
			$manDir
	done
}
