# Template file for 'python-setuptools'
pkgname=python-setuptools
version=5.7
revision=1
noarch=yes
wrksrc="${pkgname#*-}-${version}"
python_versions="2.7 3.4"
hostmakedepends="python-devel python3.4-devel"
makedepends="${hostmakedepends}"
depends="python"
pycompile_module="easy_install.py pkg_resources.py _markerlib setuptools"
provides="python-distribute-${version}_1"
replaces="python-distribute>=0"
short_desc="Easily download, build, install, upgrade, and uninstall Python2 packages"
maintainer="Alessio Sergi <al3hex@gmail.com>"
homepage="https://pypi.python.org/pypi/setuptools"
license="PSF"
distfiles="https://pypi.python.org/packages/source/s/setuptools/setuptools-${version}.tar.gz"
checksum=a8bbdb2d67532c5b5cef5ba09553cea45d767378e42c7003347e53ebbe70f482

post_extract() {
	cp -a ${wrksrc} /tmp/python2.7-build
	cp -a ${wrksrc} /tmp/python3.4-build
	mv /tmp/python{2.7,3.4}-build ${wrksrc}
}

pre_build() {
	cd ${wrksrc}/python3.4-build
	sed -i 's,easy_install =,easy_install3 =,' setup.py
	sed -i 's,#!/usr/bin/env python,&3.4,' setuptools/command/easy_install.py
	sed -i 's,#!/usr/bin/python,&3.4,' setuptools/tests/test_resources.py
}

do_build() {
	cd ${wrksrc}/python2.7-build
	python setup.py build

	cd ${wrksrc}/python3.4-build
	python3.4 setup.py build
}

do_install() {
	cd ${wrksrc}/python2.7-build
	python setup.py install --root=${DESTDIR}

	cd ${wrksrc}/python3.4-build
	python3.4 setup.py install --root=${DESTDIR}
}

python3.4-setuptools_package() {
	noarch=yes
	depends="python3.4"
	pycompile_version="3.4"
	pycompile_module="easy_install.py pkg_resources.py _markerlib setuptools"
	short_desc="${short_desc/Python2/Python3.4}"
	provides="python3-distribute-${version}_1"
	replaces="python3-distribute>=0"
	pkg_install() {
		vmove usr/bin/easy_install-3.4
		vmove usr/bin/easy_install3
		vmove usr/lib/python3.4
	}
}
