From 92ffc25b51a23c5570ea8b4874eda882e88b4563 Mon Sep 17 00:00:00 2001
From: Bart Ribbers <bribbers@disroot.org>
Date: Sat, 9 Jan 2021 13:44:27 +0100
Subject: [PATCH] community/py3-pip: upgrade to 20.3.3

---
 community/py3-pip/APKBUILD | 48 ++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 17 deletions(-)

diff --git a/community/py3-pip/APKBUILD b/community/py3-pip/APKBUILD
index 330d895465d8..9e5d7706e111 100644
--- a/community/py3-pip/APKBUILD
+++ b/community/py3-pip/APKBUILD
@@ -4,7 +4,6 @@ pkgname=py3-pip
 pkgver=20.3.3
 pkgrel=0
 pkgdesc="Tool for installing and managing Python packages"
-options="!check" # Requires https://github.com/pypa/scripttest
 url="http://www.pip-installer.org"
 arch="noarch"
 license="MIT"
@@ -34,8 +33,15 @@ makedepends="
 	py3-sphinx-inline-tabs
 	"
 checkdepends="
-	py3-pytest
+	py3-cryptography
+	py3-freezegun
 	py3-mock
+	py3-pretend
+	py3-pytest
+	py3-yaml
+	py3-scripttest
+	py3-virtualenv
+	py3-werkzeug
 	"
 subpackages="
 	$pkgname-doc
@@ -43,7 +49,6 @@ subpackages="
 	$pkgname-bash-completion:bashcomp:noarch
 	"
 source="https://github.com/pypa/pip/archive/$pkgver/pip-$pkgver.tar.gz"
-options="net" # Needed to build docs
 builddir="$srcdir/pip-$pkgver"
 
 provides="py-pip=$pkgver-r$pkgrel" # Backwards compatibility
@@ -55,26 +60,34 @@ prepare() {
 	# Remove certifi usage
 	sed -i 's|from pip._vendor.certifi import where|where = lambda: "/etc/ssl/certs/ca-certificates.crt"|' src/pip/_internal/commands/debug.py
 
-	for f in src/pip/_vendor/*; do
-		if [ "${f##*/}" = __init__.py ]; then
-			continue
-		fi
-		rm -rf "$f"
-	done
-	sed -i -e 's/DEBUNDLED = False/DEBUNDLED = True/' src/pip/_vendor/__init__.py
+	# Do not use furo as HTML theme in docs
+	# furo is not available in Alpine
+	sed -i '/html_theme = "furo"/d' docs/html/conf.py
+
+	# Upstream uses a Python 2/3 compatibility library for csv with Python 3 semantics in tests
+	# We only target Python 3 and csv23 is not (yet) packaged
+	# As of 20.1b1, this workaround was sufficient to get around the missing dependency
+	sed -i -e 's/csv23/csv/g' tests/lib/wheel.py
 }
 
 build() {
 	python3 setup.py build
 
-	# Build manpage
-	cd docs/
-#	PYTHONPATH="$builddir/src/" python3 pip_sphinxext.py
-	PYTHONPATH="$builddir/src/" sphinx-build -W -b man -d build/doctrees/man man build/man -c html
+	# Build manpages
+	PYTHONPATH="$builddir/src/" sphinx-build -b html docs/html docs/build/html
+	PYTHONPATH="$builddir/src/" sphinx-build -b man docs/man docs/build/man -c docs/html
 }
 
 check() {
-	PYTHONPATH="./build/lib" python3 -m pytest
+	# --deselect'ed and -k'ed tests are not compatible with the latest virtualenv
+	# These files contain almost 500 tests so we should enable them back
+	# as soon as pip will be compatible upstream
+	# https://github.com/pypa/pip/pull/8441
+	PYTHONPATH="$PWD/build/lib" pytest -m 'not network' \
+		-k "not test_from_link_vcs_with_source_dir_obtains_commit_id and not test_from_link_vcs_without_source_dir and not test_should_cache_git_sha" \
+		--deselect tests/functional \
+		--deselect tests/lib/test_lib.py \
+		--deselect tests/unit/test_build_env.py
 }
 
 package() {
@@ -82,11 +95,12 @@ package() {
 
 	install -Dm644 docs/build/man/* -t "$pkgdir"/usr/share/man/man1
 
-	PYTHONPATH="$pkgdir"/usr/lib/python3.8/site-packages "$pkgdir"/usr/bin/pip \
+	local _py3ver=$(python3 -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))')
+	PYTHONPATH="$pkgdir"/usr/lib/python$_py3ver/site-packages "$pkgdir"/usr/bin/pip \
 		completion --bash | \
 		install -Dm644 /dev/stdin "$pkgdir"/usr/share/bash-completion/completions/pip
 
-	PYTHONPATH="$pkgdir"/usr/lib/python3.8/site-packages "$pkgdir"/usr/bin/pip \
+	PYTHONPATH="$pkgdir"/usr/lib/python$_py3ver/site-packages "$pkgdir"/usr/bin/pip \
 		completion --zsh | \
 		install -Dm644 /dev/stdin "$pkgdir"/usr/share/zsh/site-functions/_pip
 }
-- 
GitLab