1 |
commit: 768757d3bf88df981cae7b117bbe97177bba8945 |
2 |
Author: Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed May 18 11:31:03 2022 +0000 |
4 |
Commit: Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed May 18 14:22:34 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=768757d3 |
7 |
|
8 |
dev-python/cached-property: update EAPI 7 -> 8, patch for py3.11 |
9 |
|
10 |
Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org> |
11 |
|
12 |
.../cached-property-1.5.2-r1.ebuild | 30 +++++ |
13 |
.../files/cached-property-1.5.2-python311.patch | 142 +++++++++++++++++++++ |
14 |
2 files changed, 172 insertions(+) |
15 |
|
16 |
diff --git a/dev-python/cached-property/cached-property-1.5.2-r1.ebuild b/dev-python/cached-property/cached-property-1.5.2-r1.ebuild |
17 |
new file mode 100644 |
18 |
index 000000000000..9da94d1177a4 |
19 |
--- /dev/null |
20 |
+++ b/dev-python/cached-property/cached-property-1.5.2-r1.ebuild |
21 |
@@ -0,0 +1,30 @@ |
22 |
+# Copyright 1999-2022 Gentoo Authors |
23 |
+# Distributed under the terms of the GNU General Public License v2 |
24 |
+ |
25 |
+EAPI=8 |
26 |
+ |
27 |
+PYTHON_COMPAT=( python3_{8..11} pypy3 ) |
28 |
+DISTUTILS_USE_PEP517=setuptools |
29 |
+ |
30 |
+inherit distutils-r1 |
31 |
+ |
32 |
+DESCRIPTION="A cached-property for decorating methods in classes" |
33 |
+HOMEPAGE="https://github.com/pydanny/cached-property" |
34 |
+SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz" |
35 |
+ |
36 |
+LICENSE="BSD" |
37 |
+SLOT="0" |
38 |
+KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv ~x86" |
39 |
+ |
40 |
+BDEPEND="test? ( dev-python/freezegun[${PYTHON_USEDEP}] )" |
41 |
+ |
42 |
+distutils_enable_tests pytest |
43 |
+ |
44 |
+DOCS=( README.rst HISTORY.rst CONTRIBUTING.rst AUTHORS.rst ) |
45 |
+ |
46 |
+PATCHES=( |
47 |
+ # bug 638250 |
48 |
+ "${FILESDIR}"/${PN}-1.5.1-test-failure.patch |
49 |
+ # @asyncio.coroutine removed in py3.11 |
50 |
+ "${FILESDIR}"/${PN}-1.5.2-python311.patch |
51 |
+) |
52 |
|
53 |
diff --git a/dev-python/cached-property/files/cached-property-1.5.2-python311.patch b/dev-python/cached-property/files/cached-property-1.5.2-python311.patch |
54 |
new file mode 100644 |
55 |
index 000000000000..989033f20036 |
56 |
--- /dev/null |
57 |
+++ b/dev-python/cached-property/files/cached-property-1.5.2-python311.patch |
58 |
@@ -0,0 +1,142 @@ |
59 |
+From 297031687679762849dedeaf24aa3a19116f095b Mon Sep 17 00:00:00 2001 |
60 |
+From: Petr Viktorin <encukou@×××××.com> |
61 |
+Date: Thu, 2 Dec 2021 11:26:20 +0100 |
62 |
+Subject: [PATCH 1/2] Don't use asyncio.coroutinefunction if it's not available |
63 |
+ |
64 |
+Python 3.11 drops the deprecated @asyncio.coroutine and |
65 |
+asyncio.iscoroutinefunction. |
66 |
+ |
67 |
+Using a wrapper with @asyncio.coroutine in __get__ wasn't |
68 |
+necessary (the future from asyncio.ensure_future is awaitable, |
69 |
+and the wrapper doesn't do anything asynchronous), so the |
70 |
+logic can be simplified to just call asyncio.ensure_future |
71 |
+(to schedule the task and store the result when it's |
72 |
+available). |
73 |
+ |
74 |
+Tests for @asyncio.coroutine are skipped on 3.11+. |
75 |
+ |
76 |
+An unnecessary call to asyncio.coroutine in tests is |
77 |
+removed: it's not necessary to call this for `async def` |
78 |
+functions. |
79 |
+--- |
80 |
+ cached_property.py | 24 +++++++++++------------- |
81 |
+ conftest.py | 6 +++++- |
82 |
+ tests/test_async_cached_property.py | 3 +-- |
83 |
+ 3 files changed, 17 insertions(+), 16 deletions(-) |
84 |
+ |
85 |
+diff --git a/cached_property.py b/cached_property.py |
86 |
+index 3135871..254739c 100644 |
87 |
+--- a/cached_property.py |
88 |
++++ b/cached_property.py |
89 |
+@@ -13,6 +13,12 @@ |
90 |
+ import asyncio |
91 |
+ except (ImportError, SyntaxError): |
92 |
+ asyncio = None |
93 |
++try: |
94 |
++ iscoroutinefunction = asyncio.iscoroutinefunction |
95 |
++except AttributeError: |
96 |
++ # Python 3.11: @asyncio.coroutine was removed |
97 |
++ from inspect import iscoroutinefunction |
98 |
++ |
99 |
+ |
100 |
+ |
101 |
+ class cached_property(object): |
102 |
+@@ -30,22 +36,14 @@ def __get__(self, obj, cls): |
103 |
+ if obj is None: |
104 |
+ return self |
105 |
+ |
106 |
+- if asyncio and asyncio.iscoroutinefunction(self.func): |
107 |
+- return self._wrap_in_coroutine(obj) |
108 |
++ if asyncio and iscoroutinefunction(self.func): |
109 |
++ value = asyncio.ensure_future(self.func(obj)) |
110 |
++ else: |
111 |
++ value = self.func(obj) |
112 |
+ |
113 |
+- value = obj.__dict__[self.func.__name__] = self.func(obj) |
114 |
++ obj.__dict__[self.func.__name__] = value |
115 |
+ return value |
116 |
+ |
117 |
+- def _wrap_in_coroutine(self, obj): |
118 |
+- @wraps(obj) |
119 |
+- @asyncio.coroutine |
120 |
+- def wrapper(): |
121 |
+- future = asyncio.ensure_future(self.func(obj)) |
122 |
+- obj.__dict__[self.func.__name__] = future |
123 |
+- return future |
124 |
+- |
125 |
+- return wrapper() |
126 |
+- |
127 |
+ |
128 |
+ class threaded_cached_property(object): |
129 |
+ """ |
130 |
+diff --git a/conftest.py b/conftest.py |
131 |
+index 0563f64..1c4b618 100644 |
132 |
+--- a/conftest.py |
133 |
++++ b/conftest.py |
134 |
+@@ -7,13 +7,17 @@ |
135 |
+ # Whether the async and await keywords work |
136 |
+ has_async_await = sys.version_info[0] == 3 and sys.version_info[1] >= 5 |
137 |
+ |
138 |
++# Whether "from asyncio import coroutine" *fails* |
139 |
++version_info = sys.version_info |
140 |
++dropped_asyncio_coroutine = version_info[0] == 3 and version_info[1] >= 11 |
141 |
++ |
142 |
+ |
143 |
+ print("conftest.py", has_asyncio, has_async_await) |
144 |
+ |
145 |
+ |
146 |
+ collect_ignore = [] |
147 |
+ |
148 |
+-if not has_asyncio: |
149 |
++if not has_asyncio or dropped_asyncio_coroutine: |
150 |
+ collect_ignore.append("tests/test_coroutine_cached_property.py") |
151 |
+ |
152 |
+ if not has_async_await: |
153 |
+diff --git a/tests/test_async_cached_property.py b/tests/test_async_cached_property.py |
154 |
+index 4ba84f3..d61cc28 100644 |
155 |
+--- a/tests/test_async_cached_property.py |
156 |
++++ b/tests/test_async_cached_property.py |
157 |
+@@ -9,8 +9,7 @@ |
158 |
+ |
159 |
+ def unittest_run_loop(f): |
160 |
+ def wrapper(*args, **kwargs): |
161 |
+- coro = asyncio.coroutine(f) |
162 |
+- future = coro(*args, **kwargs) |
163 |
++ future = f(*args, **kwargs) |
164 |
+ loop = asyncio.get_event_loop() |
165 |
+ loop.run_until_complete(future) |
166 |
+ |
167 |
+ |
168 |
+From 9b210d12fa73c91743378ba4a966417846e7ea9a Mon Sep 17 00:00:00 2001 |
169 |
+From: Petr Viktorin <encukou@×××××.com> |
170 |
+Date: Thu, 2 Dec 2021 11:44:18 +0100 |
171 |
+Subject: [PATCH 2/2] Restore compatibility with python 2.7 |
172 |
+ |
173 |
+This is still necessary according to the Contributing Guidelines. |
174 |
+--- |
175 |
+ cached_property.py | 12 ++++++------ |
176 |
+ 1 file changed, 6 insertions(+), 6 deletions(-) |
177 |
+ |
178 |
+diff --git a/cached_property.py b/cached_property.py |
179 |
+index 254739c..944e2f5 100644 |
180 |
+--- a/cached_property.py |
181 |
++++ b/cached_property.py |
182 |
+@@ -13,12 +13,12 @@ |
183 |
+ import asyncio |
184 |
+ except (ImportError, SyntaxError): |
185 |
+ asyncio = None |
186 |
+-try: |
187 |
+- iscoroutinefunction = asyncio.iscoroutinefunction |
188 |
+-except AttributeError: |
189 |
+- # Python 3.11: @asyncio.coroutine was removed |
190 |
+- from inspect import iscoroutinefunction |
191 |
+- |
192 |
++if asyncio: |
193 |
++ try: |
194 |
++ iscoroutinefunction = asyncio.iscoroutinefunction |
195 |
++ except AttributeError: |
196 |
++ # Python 3.11: @asyncio.coroutine was removed |
197 |
++ from inspect import iscoroutinefunction |
198 |
+ |
199 |
+ |
200 |
+ class cached_property(object): |