1 |
commit: 843541a5c33e89e226b075276c1d24b158771d94 |
2 |
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Aug 25 05:26:27 2021 +0000 |
4 |
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Aug 25 05:29:05 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=843541a5 |
7 |
|
8 |
dev-python/PyContracts: enable py3.10, add test dep on numpy |
9 |
|
10 |
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org> |
11 |
|
12 |
.../PyContracts/PyContracts-1.8.14-r1.ebuild | 13 +- |
13 |
.../files/PyContracts-1.8.14-fix-py3.10.patch | 150 +++++++++++++++++++++ |
14 |
2 files changed, 161 insertions(+), 2 deletions(-) |
15 |
|
16 |
diff --git a/dev-python/PyContracts/PyContracts-1.8.14-r1.ebuild b/dev-python/PyContracts/PyContracts-1.8.14-r1.ebuild |
17 |
index 4158f29912c..f94e9113dd4 100644 |
18 |
--- a/dev-python/PyContracts/PyContracts-1.8.14-r1.ebuild |
19 |
+++ b/dev-python/PyContracts/PyContracts-1.8.14-r1.ebuild |
20 |
@@ -3,8 +3,7 @@ |
21 |
|
22 |
EAPI=7 |
23 |
|
24 |
-DISTUTILS_USE_SETUPTOOLS=bdepend |
25 |
-PYTHON_COMPAT=( python3_{7..9} pypy3 ) |
26 |
+PYTHON_COMPAT=( python3_{8..10} pypy3 ) |
27 |
|
28 |
inherit distutils-r1 |
29 |
|
30 |
@@ -22,5 +21,15 @@ RDEPEND=" |
31 |
dev-python/pyparsing[${PYTHON_USEDEP}] |
32 |
dev-python/six[${PYTHON_USEDEP}] |
33 |
" |
34 |
+BDEPEND=" |
35 |
+ test? ( $(python_gen_cond_dep ' |
36 |
+ dev-python/numpy[${PYTHON_USEDEP}] |
37 |
+ ' 'python*' ) |
38 |
+ ) |
39 |
+" |
40 |
+ |
41 |
+PATCHES=( |
42 |
+ "${FILESDIR}/${P}-fix-py3.10.patch" |
43 |
+) |
44 |
|
45 |
distutils_enable_tests nose |
46 |
|
47 |
diff --git a/dev-python/PyContracts/files/PyContracts-1.8.14-fix-py3.10.patch b/dev-python/PyContracts/files/PyContracts-1.8.14-fix-py3.10.patch |
48 |
new file mode 100644 |
49 |
index 00000000000..754b40efabd |
50 |
--- /dev/null |
51 |
+++ b/dev-python/PyContracts/files/PyContracts-1.8.14-fix-py3.10.patch |
52 |
@@ -0,0 +1,150 @@ |
53 |
+From d23ee2902e9e9aeffec86cbdb7a392d71be70861 Mon Sep 17 00:00:00 2001 |
54 |
+From: slorg1 <slorg1@×××××.com> |
55 |
+Date: Tue, 16 Apr 2019 14:13:52 -0400 |
56 |
+Subject: [PATCH] + upgrade to use collections.abc as needed for python 3.6+ |
57 |
+ |
58 |
+--- a/src/contracts/library/map.py |
59 |
++++ b/src/contracts/library/map.py |
60 |
+@@ -1,7 +1,11 @@ |
61 |
+ from ..interface import Contract, ContractNotRespected |
62 |
+ from ..syntax import (W, contract_expression, O, S, add_contract, add_keyword, |
63 |
+ Keyword) |
64 |
+-import collections |
65 |
++ |
66 |
++try: |
67 |
++ import collections.abc as collectionsAbc # python 3.6+ |
68 |
++except ImportError: |
69 |
++ import collections as collectionsAbc |
70 |
+ |
71 |
+ |
72 |
+ class Map(Contract): |
73 |
+@@ -13,7 +17,7 @@ def __init__(self, length=None, key_c=None, value_c=None, where=None): |
74 |
+ self.value_c = value_c |
75 |
+ |
76 |
+ def check_contract(self, context, value, silent): |
77 |
+- if not isinstance(value, collections.Mapping): |
78 |
++ if not isinstance(value, collectionsAbc.Mapping): |
79 |
+ error = 'Expected a Mapping, got %r.' % value.__class__.__name__ |
80 |
+ raise ContractNotRespected(contract=self, error=error, |
81 |
+ value=value, context=context) |
82 |
+--- a/src/contracts/library/miscellaneous_aliases.py |
83 |
++++ b/src/contracts/library/miscellaneous_aliases.py |
84 |
+@@ -1,12 +1,16 @@ |
85 |
+-import collections |
86 |
+- |
87 |
++try: |
88 |
++ import collections.abc as collectionsAbc # python 3.6+ |
89 |
++except ImportError: |
90 |
++ import collections as collectionsAbc |
91 |
+ |
92 |
+ |
93 |
+ def ist(C): |
94 |
++ |
95 |
+ def f(x): |
96 |
+ f.__name__ = 'isinstance_of_%s' % C.__name__ |
97 |
+ if not isinstance(x, C): |
98 |
+ raise ValueError('Value is not an instance of %s.' % C.__name__) |
99 |
++ |
100 |
+ return f |
101 |
+ |
102 |
+ |
103 |
+@@ -14,33 +18,32 @@ def m_new_contract(name, f): |
104 |
+ from contracts.library.extensions import CheckCallable |
105 |
+ from contracts.library.extensions import Extension |
106 |
+ Extension.registrar[name] = CheckCallable(f) |
107 |
+- |
108 |
+ |
109 |
+-m_new_contract('Container', ist(collections.Container)) |
110 |
+-# todo: Iterable(x) |
111 |
+-m_new_contract('Iterable', ist(collections.Iterable)) |
112 |
+- |
113 |
+-m_new_contract('Hashable', ist(collections.Hashable)) |
114 |
+ |
115 |
++m_new_contract('Container', ist(collectionsAbc.Container)) |
116 |
++# todo: Iterable(x) |
117 |
++m_new_contract('Iterable', ist(collectionsAbc.Iterable)) |
118 |
+ |
119 |
++m_new_contract('Hashable', ist(collectionsAbc.Hashable)) |
120 |
+ |
121 |
+-m_new_contract('Iterator', ist(collections.Iterator)) |
122 |
+-m_new_contract('Sized', ist(collections.Sized)) |
123 |
+-m_new_contract('Callable', ist(collections.Callable)) |
124 |
+-m_new_contract('Sequence', ist(collections.Sequence)) |
125 |
+-m_new_contract('Set', ist(collections.Set)) |
126 |
+-m_new_contract('MutableSequence', ist(collections.MutableSequence)) |
127 |
+-m_new_contract('MutableSet', ist(collections.MutableSet)) |
128 |
+-m_new_contract('Mapping', ist(collections.Mapping)) |
129 |
+-m_new_contract('MutableMapping', ist(collections.MutableMapping)) |
130 |
+-#new_contract('MappingView', ist(collections.MappingView)) |
131 |
+-#new_contract('ItemsView', ist(collections.ItemsView)) |
132 |
+-#new_contract('ValuesView', ist(collections.ValuesView)) |
133 |
++m_new_contract('Iterator', ist(collectionsAbc.Iterator)) |
134 |
++m_new_contract('Sized', ist(collectionsAbc.Sized)) |
135 |
++m_new_contract('Callable', ist(collectionsAbc.Callable)) |
136 |
++m_new_contract('Sequence', ist(collectionsAbc.Sequence)) |
137 |
++m_new_contract('Set', ist(collectionsAbc.Set)) |
138 |
++m_new_contract('MutableSequence', ist(collectionsAbc.MutableSequence)) |
139 |
++m_new_contract('MutableSet', ist(collectionsAbc.MutableSet)) |
140 |
++m_new_contract('Mapping', ist(collectionsAbc.Mapping)) |
141 |
++m_new_contract('MutableMapping', ist(collectionsAbc.MutableMapping)) |
142 |
++# new_contract('MappingView', ist(collections.MappingView)) |
143 |
++# new_contract('ItemsView', ist(collections.ItemsView)) |
144 |
++# new_contract('ValuesView', ist(collections.ValuesView)) |
145 |
+ |
146 |
+ |
147 |
+ # Not a lambda to have better messages |
148 |
+-def is_None(x): |
149 |
++def is_None(x): |
150 |
+ return x is None |
151 |
+ |
152 |
++ |
153 |
+ m_new_contract('None', is_None) |
154 |
+ m_new_contract('NoneType', is_None) |
155 |
+--- a/src/contracts/library/seq.py |
156 |
++++ b/src/contracts/library/seq.py |
157 |
+@@ -1,7 +1,12 @@ |
158 |
+ from ..interface import Contract, ContractNotRespected |
159 |
+ from ..syntax import (add_contract, W, contract_expression, O, S, add_keyword, |
160 |
+ Keyword) |
161 |
+-import collections |
162 |
++ |
163 |
++try: |
164 |
++ import collections.abc as collectionsAbc # python 3.6+ |
165 |
++except ImportError: |
166 |
++ import collections as collectionsAbc |
167 |
++ |
168 |
+ from past.builtins import xrange |
169 |
+ |
170 |
+ try: |
171 |
+@@ -38,7 +43,7 @@ def check_contract(self, context, value, silent): |
172 |
+ |
173 |
+ return |
174 |
+ |
175 |
+- if not isinstance(value, collections.Sequence): |
176 |
++ if not isinstance(value, collectionsAbc.Sequence): |
177 |
+ error = 'Expected a Sequence, got %r.' % value.__class__.__name__ |
178 |
+ raise ContractNotRespected(self, error, value, context) |
179 |
+ |
180 |
+--- a/src/contracts/library/sets.py |
181 |
++++ b/src/contracts/library/sets.py |
182 |
+@@ -1,7 +1,10 @@ |
183 |
+ from ..interface import Contract, ContractNotRespected, describe_type |
184 |
+ from ..syntax import (Keyword, O, S, W, add_contract, add_keyword, |
185 |
+ contract_expression) |
186 |
+-import collections |
187 |
++try: |
188 |
++ import collections.abc as collectionsAbc # python 3.6+ |
189 |
++except ImportError: |
190 |
++ import collections as collectionsAbc |
191 |
+ |
192 |
+ |
193 |
+ class ASet(Contract): |
194 |
+@@ -13,7 +16,7 @@ def __init__(self, length_contract=None, |
195 |
+ self.elements_contract = elements_contract |
196 |
+ |
197 |
+ def check_contract(self, context, value, silent): |
198 |
+- if not isinstance(value, collections.Set): |
199 |
++ if not isinstance(value, collectionsAbc.Set): |
200 |
+ error = 'Expected a set, got %r.' % describe_type(value) |
201 |
+ raise ContractNotRespected(self, error, value, context) |
202 |
+ |