SUMMARY="A CLI for testing internet bandwidth using speedtest.net"
DESCRIPTION="speedtest-cli is a command-line interface for testing internet \
bandwidth using speedtest.net. Note that latency reported by this tool should \
not be relied on as a value indicative of ICMP style latency; rather, it is a \
relative value used for determining the lowest latency server for performing \
the actual speed test against.
Also note that its results may also be inconsistent with speedtest.net due to \
the website's migration to using pure socket tests instead of HTTP based ones, \
the application being written in Python, \
differing performance between Python versions, \
and CPU and Memory capacity and speed."
HOMEPAGE="https://github.com/sivel/speedtest-cli"
COPYRIGHT="2012-2018 Matt Martz"
LICENSE="Apache v2"
REVISION="1"
SOURCE_URI="$HOMEPAGE/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="5e22f2dcce1c9020f33faf559b22727483f022008a2912b85d573e578374b6a0"
SOURCE_FILENAME="speedtest-cli-$portVersion.tar.gz"
SOURCE_DIR="speedtest-cli-$portVersion"

ARCHITECTURES="any"

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

PYTHON_PACKAGES=(python python3)
PYTHON_VERSIONS=(2.7 3.6)
for i in "${!PYTHON_PACKAGES[@]}"; do
pythonPackage=${PYTHON_PACKAGES[i]}
pythonVersions=${PYTHON_VERSIONS[$i]}
eval "PROVIDES_${pythonPackage}=\"\
	${portName}_$pythonPackage = $portVersion\n\
	cmd:speedtest_cli_$pythonPackage
	\"; \
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

		rm -rf $binDir/speedtest
		mv $binDir/speedtest-cli $binDir/speedtest-cli-$pythonPackage
		packageEntries  $pythonPackage \
			$prefix/lib/python* \
			$binDir
	done
}
