# Template file for 'python-virtualenv'
pkgname=python-virtualenv
version=1.11.6
revision=1
noarch=yes
wrksrc="${pkgname#*-}-${version}"
python_versions="2.7 3.4"
build_style=python-module
hostmakedepends="python-setuptools python3.4-setuptools"
makedepends="python-devel python3.4-devel"
depends="python python-setuptools"
pycompile_module="virtualenv.py"
short_desc="Virtual Python2 environment builder"
maintainer="Alessio Sergi <al3hex@gmail.com>"
homepage="https://virtualenv.pypa.io/"
license="MIT"
distfiles="https://pypi.python.org/packages/source/v/${pkgname#*-}/${pkgname#*-}-${version}.tar.gz"
checksum=3e7a4c151e2ee97f51db0215bfd2a073b04a91e9786df6cb67c916f16abe04f7

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,virtualenv=,virtualenv3=,' setup.py
	sed -i 's,#!/usr/bin/env python,&3.4,' virtualenv.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}
}

post_install() {
	vlicense LICENSE.txt LICENSE
}

python3.4-virtualenv_package() {
	noarch=yes
	depends="python3.4 python3.4-setuptools"
	pycompile_version="3.4"
	pycompile_module="virtualenv.py"
	short_desc="${short_desc/Python2/Python3.4}"
	pkg_install() {
		vmove usr/bin/virtualenv-3.4
		vmove usr/bin/virtualenv3
		vmove usr/lib/python3.4
		vlicense ${wrksrc}/LICENSE.txt LICENSE
	}
}
