SUMMARY="A Python ASN.1 library with a pythonic API"
DESCRIPTION="asn1crypto is a fast, pure Python library for parsing and \
serializing ASN.1 structures."
HOMEPAGE="https://github.com/wbond/asn1crypto"
COPYRIGHT="2015-2019 Will Bond"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://github.com/wbond/asn1crypto/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="1aeb3e243772fdbf815867b41320436b86f05a6aa14265d90910da780910f39d"
SOURCE_FILENAME="asn1crypto-$portVersion.tar.gz"

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\
	\"; \
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"
		rm -rf build
		mkdir -p "$installLocation"
		$python setup.py build install --root=/ --prefix="$prefix"

		install -m 755 -d "$dataDir"/licenses
		install -m 644 -T LICENSE "$dataDir"/licenses/asn1crypto

		packageEntries $pythonPackage \
			"$dataDir" \
			"$prefix"/lib/$python
	done

	install -m 755 -d "$dataDir"/licenses "$docDir"/docs
	install -m 644 -T LICENSE "$dataDir"/licenses/asn1crypto
	install -m 644 -t "$docDir" changelog.md readme.md
	install -m 644 -t "$docDir"/docs docs/*
}

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

		python=python$pythonVersion
		$python run.py tests
	done
}
