SUMMARY="HTTP library with thread-safe connection pooling, file post, and more"
DESCRIPTION="- Re-use the same socket connection for multiple requests \
(HTTPConnectionPool and HTTPSConnectionPool) with optional client-side \
certificate verification.
- File posting (encode_multipart_formdata).
- Built-in redirection and retries (optional).
- Supports gzip and deflate decoding.
- Thread-safe and sanity-safe.
- Works with AppEngine, gevent, and eventlib.
- Tested on Python 2.6+, Python 3.2+, and PyPy, with 100% unit test coverage.
- Small and easy to understand codebase perfect for extending and building \
upon.

For a more comprehensive solution, have a look at \
Requests <http://python-requests.org/> which is also powered by urllib3"
HOMEPAGE="https://urllib3.readthedocs.io/
	https://pypi.org/project/urllib3/
	https://github.com/urllib3/urllib3"
COPYRIGHT="2008-2018 Andrey Petrov and contributors"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://github.com/shazow/urllib3/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="f71a4db2481ff386b8f8e9952d50a450a6aacb21da0637349d333a8bed110f33"
SOURCE_FILENAME="urllib3-$portVersion.tar.gz"

ARCHITECTURES="any"

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

BUILD_REQUIRES="
	haiku_devel
	setuptools_python
	setuptools_python3
	setuptools_python38
	setuptools_python39
	"
BUILD_PREREQUIRES="
	cmd:python
	cmd:python3
	cmd:python3.8
	cmd:python3.9
	"

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
		\""
	eval "REQUIRES_$pythonPackage=\"
		haiku
		cmd:python$pythonVersion
		\""
done


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
}
