Subject: [alpine-aports] Add support for python3 to some python packages

From: Leonardo Arena <[email-masked]>
Date: Thu, 21 Dec 2017 15:12:23 +0100

Hi,

are you okay if I merge the attached patches?

I know python3 already includes setuptools, but I need a greater version
than the one currently bundled.

Thanks

/eo
From 42067f6c710fcc7da63cdf3ce318e823df06384c Mon Sep 17 00:00:00 2001
From: Leonardo Arena <[email-masked]>
Date: Thu, 21 Dec 2017 13:45:45 +0000
Subject: [PATCH 1/3] main/py-pyflakes: replacement for pyflakes that supports
 also python3

---
 main/py-pyflakes/APKBUILD | 55 +++++++++++++++++++++++++++++++++++++++++++++++
 main/pyflakes/APKBUILD    | 25 ---------------------
 2 files changed, 55 insertions(+), 25 deletions(-)
 create mode 100644 main/py-pyflakes/APKBUILD
 delete mode 100644 main/pyflakes/APKBUILD

diff --git a/main/py-pyflakes/APKBUILD b/main/py-pyflakes/APKBUILD
new file mode 100644
index 0000000000..2bc9ecb177
--- /dev/null
+++ b/main/py-pyflakes/APKBUILD
@@ -0,0 +1,55 @@
+# Contributor: Peter Bui <[email-masked]>
+# Maintainer: Fabian Affolter <[email-masked]>
+pkgname=py-pyflakes
+_pkgname=${pkgname#py-}
+pkgver=1.6.0
+pkgrel=1
+pkgdesc="A passive checker of Python programs"
+url="https://github.com/pyflakes/pyflakes"
+arch="noarch"
+license="MIT"
+depends=""
+makedepends="python2-dev python3-dev py-setuptools"
+options="!check" #no testsuite
+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"
+
+build() {
+	cd "$builddir"
+	python2 setup.py build
+	python3 setup.py build
+}
+
+package() {
+	cd "$builddir"
+	mkdir -p "$pkgdir"/usr/bin
+}
+
+_py2() {
+       replaces=pyflakes
+       provides="pyflakes-$pkgver-r$pkgrel"
+       _py python2
+}
+
+_py3() {
+       _py python3
+}
+
+_py() {
+       local python="$1"
+       local pyver="${1:6:1}"
+       pkgdesc="$pkgdesc (for $python)"
+       depends="$depends $python"
+       install_if="$pkgname=$pkgver-r$pkgrel $python"
+
+       cd "$builddir"
+       $python setup.py --quiet install --prefix=/usr --root="$subpkgdir"
+       #Add version suffix to executable files.
+       local path; for path in "$subpkgdir"/usr/bin/*; do
+              mv -f "$path" "${path%%}"
+              mv -f "${path%%}" "${path%%}-$pyver"
+       done
+}
+
+sha512sums="7e9c2aad6ebed638a1354cef51c7e1f68b25e59f8caf4694997a9afecd7cd8baa629a9363297ac0d961430f007fd22dcae7dae1bcbd7838a3b5d4285063bc7c5  pyflakes-1.6.0.tar.gz"
diff --git a/main/pyflakes/APKBUILD b/main/pyflakes/APKBUILD
deleted file mode 100644
index 9ed672ec3e..0000000000
--- a/main/pyflakes/APKBUILD
+++ /dev/null
@@ -1,25 +0,0 @@
-# Contributor: Peter Bui <[email-masked]>
-# Maintainer: Fabian Affolter <[email-masked]>
-pkgname=pyflakes
-pkgver=1.6.0
-pkgrel=0
-pkgdesc="A passive checker of Python programs"
-url="https://github.com/pyflakes/pyflakes"
-arch="noarch"
-license="MIT"
-depends="python2"
-makedepends="python2-dev"
-source="https://files.pythonhosted.org/packages/source/${pkgname:0:1}/$pkgname/$pkgname-$pkgver.tar.gz"
-builddir="$srcdir/$pkgname-$pkgver"
-
-build() {
-	cd "$builddir"
-	python2 setup.py build || return 1
-}
-
-package() {
-	cd "$builddir"
-	python2 setup.py install --prefix=/usr --root="$pkgdir" || return 1
-}
-
-sha512sums="7e9c2aad6ebed638a1354cef51c7e1f68b25e59f8caf4694997a9afecd7cd8baa629a9363297ac0d961430f007fd22dcae7dae1bcbd7838a3b5d4285063bc7c5  pyflakes-1.6.0.tar.gz"
-- 
2.15.0

From bbb7106761c6685b2c767f93b4fc28b3dac5a4c6 Mon Sep 17 00:00:00 2001
From: Leonardo Arena <[email-masked]>
Date: Thu, 21 Dec 2017 13:52:55 +0000
Subject: [PATCH 2/3] main/py-flake8: renamed from flake8, add support for
 python3

---
 main/flake8/APKBUILD    | 25 ---------------------
 main/py-flake8/APKBUILD | 58 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 25 deletions(-)
 delete mode 100644 main/flake8/APKBUILD
 create mode 100644 main/py-flake8/APKBUILD

diff --git a/main/flake8/APKBUILD b/main/flake8/APKBUILD
deleted file mode 100644
index 304c4d4089..0000000000
--- a/main/flake8/APKBUILD
+++ /dev/null
@@ -1,25 +0,0 @@
-# Contributor: Peter Bui <[email-masked]>
-# Maintainer: Fabian Affolter <[email-masked]>
-pkgname=flake8
-pkgver=3.4.1
-pkgrel=0
-pkgdesc="A modular source code checker"
-url="https://gitlab.com/pycqa/flake8"
-arch="noarch"
-license="MIT"
-depends="python2 py-setuptools py-mccabe py-pep8 pyflakes"
-makedepends="python2-dev"
-source="https://pypi.io/packages/source/f/$pkgname/$pkgname-$pkgver.tar.gz"
-builddir="$srcdir/$pkgname-$pkgver"
-
-build() {
-	cd "$builddir"
-	python2 setup.py build || return 1
-}
-
-package() {
-	cd "$builddir"
-	python2 setup.py install --prefix=/usr --root="$pkgdir" || return 1
-}
-
-sha512sums="42df8fa0cf6f4bb4f3e52143028dee14d51a645aef19a0bab05000fef577e5bea3cc29f961acb0c98d92b76e635fdd2f0d689e23663a6c14d435d0410be94c87  flake8-3.4.1.tar.gz"
diff --git a/main/py-flake8/APKBUILD b/main/py-flake8/APKBUILD
new file mode 100644
index 0000000000..57450d4fc7
--- /dev/null
+++ b/main/py-flake8/APKBUILD
@@ -0,0 +1,58 @@
+# Contributor: Peter Bui <[email-masked]>
+# Maintainer: Fabian Affolter <[email-masked]>
+pkgname=py-flake8
+_pkgname=${pkgname#py-}
+pkgver=3.4.1
+pkgrel=0
+pkgdesc="A modular source code checker"
+url="https://gitlab.com/pycqa/flake8"
+arch="noarch"
+license="MIT"
+depends="py-mccabe py-pep8 py-pyflakes"
+makedepends="python2-dev python3-dev py-setuptools"
+subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3"
+options="!check" #no testsuite
+source="https://pypi.io/packages/source/f/$_pkgname/$_pkgname-$pkgver.tar.gz"
+builddir="$srcdir/$_pkgname-$pkgver"
+
+build() {
+	cd "$builddir"
+	python2 setup.py build
+	python3 setup.py build
+}
+
+package() {
+	cd "$builddir"
+	mkdir -p "$pkgdir"/usr/bin
+}
+
+_py2() {
+       replaces=flake8
+       provides="flake8-$pkgver-r$pkgrel"
+       depends="${depends//py-/py2-}"
+       _py python2
+}
+
+_py3() {
+	depends="${depends//py-/py3-}"
+       _py python3
+}
+
+_py() {
+       local python="$1"
+       local pyver="${1:6:1}"
+       pkgdesc="$pkgdesc (for $python)"
+       depends="$depends $python"
+       install_if="$pkgname=$pkgver-r$pkgrel $python"
+
+       cd "$builddir"
+       $python setup.py --quiet install --prefix=/usr --root="$subpkgdir"
+       #Add version suffix to executable files.
+       local path; for path in "$subpkgdir"/usr/bin/*; do
+              mv -f "$path" "${path%%}"
+              mv -f "${path%%}" "${path%%}-$pyver"
+       done
+}
+
+
+sha512sums="42df8fa0cf6f4bb4f3e52143028dee14d51a645aef19a0bab05000fef577e5bea3cc29f961acb0c98d92b76e635fdd2f0d689e23663a6c14d435d0410be94c87  flake8-3.4.1.tar.gz"
-- 
2.15.0

From 755d68bcf067ffa6bb127c25f980f435887291a1 Mon Sep 17 00:00:00 2001
From: Leonardo Arena <[email-masked]>
Date: Tue, 19 Dec 2017 12:56:46 +0000
Subject: [PATCH 3/3] main/py-setuptools: upgrade to 38.2.4, add support for
 python3

---
 main/py-setuptools/APKBUILD | 46 ++++++++++++++++++++++++++++++++++-----------
 1 file changed, 35 insertions(+), 11 deletions(-)

diff --git a/main/py-setuptools/APKBUILD b/main/py-setuptools/APKBUILD
index 79d7be9bd3..1bfd725352 100644
--- a/main/py-setuptools/APKBUILD
+++ b/main/py-setuptools/APKBUILD
@@ -2,15 +2,16 @@
 # Maintainer: Fabian Affolter <[email-masked]>
 pkgname=py-setuptools
 _pkgname=${pkgname#py-}
-pkgver=33.1.1
-pkgrel=1
+pkgver=38.2.4
+pkgrel=0
 pkgdesc="A collection of enhancements to the Python distutils"
 url="https://pypi.python.org/pypi/setuptools"
 arch="noarch"
 license="PSF"
-provides="py2-setuptools=$pkgver-r$pkgrel"
-depends="python2"
-makedepends="python2-dev"
+depends=""
+makedepends="python2-dev python3-dev"
+subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3"
+options="!check" #no testsuite
 source="$_pkgname-$pkgver.tar.gz::https://github.com/pypa/$_pkgname/archive/v$pkgver.tar.gz"
 builddir="$srcdir/$_pkgname-$pkgver"
 
@@ -18,17 +19,40 @@ build() {
 	cd "$builddir"
 	python2 bootstrap.py
 	python2 setup.py build
+	python3 bootstrap.py
+	python3 setup.py build
 }
 
 package() {
 	cd "$builddir"
+	mkdir -p "$pkgdir"/usr/bin
+}
+
+_py2() {
+	replaces=$pkgname
+	provides="$pkgname-$pkgver-r$pkgrel"
+	_py python2
+}
 
-	python2 setup.py install --prefix=/usr --root="$pkgdir"
+_py3() {
+	replaces="python3"
+	_py python3
+}
+
+_py() {
+	local python="$1"
+	local pyver="${1:6:1}"
+	pkgdesc="$pkgdesc (for $python)"
+	depends="$depends $python"
+	install_if="$pkgname=$pkgver-r$pkgrel $python"
 
-	# we don't provide a non-suffixed easy_install
-	rm -f "$pkgdir"/usr/bin/easy_install
+	cd "$builddir"
+	$python setup.py --quiet install --prefix=/usr --root="$subpkgdir"
+	#Add version suffix to executable files.
+	local path; for path in "$subpkgdir"/usr/bin/*; do
+		mv -f "$path" "${path%%}"
+		mv -f "${path%%}" "${path%%}-$pyver"
+	done
 }
 
-md5sums="6f325e870730cd90f3ac9608cdf6a82f  setuptools-33.1.1.tar.gz"
-sha256sums="a1ceebce3a0e2c6676ab03d6222a3f3cb403a392acb9e3919da5d1e1bbc447a4  setuptools-33.1.1.tar.gz"
-sha512sums="4cc73881162be28b70cd9abe01bafc676b491608e5d22dd6b688043291eb42f7b1c6cb17d1e0c65a1f88e3896688991d446048e330426bcf3247baecc2eb1d06  setuptools-33.1.1.tar.gz"
+sha512sums="f06badd27f0b797482bf42314edb7ffde7fa80556825b0ef27b125a3fc876b9d2ec26bf2b540f88b39f52fb58536e762c5bef24d9a92115b5f5decdf01f00c6c  setuptools-38.2.4.tar.gz"
-- 
2.15.0