# Template file for 'python-sqlparse'
pkgname=python-sqlparse
version=0.1.15
revision=1
noarch=yes
wrksrc="sqlparse-${version}"
python_versions="2.7 3.4"
hostmakedepends="python-setuptools python3.4-setuptools"
depends="python"
pycompile_module="sqlparse"
short_desc="Non-validating SQL parser for Python2"
maintainer="Alessio Sergi <al3hex@gmail.com>"
homepage="https://github.com/andialbrecht/sqlparse"
license="BSD"
distfiles="${PYPI_SITE}/s/sqlparse/sqlparse-${version}.tar.gz"
checksum=ce92c9f134b1cd461a27c502197464b5f245261ad0fbb26d7bf659f28a5c11b2

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
	mv bin/sqlformat{,3}
	sed -i 's,#!/usr/bin/env python,&3.4,' bin/sqlformat3
	sed -i "s,'bin/sqlformat','bin/sqlformat3'," setup.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-sqlparse_package() {
	noarch=yes
	depends="python3.4"
	pycompile_version="3.4"
	pycompile_module="sqlparse"
	short_desc="${short_desc/Python2/Python3.4}"
	pkg_install() {
		vmove usr/bin/sqlformat3
		vmove usr/lib/python3.4
	}
}
