# Template file for 'python-sqlparse'
pkgname=python-sqlparse
version=0.1.18
revision=1
noarch=yes
build_style=python-module
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="3-clause-BSD"
distfiles="${PYPI_SITE}/s/sqlparse/sqlparse-${version}.tar.gz"
checksum=39b196c4a06f76d6ac82f029457ca961f662a8bbbb2694eb1dfe4f2b68a2d7cf

pre_build() {
	cp -a ${wrksrc} /tmp/${pkgname#*-}-2.7
	cp -a ${wrksrc} /tmp/${pkgname#*-}-3.4
	mv /tmp/${pkgname#*-}-{2.7,3.4} ${wrksrc}

	cd ${pkgname#*-}-3.4
	mv bin/sqlformat{,3}
	sed -i 's,\(bin/sqlformat\),\13,' setup.py
}
do_build() {
	for pyver in $python_versions; do
		cd ${wrksrc}/${pkgname#*-}-${pyver}
		python${pyver} setup.py build
	done
}
do_install() {
	for pyver in $python_versions; do
		cd ${wrksrc}/${pkgname#*-}-${pyver}
		python${pyver} setup.py install --root=${DESTDIR}
	done
	vlicense COPYING LICENSE
}

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
		vlicense COPYING LICENSE
	}
}
