1 |
commit: 7f754153e019367b53e721d9d9430435124ea90d |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Dec 2 10:10:40 2020 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Dec 2 10:50:19 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7f754153 |
7 |
|
8 |
dev-python/urllib3: Support dev-python/brotlicffi |
9 |
|
10 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
11 |
|
12 |
.../urllib3/files/urllib3-1.26.2-brotlicffi.patch | 65 ++++++++++++++++++++++ |
13 |
dev-python/urllib3/urllib3-1.26.2-r1.ebuild | 65 ++++++++++++++++++++++ |
14 |
2 files changed, 130 insertions(+) |
15 |
|
16 |
diff --git a/dev-python/urllib3/files/urllib3-1.26.2-brotlicffi.patch b/dev-python/urllib3/files/urllib3-1.26.2-brotlicffi.patch |
17 |
new file mode 100644 |
18 |
index 00000000000..b7cbf9bb7e9 |
19 |
--- /dev/null |
20 |
+++ b/dev-python/urllib3/files/urllib3-1.26.2-brotlicffi.patch |
21 |
@@ -0,0 +1,65 @@ |
22 |
+From 14bcf7004a143f7a6fb2df9a48196a113d531f50 Mon Sep 17 00:00:00 2001 |
23 |
+From: Seth Michael Larson <sethmichaellarson@×××××.com> |
24 |
+Date: Tue, 1 Dec 2020 20:09:32 -0600 |
25 |
+Subject: [PATCH] Switch to Brotli C bindings for CPython, brotlicffi for |
26 |
+ non-CPython |
27 |
+ |
28 |
+--- |
29 |
+ setup.cfg | 3 ++- |
30 |
+ setup.py | 5 ++++- |
31 |
+ src/urllib3/response.py | 5 ++++- |
32 |
+ src/urllib3/util/request.py | 5 ++++- |
33 |
+ 7 files changed, 16 insertions(+), 18 deletions(-) |
34 |
+ |
35 |
+diff --git a/setup.cfg b/setup.cfg |
36 |
+index 90b79d8c5..31a465b58 100644 |
37 |
+--- a/setup.cfg |
38 |
++++ b/setup.cfg |
39 |
+@@ -15,7 +15,7 @@ requires-dist = |
40 |
+ idna>=2.0.0; extra == 'secure' |
41 |
+ certifi; extra == 'secure' |
42 |
+ PySocks>=1.5.6,<2.0,!=1.5.7; extra == 'socks' |
43 |
+- brotlipy>=0.6.0; extra == 'brotli' |
44 |
++ brotlicffi>=0.8.0; extra == 'brotli' |
45 |
+ |
46 |
+ [tool:pytest] |
47 |
+ xfail_strict = true |
48 |
+diff --git a/setup.py b/setup.py |
49 |
+index 2d449b095..02071aa58 100755 |
50 |
+--- a/setup.py |
51 |
++++ b/setup.py |
52 |
+@@ -109,7 +109,7 @@ |
53 |
+ requires=[], |
54 |
+ python_requires=">=3.6, <4", |
55 |
+ extras_require={ |
56 |
+- "brotli": ["brotlipy>=0.6.0"], |
57 |
++ "brotli": ["brotlicffi>=0.8.0"], |
58 |
+ "secure": [ |
59 |
+ "pyOpenSSL>=0.14", |
60 |
+ "cryptography>=1.3.4", |
61 |
+diff --git a/src/urllib3/response.py b/src/urllib3/response.py |
62 |
+index 77b6ffc16..d277120ee 100644 |
63 |
+--- a/src/urllib3/response.py |
64 |
++++ b/src/urllib3/response.py |
65 |
+@@ -7,7 +7,7 @@ |
66 |
+ from socket import timeout as SocketTimeout |
67 |
+ |
68 |
+ try: |
69 |
+- import brotli |
70 |
++ import brotlicffi as brotli |
71 |
+ except ImportError: |
72 |
+ brotli = None |
73 |
+ |
74 |
+diff --git a/src/urllib3/util/request.py b/src/urllib3/util/request.py |
75 |
+index 6cbdad9b4..64d40641d 100644 |
76 |
+--- a/src/urllib3/util/request.py |
77 |
++++ b/src/urllib3/util/request.py |
78 |
+@@ -11,7 +11,7 @@ |
79 |
+ |
80 |
+ ACCEPT_ENCODING = "gzip,deflate" |
81 |
+ try: |
82 |
+- import brotli as _unused_module_brotli # noqa: F401 |
83 |
++ import brotlicffi as _unused_module_brotli # noqa: F401 |
84 |
+ except ImportError: |
85 |
+ pass |
86 |
+ else: |
87 |
|
88 |
diff --git a/dev-python/urllib3/urllib3-1.26.2-r1.ebuild b/dev-python/urllib3/urllib3-1.26.2-r1.ebuild |
89 |
new file mode 100644 |
90 |
index 00000000000..2345ae630e3 |
91 |
--- /dev/null |
92 |
+++ b/dev-python/urllib3/urllib3-1.26.2-r1.ebuild |
93 |
@@ -0,0 +1,65 @@ |
94 |
+# Copyright 1999-2020 Gentoo Authors |
95 |
+# Distributed under the terms of the GNU General Public License v2 |
96 |
+ |
97 |
+EAPI=7 |
98 |
+ |
99 |
+PYTHON_COMPAT=( python3_{6,7,8,9} pypy3 ) |
100 |
+PYTHON_REQ_USE="ssl(+)" |
101 |
+ |
102 |
+inherit distutils-r1 |
103 |
+ |
104 |
+DESCRIPTION="HTTP library with thread-safe connection pooling, file post, and more" |
105 |
+HOMEPAGE="https://github.com/urllib3/urllib3" |
106 |
+SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz" |
107 |
+ |
108 |
+LICENSE="MIT" |
109 |
+SLOT="0" |
110 |
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~x64-macos" |
111 |
+IUSE="brotli test" |
112 |
+RESTRICT="!test? ( test )" |
113 |
+ |
114 |
+RDEPEND=" |
115 |
+ >=dev-python/PySocks-1.5.8[${PYTHON_USEDEP}] |
116 |
+ <dev-python/PySocks-2.0[${PYTHON_USEDEP}] |
117 |
+ dev-python/certifi[${PYTHON_USEDEP}] |
118 |
+ >=dev-python/cryptography-1.3.4[${PYTHON_USEDEP}] |
119 |
+ >=dev-python/pyopenssl-0.14[${PYTHON_USEDEP}] |
120 |
+ >=dev-python/idna-2.0.0[${PYTHON_USEDEP}] |
121 |
+ brotli? ( dev-python/brotlicffi[${PYTHON_USEDEP}] ) |
122 |
+" |
123 |
+BDEPEND=" |
124 |
+ test? ( |
125 |
+ $(python_gen_cond_dep " |
126 |
+ ${RDEPEND} |
127 |
+ dev-python/brotlicffi[\${PYTHON_USEDEP}] |
128 |
+ dev-python/mock[\${PYTHON_USEDEP}] |
129 |
+ dev-python/pytest[\${PYTHON_USEDEP}] |
130 |
+ dev-python/pytest-freezegun[\${PYTHON_USEDEP}] |
131 |
+ >=dev-python/trustme-0.5.3[\${PYTHON_USEDEP}] |
132 |
+ >=www-servers/tornado-4.2.1[\${PYTHON_USEDEP}] |
133 |
+ " python3_{6,7,8,9}) |
134 |
+ ) |
135 |
+" |
136 |
+ |
137 |
+python_prepare_all() { |
138 |
+ # https://github.com/urllib3/urllib3/issues/1756 |
139 |
+ sed -e 's:10.255.255.1:240.0.0.0:' \ |
140 |
+ -i test/__init__.py || die |
141 |
+ # tests failing if 'localhost.' cannot be resolved |
142 |
+ sed -e 's:test_dotted_fqdn:_&:' \ |
143 |
+ -i test/with_dummyserver/test_https.py || die |
144 |
+ sed -e 's:test_request_host_header_ignores_fqdn_dot:_&:' \ |
145 |
+ -i test/with_dummyserver/test_socketlevel.py || die |
146 |
+ |
147 |
+ distutils-r1_python_prepare_all |
148 |
+} |
149 |
+ |
150 |
+python_test() { |
151 |
+ local -x CI=1 |
152 |
+ # FIXME: get tornado ported |
153 |
+ case ${EPYTHON} in |
154 |
+ python3*) |
155 |
+ pytest -vv || die "Tests fail with ${EPYTHON}" |
156 |
+ ;; |
157 |
+ esac |
158 |
+} |