# Contributor: <xmingske@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
setvar _pkgname = 'chardet'
setvar pkgname = "py-$_pkgname"
setvar pkgver = '3.0.4'
setvar pkgrel = '0'
setvar pkgdesc = ""The Universal Character Encoding Detector""
setvar url = ""https://github.com/chardet/chardet/""
setvar arch = ""noarch""
setvar license = ""LGPL 2.1""
setvar depends = """"
setvar makedepends = ""python2-dev python3-dev py-setuptools""
setvar subpackages = ""py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3""
setvar source = ""https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz""
setvar builddir = ""$srcdir/$_pkgname-$pkgver""

proc build {
	cd $builddir
	python2 setup.py build
	python3 setup.py build
}

proc package {
	mkdir -p $pkgdir
}

proc _py2 {
	setvar replaces = "$pkgname"
	_py python2
}

proc _py3 {
	_py python3
}

proc _py {
	local python="$1"
	setvar pkgdesc = ""$pkgdesc (for $python)""
	setvar depends = ""$depends $python""
	setvar install_if = ""$pkgname=$pkgver-r$pkgrel $python""

	cd $builddir
	$python setup.py install --prefix=/usr --root="$subpkgdir" --optimize=1
}

setvar sha512sums = ""61a03b23447a2bfe52ceed4dd1b9afdb5784da1933a623776883ee9f297e341f633e27f0ce0230bd5fdc5fdb5382105ab42736a74a417ddeb9f83af57455dba5  chardet-3.0.4.tar.gz""