Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/pycurl/, dev-python/pycurl/files/
Date: Thu, 27 Aug 2020 05:55:29
Message-Id: 1598507674.4af3cd5c7df291ed2093f0b60ffbcca01322ec65.mgorny@gentoo
1 commit: 4af3cd5c7df291ed2093f0b60ffbcca01322ec65
2 Author: Stefan Strogin <steils <AT> gentoo <DOT> org>
3 AuthorDate: Wed Aug 26 23:23:35 2020 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Thu Aug 27 05:54:34 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4af3cd5c
7
8 dev-python/pycurl: add patch for multiple SSL backends
9
10 net-misc/curl supports multiple SSL backends since 5e560782
11 "net-misc/curl: enable multiple ssl implementations", which is supported
12 in curl since 7.56.
13
14 pycurl supporting this feature is not released yet, so with the latest
15 pycurl users could get an error like:
16
17 ImportError: pycurl: libcurl link-time ssl backend (gnutls) is
18 different from compile-time ssl backend (openssl)
19
20 Add patch from upstream to support multiple SSL backend in pycurl.
21
22 Package-Manager: Portage-3.0.4, Repoman-3.0.1
23 Signed-off-by: Stefan Strogin <steils <AT> gentoo.org>
24 Closes: https://github.com/gentoo/gentoo/pull/17272
25 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
26
27 .../files/pycurl-7.43.0.5-multiple-ssl.patch | 146 +++++++++++++++++++++
28 dev-python/pycurl/pycurl-7.43.0.5-r1.ebuild | 93 +++++++++++++
29 2 files changed, 239 insertions(+)
30
31 diff --git a/dev-python/pycurl/files/pycurl-7.43.0.5-multiple-ssl.patch b/dev-python/pycurl/files/pycurl-7.43.0.5-multiple-ssl.patch
32 new file mode 100644
33 index 00000000000..035ad6f9ca3
34 --- /dev/null
35 +++ b/dev-python/pycurl/files/pycurl-7.43.0.5-multiple-ssl.patch
36 @@ -0,0 +1,146 @@
37 +From 290d762ea13a1d95affa0888c5450b33b00241e8 Mon Sep 17 00:00:00 2001
38 +From: Bo Anderson <mail@××××××××××.me>
39 +Date: Tue, 21 Jul 2020 18:28:31 +0100
40 +Subject: [PATCH] Handle MultiSSL
41 +
42 +Upstream-Status: Accepted [https://github.com/pycurl/pycurl/pull/639]
43 +Signed-off-by: Stefan Strogin <steils@g.o>
44 +---
45 + src/module.c | 41 ++++++++++++++++++++++++++++++++++++++++-
46 + src/pycurl.h | 11 +++++++++++
47 + 2 files changed, 51 insertions(+), 1 deletion(-)
48 +
49 +diff --git a/src/module.c b/src/module.c
50 +index 23387ec..dbc5b0c 100644
51 +--- a/src/module.c
52 ++++ b/src/module.c
53 +@@ -322,12 +322,21 @@ initpycurl(void)
54 + {
55 + PyObject *m, *d;
56 + const curl_version_info_data *vi;
57 +- const char *libcurl_version, *runtime_ssl_lib;
58 ++ const char *libcurl_version;
59 + size_t libcurl_version_len, pycurl_version_len;
60 + PyObject *xio_module = NULL;
61 + PyObject *collections_module = NULL;
62 + PyObject *named_tuple = NULL;
63 + PyObject *arglist = NULL;
64 ++#ifdef HAVE_CURL_GLOBAL_SSLSET
65 ++ const curl_ssl_backend **ssllist = NULL;
66 ++ CURLsslset sslset;
67 ++ int i, runtime_supported_backend_found = 0;
68 ++ char backends[200];
69 ++ size_t backends_len = 0;
70 ++#else
71 ++ const char *runtime_ssl_lib;
72 ++#endif
73 +
74 + assert(Curl_Type.tp_weaklistoffset > 0);
75 + assert(CurlMulti_Type.tp_weaklistoffset > 0);
76 +@@ -346,6 +355,35 @@ initpycurl(void)
77 + }
78 +
79 + /* Our compiled crypto locks should correspond to runtime ssl library. */
80 ++#ifdef HAVE_CURL_GLOBAL_SSLSET
81 ++ sslset = curl_global_sslset(-1, COMPILE_SSL_LIB, &ssllist);
82 ++ if (sslset != CURLSSLSET_OK) {
83 ++ if (sslset == CURLSSLSET_NO_BACKENDS) {
84 ++ strcpy(backends, "none");
85 ++ } else {
86 ++ for (i = 0; ssllist[i] != NULL; i++) {
87 ++ switch (ssllist[i]->id) {
88 ++ case CURLSSLBACKEND_OPENSSL:
89 ++ case CURLSSLBACKEND_GNUTLS:
90 ++ case CURLSSLBACKEND_NSS:
91 ++ case CURLSSLBACKEND_WOLFSSL:
92 ++ case CURLSSLBACKEND_MBEDTLS:
93 ++ runtime_supported_backend_found = 1;
94 ++ break;
95 ++ default:
96 ++ break;
97 ++ }
98 ++ if (backends_len < sizeof(backends)) {
99 ++ backends_len += snprintf(backends + backends_len, sizeof(backends) - backends_len, "%s%s", (i > 0) ? ", " : "", ssllist[i]->name);
100 ++ }
101 ++ }
102 ++ }
103 ++ if (runtime_supported_backend_found == COMPILE_SUPPORTED_SSL_BACKEND_FOUND) {
104 ++ PyErr_Format(PyExc_ImportError, "pycurl: libcurl link-time ssl backends (%s) do not include compile-time ssl backend (%s)", backends, COMPILE_SSL_LIB);
105 ++ goto error;
106 ++ }
107 ++ }
108 ++#else
109 + if (vi->ssl_version == NULL) {
110 + runtime_ssl_lib = "none/other";
111 + } else if (!strncmp(vi->ssl_version, "OpenSSL/", 8) || !strncmp(vi->ssl_version, "LibreSSL/", 9) ||
112 +@@ -366,6 +404,7 @@ initpycurl(void)
113 + PyErr_Format(PyExc_ImportError, "pycurl: libcurl link-time ssl backend (%s) is different from compile-time ssl backend (%s)", runtime_ssl_lib, COMPILE_SSL_LIB);
114 + goto error;
115 + }
116 ++#endif
117 +
118 + /* Initialize the type of the new type objects here; doing it here
119 + * is required for portability to Windows without requiring C++. */
120 +diff --git a/src/pycurl.h b/src/pycurl.h
121 +index 02db495..a83c85b 100644
122 +--- a/src/pycurl.h
123 ++++ b/src/pycurl.h
124 +@@ -154,6 +154,10 @@ pycurl_inet_ntop (int family, void *addr, char *string, size_t string_size);
125 + #define HAVE_CURLINFO_HTTP_VERSION
126 + #endif
127 +
128 ++#if LIBCURL_VERSION_NUM >= 0x073800 /* check for 7.56.0 or greater */
129 ++#define HAVE_CURL_GLOBAL_SSLSET
130 ++#endif
131 ++
132 + #undef UNUSED
133 + #define UNUSED(var) ((void)&var)
134 +
135 +@@ -165,6 +169,7 @@ pycurl_inet_ntop (int family, void *addr, char *string, size_t string_size);
136 + # include <openssl/ssl.h>
137 + # include <openssl/err.h>
138 + # define COMPILE_SSL_LIB "openssl"
139 ++# define COMPILE_SUPPORTED_SSL_BACKEND_FOUND 1
140 + # elif defined(HAVE_CURL_WOLFSSL)
141 + # include <wolfssl/options.h>
142 + # if defined(OPENSSL_EXTRA)
143 +@@ -187,6 +192,7 @@ pycurl_inet_ntop (int family, void *addr, char *string, size_t string_size);
144 + # endif
145 + # endif
146 + # define COMPILE_SSL_LIB "wolfssl"
147 ++# define COMPILE_SUPPORTED_SSL_BACKEND_FOUND 1
148 + # elif defined(HAVE_CURL_GNUTLS)
149 + # include <gnutls/gnutls.h>
150 + # if GNUTLS_VERSION_NUMBER <= 0x020b00
151 +@@ -195,13 +201,16 @@ pycurl_inet_ntop (int family, void *addr, char *string, size_t string_size);
152 + # include <gcrypt.h>
153 + # endif
154 + # define COMPILE_SSL_LIB "gnutls"
155 ++# define COMPILE_SUPPORTED_SSL_BACKEND_FOUND 1
156 + # elif defined(HAVE_CURL_NSS)
157 + # define COMPILE_SSL_LIB "nss"
158 ++# define COMPILE_SUPPORTED_SSL_BACKEND_FOUND 1
159 + # elif defined(HAVE_CURL_MBEDTLS)
160 + # include <mbedtls/ssl.h>
161 + # define PYCURL_NEED_SSL_TSL
162 + # define PYCURL_NEED_MBEDTLS_TSL
163 + # define COMPILE_SSL_LIB "mbedtls"
164 ++# define COMPILE_SUPPORTED_SSL_BACKEND_FOUND 1
165 + # else
166 + # ifdef _MSC_VER
167 + /* sigh */
168 +@@ -218,9 +227,11 @@ pycurl_inet_ntop (int family, void *addr, char *string, size_t string_size);
169 + /* since we have no crypto callbacks for other ssl backends,
170 + * no reason to require users match those */
171 + # define COMPILE_SSL_LIB "none/other"
172 ++# define COMPILE_SUPPORTED_SSL_BACKEND_FOUND 0
173 + # endif /* HAVE_CURL_OPENSSL || HAVE_CURL_WOLFSSL || HAVE_CURL_GNUTLS || HAVE_CURL_NSS || HAVE_CURL_MBEDTLS */
174 + #else
175 + # define COMPILE_SSL_LIB "none/other"
176 ++# define COMPILE_SUPPORTED_SSL_BACKEND_FOUND 0
177 + #endif /* HAVE_CURL_SSL */
178 +
179 + #if defined(PYCURL_NEED_SSL_TSL)
180 +--
181 +2.28.0
182 +
183
184 diff --git a/dev-python/pycurl/pycurl-7.43.0.5-r1.ebuild b/dev-python/pycurl/pycurl-7.43.0.5-r1.ebuild
185 new file mode 100644
186 index 00000000000..1b678aa041e
187 --- /dev/null
188 +++ b/dev-python/pycurl/pycurl-7.43.0.5-r1.ebuild
189 @@ -0,0 +1,93 @@
190 +# Copyright 1999-2020 Gentoo Authors
191 +# Distributed under the terms of the GNU General Public License v2
192 +
193 +EAPI=7
194 +
195 +DISTUTILS_USE_SETUPTOOLS=manual
196 +# The selftests fail with pypy, and urlgrabber segfaults for me.
197 +PYTHON_COMPAT=( python3_{6,7,8,9} )
198 +
199 +inherit distutils-r1 toolchain-funcs
200 +
201 +DESCRIPTION="python binding for curl/libcurl"
202 +HOMEPAGE="
203 + https://github.com/pycurl/pycurl
204 + https://pypi.org/project/pycurl/
205 + http://pycurl.io/"
206 +SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
207 +
208 +LICENSE="LGPL-2.1"
209 +SLOT="0"
210 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
211 +IUSE="curl_ssl_gnutls curl_ssl_libressl curl_ssl_nss +curl_ssl_openssl examples ssl test"
212 +RESTRICT="!test? ( test )"
213 +
214 +# Depend on a curl with curl_ssl_* USE flags.
215 +# libcurl must not be using an ssl backend we do not support.
216 +# If the libcurl ssl backend changes pycurl should be recompiled.
217 +# If curl uses gnutls, depend on at least gnutls 2.11.0 so that pycurl
218 +# does not need to initialize gcrypt threading and we do not need to
219 +# explicitly link to libgcrypt.
220 +RDEPEND="
221 + >=net-misc/curl-7.25.0-r1:=[ssl=]
222 + ssl? (
223 + net-misc/curl[curl_ssl_gnutls(-)=,curl_ssl_libressl(-)=,curl_ssl_nss(-)=,curl_ssl_openssl(-)=,-curl_ssl_axtls(-),-curl_ssl_cyassl(-)]
224 + curl_ssl_gnutls? ( >=net-libs/gnutls-2.11.0:= )
225 + curl_ssl_libressl? ( dev-libs/libressl:= )
226 + curl_ssl_openssl? ( dev-libs/openssl:= )
227 + )"
228 +
229 +# bottle-0.12.7: https://github.com/pycurl/pycurl/issues/180
230 +# bottle-0.12.7: https://github.com/defnull/bottle/commit/f35197e2a18de1672831a70a163fcfd38327a802
231 +DEPEND="${RDEPEND}
232 + test? (
233 + dev-python/bottle[${PYTHON_USEDEP}]
234 + dev-python/flaky[${PYTHON_USEDEP}]
235 + dev-python/nose[${PYTHON_USEDEP}]
236 + net-misc/curl[curl_ssl_gnutls(-)=,curl_ssl_libressl(-)=,curl_ssl_nss(-)=,curl_ssl_openssl(-)=,-curl_ssl_axtls(-),-curl_ssl_cyassl(-),http2]
237 + >=dev-python/bottle-0.12.7[${PYTHON_USEDEP}]
238 + )"
239 +
240 +PATCHES=(
241 + "${FILESDIR}"/pycurl-7.43.0.5-telnet-test.patch
242 + "${FILESDIR}"/pycurl-7.43.0.5-cc-cflags.patch
243 + "${FILESDIR}"/pycurl-7.43.0.5-multiple-ssl.patch
244 +)
245 +
246 +python_prepare_all() {
247 + sed -e "/setup_args\['data_files'\] = /d" -i setup.py || die
248 + # disable automagic use of setuptools
249 + sed -e 's:import wheel:raise ImportError:' -i setup.py || die
250 + # these tests are broken with newer versions of bottle
251 + sed -e 's:test.*_invalid_utf8:_&:' -i tests/getinfo_test.py || die
252 + distutils-r1_python_prepare_all
253 +}
254 +
255 +python_configure_all() {
256 + # Override faulty detection in setup.py, bug 510974.
257 + export PYCURL_SSL_LIBRARY=${CURL_SSL/libressl/openssl}
258 +}
259 +
260 +src_test() {
261 + # upstream bundles precompiled amd64 libs
262 + rm tests/fake-curl/libcurl/*.so || die
263 + emake -C tests/fake-curl/libcurl CC="$(tc-getCC)"
264 +
265 + distutils-r1_src_test
266 +}
267 +
268 +python_compile() {
269 + python_is_python3 || local -x CFLAGS="${CFLAGS} -fno-strict-aliasing"
270 + distutils-r1_python_compile
271 +}
272 +
273 +python_test() {
274 + nosetests -a '!standalone,!gssapi' -v --with-flaky || die "Tests fail with ${EPYTHON}"
275 + nosetests -a 'standalone' -v --with-flaky || die "Tests fail with ${EPYTHON}"
276 +}
277 +
278 +python_install_all() {
279 + local HTML_DOCS=( doc/. )
280 + use examples && dodoc -r examples
281 + distutils-r1_python_install_all
282 +}