summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dev-python/urllib3/files/urllib3-1.26.2-brotlicffi.patch65
-rw-r--r--dev-python/urllib3/urllib3-1.26.2-r1.ebuild65
2 files changed, 130 insertions, 0 deletions
diff --git a/dev-python/urllib3/files/urllib3-1.26.2-brotlicffi.patch b/dev-python/urllib3/files/urllib3-1.26.2-brotlicffi.patch
new file mode 100644
index 00000000000..b7cbf9bb7e9
--- /dev/null
+++ b/dev-python/urllib3/files/urllib3-1.26.2-brotlicffi.patch
@@ -0,0 +1,65 @@
+From 14bcf7004a143f7a6fb2df9a48196a113d531f50 Mon Sep 17 00:00:00 2001
+From: Seth Michael Larson <sethmichaellarson@gmail.com>
+Date: Tue, 1 Dec 2020 20:09:32 -0600
+Subject: [PATCH] Switch to Brotli C bindings for CPython, brotlicffi for
+ non-CPython
+
+---
+ setup.cfg | 3 ++-
+ setup.py | 5 ++++-
+ src/urllib3/response.py | 5 ++++-
+ src/urllib3/util/request.py | 5 ++++-
+ 7 files changed, 16 insertions(+), 18 deletions(-)
+
+diff --git a/setup.cfg b/setup.cfg
+index 90b79d8c5..31a465b58 100644
+--- a/setup.cfg
++++ b/setup.cfg
+@@ -15,7 +15,7 @@ requires-dist =
+ idna>=2.0.0; extra == 'secure'
+ certifi; extra == 'secure'
+ PySocks>=1.5.6,<2.0,!=1.5.7; extra == 'socks'
+- brotlipy>=0.6.0; extra == 'brotli'
++ brotlicffi>=0.8.0; extra == 'brotli'
+
+ [tool:pytest]
+ xfail_strict = true
+diff --git a/setup.py b/setup.py
+index 2d449b095..02071aa58 100755
+--- a/setup.py
++++ b/setup.py
+@@ -109,7 +109,7 @@
+ requires=[],
+ python_requires=">=3.6, <4",
+ extras_require={
+- "brotli": ["brotlipy>=0.6.0"],
++ "brotli": ["brotlicffi>=0.8.0"],
+ "secure": [
+ "pyOpenSSL>=0.14",
+ "cryptography>=1.3.4",
+diff --git a/src/urllib3/response.py b/src/urllib3/response.py
+index 77b6ffc16..d277120ee 100644
+--- a/src/urllib3/response.py
++++ b/src/urllib3/response.py
+@@ -7,7 +7,7 @@
+ from socket import timeout as SocketTimeout
+
+ try:
+- import brotli
++ import brotlicffi as brotli
+ except ImportError:
+ brotli = None
+
+diff --git a/src/urllib3/util/request.py b/src/urllib3/util/request.py
+index 6cbdad9b4..64d40641d 100644
+--- a/src/urllib3/util/request.py
++++ b/src/urllib3/util/request.py
+@@ -11,7 +11,7 @@
+
+ ACCEPT_ENCODING = "gzip,deflate"
+ try:
+- import brotli as _unused_module_brotli # noqa: F401
++ import brotlicffi as _unused_module_brotli # noqa: F401
+ except ImportError:
+ pass
+ else:
diff --git a/dev-python/urllib3/urllib3-1.26.2-r1.ebuild b/dev-python/urllib3/urllib3-1.26.2-r1.ebuild
new file mode 100644
index 00000000000..2345ae630e3
--- /dev/null
+++ b/dev-python/urllib3/urllib3-1.26.2-r1.ebuild
@@ -0,0 +1,65 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{6,7,8,9} pypy3 )
+PYTHON_REQ_USE="ssl(+)"
+
+inherit distutils-r1
+
+DESCRIPTION="HTTP library with thread-safe connection pooling, file post, and more"
+HOMEPAGE="https://github.com/urllib3/urllib3"
+SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~x64-macos"
+IUSE="brotli test"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+ >=dev-python/PySocks-1.5.8[${PYTHON_USEDEP}]
+ <dev-python/PySocks-2.0[${PYTHON_USEDEP}]
+ dev-python/certifi[${PYTHON_USEDEP}]
+ >=dev-python/cryptography-1.3.4[${PYTHON_USEDEP}]
+ >=dev-python/pyopenssl-0.14[${PYTHON_USEDEP}]
+ >=dev-python/idna-2.0.0[${PYTHON_USEDEP}]
+ brotli? ( dev-python/brotlicffi[${PYTHON_USEDEP}] )
+"
+BDEPEND="
+ test? (
+ $(python_gen_cond_dep "
+ ${RDEPEND}
+ dev-python/brotlicffi[\${PYTHON_USEDEP}]
+ dev-python/mock[\${PYTHON_USEDEP}]
+ dev-python/pytest[\${PYTHON_USEDEP}]
+ dev-python/pytest-freezegun[\${PYTHON_USEDEP}]
+ >=dev-python/trustme-0.5.3[\${PYTHON_USEDEP}]
+ >=www-servers/tornado-4.2.1[\${PYTHON_USEDEP}]
+ " python3_{6,7,8,9})
+ )
+"
+
+python_prepare_all() {
+ # https://github.com/urllib3/urllib3/issues/1756
+ sed -e 's:10.255.255.1:240.0.0.0:' \
+ -i test/__init__.py || die
+ # tests failing if 'localhost.' cannot be resolved
+ sed -e 's:test_dotted_fqdn:_&:' \
+ -i test/with_dummyserver/test_https.py || die
+ sed -e 's:test_request_host_header_ignores_fqdn_dot:_&:' \
+ -i test/with_dummyserver/test_socketlevel.py || die
+
+ distutils-r1_python_prepare_all
+}
+
+python_test() {
+ local -x CI=1
+ # FIXME: get tornado ported
+ case ${EPYTHON} in
+ python3*)
+ pytest -vv || die "Tests fail with ${EPYTHON}"
+ ;;
+ esac
+}