SUMMARY="Python bindings for ØMQ"
DESCRIPTION="
This package contains Python bindings for ØMQ. \
ØMQ is a lightweight and fast messaging implementation."
HOMEPAGE="https://zeromq.org/"
COPYRIGHT="2009-2019, Brian Granger, Min Ragan-Kelley"
LICENSE="GNU LGPL v3"
REVISION="3"
SOURCE_URI="https://github.com/zeromq/pyzmq/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="32f7618b8104021bc96cbd60be4330bdf37b929e8061dbce362c9f3478a08e21"

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

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

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libzmq$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:pkg_config$secondaryArchSuffix
	"
PYTHON_PACKAGES=(python3 python38)
PYTHON_VERSIONS=(3.7 3.8)
if [ -z "$secondaryArchSuffix" ]; then
	PYTHON_PACKAGES+=(python)
	PYTHON_VERSIONS+=(2.7)
fi
for i in "${!PYTHON_PACKAGES[@]}"; do
pythonPackage=${PYTHON_PACKAGES[i]}
pythonVersion=${PYTHON_VERSIONS[$i]}
maybe_pyzmqNoSuffix=
if [ "$targetArchitecture" = "x86_gcc2" ]; then
	maybe_pyzmqNoSuffix="pyzmq_$pythonPackage = $portVersion"
fi
eval "PROVIDES_${pythonPackage}=\"\
	pyzmq${secondaryArchSuffix}_$pythonPackage = $portVersion\n\
	$maybe_pyzmqNoSuffix\
	\"; \
REQUIRES_$pythonPackage=\"\
	haiku$secondaryArchSuffix\n\
	lib:libzmq$secondaryArchSuffix\n\
	cmd:python$pythonVersion\
	\""
BUILD_REQUIRES="$BUILD_REQUIRES
	setuptools_$pythonPackage"
BUILD_PREREQUIRES="$BUILD_PREREQUIRES
	cmd:cython${pythonVersion}${secondaryArchSuffix}
	cmd:python$pythonVersion"
done

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

		# GENERIC: all python_setuptools-based installs need this
		python=python$pythonVersion
		pythonVersion=$($python --version 2>&1 | sed 's/Python //' | head -c3)
		installLocation=$prefix/lib/python$pythonVersion/vendor-packages/
		export PYTHONPATH=$installLocation:$PYTHONPATH
		mkdir -p $installLocation
		rm -rf build
		$python setup.py install \
			--root=/ --prefix=$prefix

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