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/cryptography/, dev-python/cryptography/files/
Date: Sat, 15 May 2021 11:51:40
Message-Id: 1621079492.5afe2baaffb4746f159b3d82f6ed28c33c8f5e18.mgorny@gentoo
1 commit: 5afe2baaffb4746f159b3d82f6ed28c33c8f5e18
2 Author: Ekaterina Vaartis <vaartis <AT> kotobank <DOT> ch>
3 AuthorDate: Fri May 14 20:05:14 2021 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sat May 15 11:51:32 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5afe2baa
7
8 dev-python/cryptography: bump to r1 and backport the fixes for 3.10
9
10 Signed-off-by: Ekaterina Vaartis <vaartis <AT> kotobank.ch>
11 Closes: https://github.com/gentoo/gentoo/pull/20795
12 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
13
14 ...y-3.4.7.ebuild => cryptography-3.4.7-r1.ebuild} | 6 +-
15 .../files/cryptography-3.4.7-py310.patch | 301 +++++++++++++++++++++
16 2 files changed, 306 insertions(+), 1 deletion(-)
17
18 diff --git a/dev-python/cryptography/cryptography-3.4.7.ebuild b/dev-python/cryptography/cryptography-3.4.7-r1.ebuild
19 similarity index 95%
20 rename from dev-python/cryptography/cryptography-3.4.7.ebuild
21 rename to dev-python/cryptography/cryptography-3.4.7-r1.ebuild
22 index 59b98063ce3..1a0d6a6f5d9 100644
23 --- a/dev-python/cryptography/cryptography-3.4.7.ebuild
24 +++ b/dev-python/cryptography/cryptography-3.4.7-r1.ebuild
25 @@ -3,7 +3,7 @@
26
27 EAPI=7
28
29 -PYTHON_COMPAT=( python3_{7..9} pypy3 )
30 +PYTHON_COMPAT=( python3_{7..10} pypy3 )
31 PYTHON_REQ_USE="threads(+)"
32
33 inherit distutils-r1 multiprocessing
34 @@ -41,6 +41,10 @@ DEPEND="
35 "
36 RDEPEND+=${DEPEND}
37
38 +PATCHES=(
39 + "${FILESDIR}/${P}-py310.patch"
40 +)
41 +
42 src_prepare() {
43 default
44
45
46 diff --git a/dev-python/cryptography/files/cryptography-3.4.7-py310.patch b/dev-python/cryptography/files/cryptography-3.4.7-py310.patch
47 new file mode 100644
48 index 00000000000..d961af82b77
49 --- /dev/null
50 +++ b/dev-python/cryptography/files/cryptography-3.4.7-py310.patch
51 @@ -0,0 +1,301 @@
52 +diff --git a/src/cryptography/exceptions.py b/src/cryptography/exceptions.py
53 +index f5860590..3bd98d82 100644
54 +--- a/src/cryptography/exceptions.py
55 ++++ b/src/cryptography/exceptions.py
56 +@@ -3,10 +3,10 @@
57 + # for complete details.
58 +
59 +
60 +-from enum import Enum
61 ++from cryptography import utils
62 +
63 +
64 +-class _Reasons(Enum):
65 ++class _Reasons(utils.Enum):
66 + BACKEND_MISSING_INTERFACE = 0
67 + UNSUPPORTED_HASH = 1
68 + UNSUPPORTED_CIPHER = 2
69 +diff --git a/src/cryptography/hazmat/primitives/_serialization.py b/src/cryptography/hazmat/primitives/_serialization.py
70 +index 96a5ed9b..160a6b89 100644
71 +--- a/src/cryptography/hazmat/primitives/_serialization.py
72 ++++ b/src/cryptography/hazmat/primitives/_serialization.py
73 +@@ -3,13 +3,14 @@
74 + # for complete details.
75 +
76 + import abc
77 +-from enum import Enum
78 ++
79 ++from cryptography import utils
80 +
81 + # This exists to break an import cycle. These classes are normally accessible
82 + # from the serialization module.
83 +
84 +
85 +-class Encoding(Enum):
86 ++class Encoding(utils.Enum):
87 + PEM = "PEM"
88 + DER = "DER"
89 + OpenSSH = "OpenSSH"
90 +@@ -18,14 +19,14 @@ class Encoding(Enum):
91 + SMIME = "S/MIME"
92 +
93 +
94 +-class PrivateFormat(Enum):
95 ++class PrivateFormat(utils.Enum):
96 + PKCS8 = "PKCS8"
97 + TraditionalOpenSSL = "TraditionalOpenSSL"
98 + Raw = "Raw"
99 + OpenSSH = "OpenSSH"
100 +
101 +
102 +-class PublicFormat(Enum):
103 ++class PublicFormat(utils.Enum):
104 + SubjectPublicKeyInfo = "X.509 subjectPublicKeyInfo with PKCS#1"
105 + PKCS1 = "Raw PKCS#1"
106 + OpenSSH = "OpenSSH"
107 +@@ -34,7 +35,7 @@ class PublicFormat(Enum):
108 + UncompressedPoint = "X9.62 Uncompressed Point"
109 +
110 +
111 +-class ParameterFormat(Enum):
112 ++class ParameterFormat(utils.Enum):
113 + PKCS3 = "PKCS3"
114 +
115 +
116 +diff --git a/src/cryptography/hazmat/primitives/kdf/kbkdf.py b/src/cryptography/hazmat/primitives/kdf/kbkdf.py
117 +index ac36474f..75fe7d51 100644
118 +--- a/src/cryptography/hazmat/primitives/kdf/kbkdf.py
119 ++++ b/src/cryptography/hazmat/primitives/kdf/kbkdf.py
120 +@@ -4,7 +4,6 @@
121 +
122 +
123 + import typing
124 +-from enum import Enum
125 +
126 + from cryptography import utils
127 + from cryptography.exceptions import (
128 +@@ -19,11 +18,11 @@ from cryptography.hazmat.primitives import constant_time, hashes, hmac
129 + from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
130 +
131 +
132 +-class Mode(Enum):
133 ++class Mode(utils.Enum):
134 + CounterMode = "ctr"
135 +
136 +
137 +-class CounterLocation(Enum):
138 ++class CounterLocation(utils.Enum):
139 + BeforeFixed = "before_fixed"
140 + AfterFixed = "after_fixed"
141 +
142 +diff --git a/src/cryptography/hazmat/primitives/serialization/pkcs7.py b/src/cryptography/hazmat/primitives/serialization/pkcs7.py
143 +index bcd9e330..57aac7e3 100644
144 +--- a/src/cryptography/hazmat/primitives/serialization/pkcs7.py
145 ++++ b/src/cryptography/hazmat/primitives/serialization/pkcs7.py
146 +@@ -3,8 +3,8 @@
147 + # for complete details.
148 +
149 + import typing
150 +-from enum import Enum
151 +
152 ++from cryptography import utils
153 + from cryptography import x509
154 + from cryptography.hazmat.backends import _get_backend
155 + from cryptography.hazmat.primitives import hashes, serialization
156 +@@ -35,7 +35,7 @@ _ALLOWED_PRIVATE_KEY_TYPES = typing.Union[
157 + ]
158 +
159 +
160 +-class PKCS7Options(Enum):
161 ++class PKCS7Options(utils.Enum):
162 + Text = "Add text/plain MIME type"
163 + Binary = "Don't translate input data into canonical MIME format"
164 + DetachedSignature = "Don't embed data in the PKCS7 structure"
165 +diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py
166 +index ef0fc443..9e571cfd 100644
167 +--- a/src/cryptography/utils.py
168 ++++ b/src/cryptography/utils.py
169 +@@ -4,6 +4,7 @@
170 +
171 +
172 + import abc
173 ++import enum
174 + import inspect
175 + import sys
176 + import typing
177 +@@ -162,3 +163,13 @@ int_from_bytes = deprecated(
178 + "int_from_bytes is deprecated, use int.from_bytes instead",
179 + DeprecatedIn34,
180 + )
181 ++
182 ++
183 ++# Python 3.10 changed representation of enums. We use well-defined object
184 ++# representation and string representation from Python 3.9.
185 ++class Enum(enum.Enum):
186 ++ def __repr__(self):
187 ++ return f"<{self.__class__.__name__}.{self._name_}: {self._value_!r}>"
188 ++
189 ++ def __str__(self):
190 ++ return f"{self.__class__.__name__}.{self._name_}"
191 +diff --git a/src/cryptography/x509/base.py b/src/cryptography/x509/base.py
192 +index 5505fa3b..e3846c33 100644
193 +--- a/src/cryptography/x509/base.py
194 ++++ b/src/cryptography/x509/base.py
195 +@@ -7,9 +7,9 @@ import abc
196 + import datetime
197 + import os
198 + import typing
199 +-from enum import Enum
200 +
201 + from cryptography.hazmat._types import _PRIVATE_KEY_TYPES, _PUBLIC_KEY_TYPES
202 ++from cryptography import utils
203 + from cryptography.hazmat.backends import _get_backend
204 + from cryptography.hazmat.primitives import hashes, serialization
205 + from cryptography.hazmat.primitives.asymmetric import (
206 +@@ -66,7 +66,7 @@ def _convert_to_naive_utc_time(time: datetime.datetime) -> datetime.datetime:
207 + return time
208 +
209 +
210 +-class Version(Enum):
211 ++class Version(utils.Enum):
212 + v1 = 0
213 + v3 = 2
214 +
215 +diff --git a/src/cryptography/x509/certificate_transparency.py b/src/cryptography/x509/certificate_transparency.py
216 +index d51bee92..d80f051a 100644
217 +--- a/src/cryptography/x509/certificate_transparency.py
218 ++++ b/src/cryptography/x509/certificate_transparency.py
219 +@@ -5,15 +5,16 @@
220 +
221 + import abc
222 + import datetime
223 +-from enum import Enum
224 +
225 ++from cryptography import utils
226 +
227 +-class LogEntryType(Enum):
228 ++
229 ++class LogEntryType(utils.Enum):
230 + X509_CERTIFICATE = 0
231 + PRE_CERTIFICATE = 1
232 +
233 +
234 +-class Version(Enum):
235 ++class Version(utils.Enum):
236 + v1 = 0
237 +
238 +
239 +diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py
240 +index 6cae016a..742f1fa2 100644
241 +--- a/src/cryptography/x509/extensions.py
242 ++++ b/src/cryptography/x509/extensions.py
243 +@@ -8,7 +8,6 @@ import datetime
244 + import hashlib
245 + import ipaddress
246 + import typing
247 +-from enum import Enum
248 +
249 + from cryptography import utils
250 + from cryptography.hazmat._der import (
251 +@@ -634,7 +633,7 @@ class DistributionPoint(object):
252 + crl_issuer = utils.read_only_property("_crl_issuer")
253 +
254 +
255 +-class ReasonFlags(Enum):
256 ++class ReasonFlags(utils.Enum):
257 + unspecified = "unspecified"
258 + key_compromise = "keyCompromise"
259 + ca_compromise = "cACompromise"
260 +@@ -978,7 +977,7 @@ class TLSFeature(ExtensionType):
261 + return hash(tuple(self._features))
262 +
263 +
264 +-class TLSFeatureType(Enum):
265 ++class TLSFeatureType(utils.Enum):
266 + # status_request is defined in RFC 6066 and is used for what is commonly
267 + # called OCSP Must-Staple when present in the TLS Feature extension in an
268 + # X.509 certificate.
269 +diff --git a/src/cryptography/x509/name.py b/src/cryptography/x509/name.py
270 +index a579aa21..9069a9f4 100644
271 +--- a/src/cryptography/x509/name.py
272 ++++ b/src/cryptography/x509/name.py
273 +@@ -3,14 +3,13 @@
274 + # for complete details.
275 +
276 + import typing
277 +-from enum import Enum
278 +
279 + from cryptography import utils
280 + from cryptography.hazmat.backends import _get_backend
281 + from cryptography.x509.oid import NameOID, ObjectIdentifier
282 +
283 +
284 +-class _ASN1Type(Enum):
285 ++class _ASN1Type(utils.Enum):
286 + UTF8String = 12
287 + NumericString = 18
288 + PrintableString = 19
289 +diff --git a/src/cryptography/x509/ocsp.py b/src/cryptography/x509/ocsp.py
290 +index 1c5de73e..bcf210c1 100644
291 +--- a/src/cryptography/x509/ocsp.py
292 ++++ b/src/cryptography/x509/ocsp.py
293 +@@ -6,8 +6,8 @@
294 + import abc
295 + import datetime
296 + import typing
297 +-from enum import Enum
298 +
299 ++from cryptography import utils
300 + from cryptography import x509
301 + from cryptography.hazmat.primitives import hashes, serialization
302 + from cryptography.x509.base import (
303 +@@ -27,12 +27,12 @@ _OIDS_TO_HASH = {
304 + }
305 +
306 +
307 +-class OCSPResponderEncoding(Enum):
308 ++class OCSPResponderEncoding(utils.Enum):
309 + HASH = "By Hash"
310 + NAME = "By Name"
311 +
312 +
313 +-class OCSPResponseStatus(Enum):
314 ++class OCSPResponseStatus(utils.Enum):
315 + SUCCESSFUL = 0
316 + MALFORMED_REQUEST = 1
317 + INTERNAL_ERROR = 2
318 +@@ -58,7 +58,7 @@ def _verify_algorithm(algorithm):
319 + )
320 +
321 +
322 +-class OCSPCertStatus(Enum):
323 ++class OCSPCertStatus(utils.Enum):
324 + GOOD = 0
325 + REVOKED = 1
326 + UNKNOWN = 2
327 +diff --git a/tests/test_cryptography_utils.py b/tests/test_cryptography_utils.py
328 +index 6b795e0c..803997ac 100644
329 +--- a/tests/test_cryptography_utils.py
330 ++++ b/tests/test_cryptography_utils.py
331 +@@ -2,6 +2,7 @@
332 + # 2.0, and the BSD License. See the LICENSE file in the root of this repository
333 + # for complete details.
334 +
335 ++import enum
336 + import typing
337 +
338 + import pytest
339 +@@ -51,3 +52,13 @@ class TestCachedProperty(object):
340 + assert len(accesses) == 1
341 + assert t.t == 14
342 + assert len(accesses) == 1
343 ++
344 ++
345 ++def test_enum():
346 ++ class TestEnum(utils.Enum):
347 ++ value = "something"
348 ++
349 ++ assert issubclass(TestEnum, enum.Enum)
350 ++ assert isinstance(TestEnum.value, enum.Enum)
351 ++ assert repr(TestEnum.value) == "<TestEnum.value: 'something'>"
352 ++ assert str(TestEnum.value) == "TestEnum.value"