1 |
commit: 7e8be4b686c79df075210ba27adf8e7580a09576 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jun 24 05:50:58 2021 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jun 24 07:43:37 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7e8be4b6 |
7 |
|
8 |
dev-python/anyio: Bump to 3.2.1 |
9 |
|
10 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
11 |
|
12 |
dev-python/anyio/Manifest | 1 + |
13 |
dev-python/anyio/anyio-3.2.1.ebuild | 47 ++++++++ |
14 |
.../anyio/files/anyio-3.2.1-missing-trio.patch | 125 +++++++++++++++++++++ |
15 |
3 files changed, 173 insertions(+) |
16 |
|
17 |
diff --git a/dev-python/anyio/Manifest b/dev-python/anyio/Manifest |
18 |
index 33a08706f84..4977f31d9d3 100644 |
19 |
--- a/dev-python/anyio/Manifest |
20 |
+++ b/dev-python/anyio/Manifest |
21 |
@@ -1,2 +1,3 @@ |
22 |
DIST anyio-3.1.0.tar.gz 122097 BLAKE2B 4a16a5d231cc5262dd4138f628b9d210180733bda4b9e81ced0c0e0c7f49e1760c8dd22db0a1db3b7a21f3210072f4e1c543e52a7dc716ad3f0415827da48e38 SHA512 120d8e3e24f542c06caedd0a67d16b3fb69c94f5feaebde5262e54f8ffba3f1cf927c82030d65fa2efb3479ee64abd968b6ce67aee767ea33ccef6b0e3fbd358 |
23 |
DIST anyio-3.2.0.tar.gz 126210 BLAKE2B cedace636a115ad579ca47b345bb2a9bb32e97fa2ef886a9e6bd19219dcc92c393aaaf480df5e6f48c959590c2d6a3e0770f700ab4901c7a8e576b231597abf1 SHA512 f4e718704225d9cbb8e2592246ac393f96e82fb1898bc0ff89b2d7990c4aac7e7c9b339cb57a594c59a9e5730696122c9e647310c26e00ab152879e0a7e85863 |
24 |
+DIST anyio-3.2.1.tar.gz 126277 BLAKE2B 510980c9251081d5188f7654279753051cd9f8221f2090fb99624612e48b6f5fc1f6d9f1808f1c329c350857f14ceaee0d72615857171de33dc35cc7ba35ab23 SHA512 ef78e5531a917e3a5ddc1106f45ba556ca147e52ab29ed6cb25a3bd287148a15a015942dde6b9535d683fbe5910affed27df6ce5c4049251610f689cd151ee89 |
25 |
|
26 |
diff --git a/dev-python/anyio/anyio-3.2.1.ebuild b/dev-python/anyio/anyio-3.2.1.ebuild |
27 |
new file mode 100644 |
28 |
index 00000000000..7727ceecc61 |
29 |
--- /dev/null |
30 |
+++ b/dev-python/anyio/anyio-3.2.1.ebuild |
31 |
@@ -0,0 +1,47 @@ |
32 |
+# Copyright 1999-2021 Gentoo Authors |
33 |
+# Distributed under the terms of the GNU General Public License v2 |
34 |
+ |
35 |
+EAPI=7 |
36 |
+ |
37 |
+PYTHON_COMPAT=( python3_{8..9} ) |
38 |
+ |
39 |
+inherit distutils-r1 |
40 |
+ |
41 |
+DESCRIPTION="Compatibility layer for multiple asynchronous event loop implementations" |
42 |
+HOMEPAGE=" |
43 |
+ https://github.com/agronholm/anyio |
44 |
+ https://pypi.org/project/anyio/ |
45 |
+" |
46 |
+SRC_URI="mirror://pypi/${P:0:1}/${PN}/${P}.tar.gz" |
47 |
+ |
48 |
+LICENSE="MIT" |
49 |
+SLOT="0" |
50 |
+KEYWORDS="~amd64 ~arm" |
51 |
+ |
52 |
+RDEPEND=" |
53 |
+ >=dev-python/idna-2.8[${PYTHON_USEDEP}] |
54 |
+ >=dev-python/sniffio-1.1[${PYTHON_USEDEP}] |
55 |
+" |
56 |
+ |
57 |
+BDEPEND=" |
58 |
+ test? ( |
59 |
+ >=dev-python/hypothesis-4.0[${PYTHON_USEDEP}] |
60 |
+ >=dev-python/pytest-mock-3.6.1[${PYTHON_USEDEP}] |
61 |
+ dev-python/trustme[${PYTHON_USEDEP}] |
62 |
+ >=dev-python/uvloop-0.15[${PYTHON_USEDEP}] |
63 |
+ ) |
64 |
+" |
65 |
+ |
66 |
+distutils_enable_tests --install pytest |
67 |
+distutils_enable_sphinx docs \ |
68 |
+ dev-python/sphinx_rtd_theme \ |
69 |
+ dev-python/sphinx-autodoc-typehints |
70 |
+ |
71 |
+PATCHES=( |
72 |
+ "${FILESDIR}"/${P}-missing-trio.patch |
73 |
+) |
74 |
+ |
75 |
+python_test() { |
76 |
+ distutils_install_for_testing |
77 |
+ epytest -Wdefault -m 'not network' -p no:django |
78 |
+} |
79 |
|
80 |
diff --git a/dev-python/anyio/files/anyio-3.2.1-missing-trio.patch b/dev-python/anyio/files/anyio-3.2.1-missing-trio.patch |
81 |
new file mode 100644 |
82 |
index 00000000000..492fe40fe70 |
83 |
--- /dev/null |
84 |
+++ b/dev-python/anyio/files/anyio-3.2.1-missing-trio.patch |
85 |
@@ -0,0 +1,125 @@ |
86 |
+From d05f92bddc4b34a8d527f66d5d27513cd91c741a Mon Sep 17 00:00:00 2001 |
87 |
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o> |
88 |
+Date: Thu, 24 Jun 2021 09:16:01 +0200 |
89 |
+Subject: [PATCH] Handle missing trio gracefully |
90 |
+ |
91 |
+Make it possible to use anyio without actually having to install trio. |
92 |
+This involves modifying get_all_backends() to only return the backends |
93 |
+that are actually present, and teaching the tests to skip trio if it |
94 |
+is not importable. |
95 |
+--- |
96 |
+ src/anyio/_core/_eventloop.py | 13 +++++++++---- |
97 |
+ tests/conftest.py | 9 ++++++++- |
98 |
+ tests/test_pytest_plugin.py | 2 +- |
99 |
+ tests/test_taskgroups.py | 10 ++++++++-- |
100 |
+ 4 files changed, 26 insertions(+), 8 deletions(-) |
101 |
+ |
102 |
+diff --git a/src/anyio/_core/_eventloop.py b/src/anyio/_core/_eventloop.py |
103 |
+index f2364a3..431a922 100644 |
104 |
+--- a/src/anyio/_core/_eventloop.py |
105 |
++++ b/src/anyio/_core/_eventloop.py |
106 |
+@@ -10,8 +10,6 @@ import sniffio |
107 |
+ # This must be updated when new backends are introduced |
108 |
+ from ._compat import DeprecatedAwaitableFloat |
109 |
+ |
110 |
+-BACKENDS = 'asyncio', 'trio' |
111 |
+- |
112 |
+ T_Retval = TypeVar('T_Retval') |
113 |
+ threadlocals = threading.local() |
114 |
+ |
115 |
+@@ -106,8 +104,15 @@ def current_time() -> DeprecatedAwaitableFloat: |
116 |
+ |
117 |
+ |
118 |
+ def get_all_backends() -> Tuple[str, ...]: |
119 |
+- """Return a tuple of the names of all built-in backends.""" |
120 |
+- return BACKENDS |
121 |
++ """Return a tuple of the names of all available built-in backends.""" |
122 |
++ backends = ['asyncio'] |
123 |
++ try: |
124 |
++ import trio |
125 |
++ except ImportError: |
126 |
++ pass |
127 |
++ else: |
128 |
++ backends.append(trio) |
129 |
++ return tuple(backends) |
130 |
+ |
131 |
+ |
132 |
+ def get_cancelled_exc_class() -> Type[BaseException]: |
133 |
+diff --git a/tests/conftest.py b/tests/conftest.py |
134 |
+index f040ac8..5834395 100644 |
135 |
+--- a/tests/conftest.py |
136 |
++++ b/tests/conftest.py |
137 |
+@@ -8,6 +8,11 @@ import trustme |
138 |
+ from _pytest.fixtures import SubRequest |
139 |
+ from trustme import CA |
140 |
+ |
141 |
++try: |
142 |
++ import trio |
143 |
++except ImportError: |
144 |
++ trio = None |
145 |
++ |
146 |
+ uvloop_marks = [] |
147 |
+ uvloop_policy = None |
148 |
+ try: |
149 |
+@@ -30,7 +35,9 @@ pytest_plugins = ['pytester'] |
150 |
+ id='asyncio'), |
151 |
+ pytest.param(('asyncio', {'debug': True, 'policy': uvloop_policy}), marks=uvloop_marks, |
152 |
+ id='asyncio+uvloop'), |
153 |
+- pytest.param('trio') |
154 |
++ pytest.param('trio', |
155 |
++ marks=[pytest.mark.skipif(trio is None, |
156 |
++ reason='trio is not available')]) |
157 |
+ ]) |
158 |
+ def anyio_backend(request: SubRequest) -> Tuple[str, Dict[str, Any]]: |
159 |
+ return request.param |
160 |
+diff --git a/tests/test_pytest_plugin.py b/tests/test_pytest_plugin.py |
161 |
+index bb254a5..d55d511 100644 |
162 |
+--- a/tests/test_pytest_plugin.py |
163 |
++++ b/tests/test_pytest_plugin.py |
164 |
+@@ -135,7 +135,7 @@ def test_asyncio(testdir: Testdir) -> None: |
165 |
+ ) |
166 |
+ |
167 |
+ result = testdir.runpytest('-v') |
168 |
+- result.assert_outcomes(passed=2, failed=1, errors=2) |
169 |
++ result.assert_outcomes(passed=2, failed=1, errors=len(get_all_backends())) |
170 |
+ |
171 |
+ |
172 |
+ def test_autouse_async_fixture(testdir: Testdir) -> None: |
173 |
+diff --git a/tests/test_taskgroups.py b/tests/test_taskgroups.py |
174 |
+index 62a2389..47971c0 100644 |
175 |
+--- a/tests/test_taskgroups.py |
176 |
++++ b/tests/test_taskgroups.py |
177 |
+@@ -5,7 +5,6 @@ import time |
178 |
+ from typing import Any, AsyncGenerator, Coroutine, Dict, Generator, NoReturn, Set |
179 |
+ |
180 |
+ import pytest |
181 |
+-import trio |
182 |
+ |
183 |
+ import anyio |
184 |
+ from anyio import ( |
185 |
+@@ -13,6 +12,11 @@ from anyio import ( |
186 |
+ fail_after, get_cancelled_exc_class, move_on_after, sleep, wait_all_tasks_blocked) |
187 |
+ from anyio.abc import TaskGroup, TaskStatus |
188 |
+ |
189 |
++try: |
190 |
++ import trio |
191 |
++except ImportError: |
192 |
++ trio = None |
193 |
++ |
194 |
+ if sys.version_info < (3, 7): |
195 |
+ current_task = asyncio.Task.current_task |
196 |
+ else: |
197 |
+@@ -53,7 +57,9 @@ async def test_success() -> None: |
198 |
+ |
199 |
+ @pytest.mark.parametrize('module', [ |
200 |
+ pytest.param(asyncio, id='asyncio'), |
201 |
+- pytest.param(trio, id='trio') |
202 |
++ pytest.param(trio, id='trio', |
203 |
++ marks=[pytest.mark.skipif(trio is None, |
204 |
++ reason='trio is not available')]) |
205 |
+ ]) |
206 |
+ def test_run_natively(module: Any) -> None: |
207 |
+ async def testfunc() -> None: |
208 |
+-- |
209 |
+2.32.0 |
210 |
+ |