Mail archive
alpine-aports

[alpine-aports] [PATCH] testing/py-matplotlib: Build py2 and py3 version as subpkgs

From: Marian Buschsieweke <marian.buschsieweke_at_ovgu.de>
Date: Sun, 20 May 2018 20:32:01 +0200

---
 testing/py-matplotlib/APKBUILD | 69 +++++++++++++++++++++++++++-------
 1 file changed, 55 insertions(+), 14 deletions(-)
diff --git a/testing/py-matplotlib/APKBUILD b/testing/py-matplotlib/APKBUILD
index 45e057e3f6..bb3d4886b0 100644
--- a/testing/py-matplotlib/APKBUILD
+++ b/testing/py-matplotlib/APKBUILD
_at_@ -3,39 +3,80 @@
 pkgname=py-matplotlib
 _pkgname=matplotlib
 pkgver=1.5.1
-pkgrel=2
+pkgrel=3
 pkgdesc="A Python library for plots"
 url="http://matplotlib.org"
 arch="all !s390x"
 license="custom"
-depends="python2 py-numpy python2-tkinter py-dateutil py-parsing py-tz py-cycler"
-makedepends="python2-dev gfortran py-numpy-dev freetype-dev libpng-dev tk-dev
-	py-setuptools"
-subpackages="$pkgname-doc $pkgname-tests"
+depends=""
+_depends_py2="python2 py2-numpy python2-tkinter py2-dateutil py2-parsing py2-tz
+	py2-cycler"
+_depends_py3="python3 py3-numpy python3-tkinter py3-dateutil py3-parsing py3-tz
+	py3-cycler"
+makedepends="python3-dev python2-dev gfortran py-numpy-dev freetype-dev
+	libpng-dev tk-dev py-setuptools ${_depends_py2} ${_depends_py3}"
+subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3
+	py2-${pkgname#py-}-tests:_py2_tests py3-${pkgname#py-}-tests:_py3_tests
+	$pkgname-doc"
 source="$_pkgname-$pkgver.tar.gz::https://github.com/matplotlib/$_pkgname/archive/v$pkgver.tar.gz"
 builddir="$srcdir/$_pkgname-$pkgver"
 
 build() {
 	cd "$builddir"
 	python2 setup.py build || return 1
+	python3 setup.py build || return 1
 }
 
 package() {
+	mkdir -p "$pkgdir"
+}
+
+_py2() {
+	replaces="$pkgname"
+	depends="$depends $_depends_py2"
+	_py python2
+}
+
+_py3() {
+	depends="$depends $_depends_py3"
+	_py python3
+	# Remove documentation, doc-subpkg will use python2 version
+	rm -rf "$subpkgdir/usr/share"
+}
+
+doc() {
+	mkdir -p "${subpkgdir}/usr"
+	mv "${pkgdir}/../py2-$_pkgname/usr/share" "$subpkgdir/usr/"
+}
+
+_py() {
+	local python="$1"
+	pkgdesc="$pkgdesc (for $python)"
 	cd "$builddir"
 
-	python2 setup.py install --prefix=/usr --root="$pkgdir" || return 1
-	install -m755 -d "$pkgdir"/usr/share/licenses/custom/$pkgname
-	install -m644 LICENSE/* "$pkgdir"/usr/share/licenses/custom/$pkgname/
+	$python setup.py install --prefix=/usr --root="$subpkgdir" || return 1
+	install -m755 -d "$subpkgdir"/usr/share/licenses/custom/$subpkgname
+	install -m644 LICENSE/* "$subpkgdir"/usr/share/licenses/custom/$subpkgname/
+}
+
+_py2_tests() {
+	depends="$depends $_depends_py2 py2-nose"
+	_py_tests python2 "$(python2 -c 'import site; print(site.getsitepackages()[0])')/$_pkgname"
+}
+
+_py3_tests() {
+	depends="$depends $_depends_py3 py3-nose"
+	_py_tests python3 "$(python3 -c 'import site; print(site.getsitepackages()[0])')/$_pkgname"
 }
 
-tests() {
-	pkgdesc="$pkgdesc (tests)"
+_py_tests() {
+	local python="$1"
+	local sitepath="$2"
+	pkgdesc="$pkgdesc (tests for $python)"
 	arch="noarch"
-	depends="$depends py-nose"
-	local sitepath="$(python2 -c 'import site; print(site.getsitepackages()[0])')/$_pkgname"
 
-	mkdir -p "$subpkgdir"$sitepath
-	mv "$pkgdir"$sitepath/tests "$subpkgdir"$sitepath/
+	mkdir -p "$subpkgdir/$sitepath"
+	mv "${pkgdir}/../${subpkgname%-tests}/${sitepath}/tests" "$subpkgdir/$sitepath/"
 }
 
 md5sums="b22dc4962f36aab919a7125b3b35953b  matplotlib-1.5.1.tar.gz"
-- 
2.17.0
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Sun May 20 2018 - 20:32:01 GMT