# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=py-img2pdf
pkgver=0.2.4
pkgrel=0
pkgdesc="Convert images to PDF via direct JPEG inclusion"
url="https://gitlab.mister-muffin.de/josch/img2pdf"
arch="noarch"
license="LGPL"
depends="py-pillow"
makedepends="python2-dev python3-dev py-setuptools"
install=""
subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3"
source="https://pypi.python.org/packages/7e/a2/4f06081f674920be757d894b4bab874e6a3b5227e730cb7618430b366e69/img2pdf-$pkgver.tar.gz"
builddir="$srcdir/img2pdf-$pkgver"

build() {
	cd "$builddir"
	python2 setup.py build
	python3 setup.py build
}

package() {
	mkdir -p "$pkgdir"
}

_py2() {
	replaces="$pkgname"
	depends="${depends//py-/py2-}"
	_py python2
}

_py3() {
	depends="${depends//py-/py3-}"
	_py python3
}

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

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

sha512sums="c2d99da7076411cf4acabe8929fc8af4005ef1f3e3d9edc953f2731b8d41159c9e4637a803765e1405c595daebfb3d519d4c7903003ce0118d8b0c6e88f11860  img2pdf-0.2.4.tar.gz"
