SUMMARY="The PyPA recommended tool for installing Python packages"
DESCRIPTION="Install Python packages, replacement for easy_install"
HOMEPAGE="https://pypi.python.org/pypi/pip"
COPYRIGHT="2006-2019 Python Packaging Authority"
LICENSE="Python"
REVISION="2"
SOURCE_URI="https://pypi.io/packages/source/p/pip/pip-$portVersion.tar.gz"
CHECKSUM_SHA256="21207d76c1031e517668898a6b46a9fb1501c7a4710ef5dfd6a40ad9e6757ea7"

ARCHITECTURES="any"

PROVIDES="
	$portName = $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\n\
	cmd:pip$pythonVersion\n\
	\"; \
REQUIRES_$pythonPackage=\"\
	haiku\n\
	cmd:python$pythonVersion\n\
	setuptools_$pythonPackage\n\
	\""
BUILD_REQUIRES="$BUILD_REQUIRES
	setuptools_$pythonPackage"
BUILD_PREREQUIRES="$BUILD_PREREQUIRES
	cmd:python$pythonVersion"
done

PROVIDES_python="$PROVIDES_python
	cmd:pip
	"
REPLACES_python="
	python_pip
	"

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

		if [ $pythonPackage != python ]; then
			rm $binDir/{pip,pip3}
		fi
		packageEntries  $pythonPackage \
			$prefix/lib/python* \
			$binDir
	done
}
