Subject: [alpine-aports] [PATCH] testing/py-beautifulsoup4: fix python 3 support

From: Drew DeVault <[email-masked]>
Date: Sat, 20 Jan 2018 10:28:33 -0500

---
 testing/py-beautifulsoup4/APKBUILD | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/testing/py-beautifulsoup4/APKBUILD b/testing/py-beautifulsoup4/APKBUILD
index 26dce245b0..694e68c1b6 100644
--- a/testing/py-beautifulsoup4/APKBUILD
+++ b/testing/py-beautifulsoup4/APKBUILD
@@ -8,17 +8,29 @@ pkgdesc="A Python HTML/XML parser"
 url="http://www.crummy.com/software/BeautifulSoup/index.html"
 arch="noarch"
 license="MIT"
-makedepends="python2-dev py-setuptools python3-dev"
+makedepends="python2-dev py-setuptools python3-dev py2-unittest2"
 subpackages="py3-$_pkgname:_py3 py2-$_pkgname:_py2"
 source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
 builddir="$srcdir"/$_pkgname-$pkgver
 
+prepare() {
+	cd "$srcdir"
+	cp -r "$_pkgname-$pkgver" "$_pkgname-$pkgver"-py3
+}
+
 build() {
 	cd "$builddir"
 	python2 setup.py build || return 1
+	cd "$builddir"-py3
 	python3 setup.py build || return 1
 }
 
+check() {
+	cd "$builddir"
+	# bs4 unit tests are written for python2
+	python -m unittest discover -s bs4
+}
+
 package() {
 	mkdir -p "$pkgdir"
 }
@@ -26,11 +38,13 @@ package() {
 _py2() {
 	replaces="$pkgname"
 	depends="${depends//py-/py2-}"
+	cd "$builddir"
 	_py python2
 }
 
 _py3() {
 	depends="${depends//py-/py3-}"
+	cd "$builddir"-py3
 	_py python3
 }
 
@@ -39,8 +53,6 @@ _py() {
 	pkgdesc="$pkgdesc (for $python)"
 	depends="$depends $python"
 	install_if="$pkgname=$pkgver-r$pkgrel $python"
-
-	cd "$builddir"
 	$python setup.py install --prefix=/usr --root="$subpkgdir"
 }
 
-- 
2.15.0

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---