Gentoo Archives: gentoo-commits

From: Louis Sautier <sbraz@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/tempita/files/, dev-python/tempita/
Date: Thu, 09 Sep 2021 22:33:40
Message-Id: 1631226777.350ba3bc2c06478656b6520cd3d2ac74ddb62a2d.sbraz@gentoo
1 commit: 350ba3bc2c06478656b6520cd3d2ac74ddb62a2d
2 Author: Louis Sautier <sbraz <AT> gentoo <DOT> org>
3 AuthorDate: Thu Sep 9 21:41:10 2021 +0000
4 Commit: Louis Sautier <sbraz <AT> gentoo <DOT> org>
5 CommitDate: Thu Sep 9 22:32:57 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=350ba3bc
7
8 dev-python/tempita: disable setuptools' 2to3, use epytest
9
10 Also:
11 * The pypy patch is no longer required.
12 * Bump to EAPI 8 (no changes in installed files).
13
14 Closes: https://bugs.gentoo.org/812239
15 Signed-off-by: Louis Sautier <sbraz <AT> gentoo.org>
16
17 dev-python/tempita/files/tempita-0.5.3-2to3.patch | 233 +++++++++++++++++++++
18 .../tempita/files/tempita-0.5.3-pypy-tests.patch | 26 ---
19 dev-python/tempita/tempita-0.5.3-r3.ebuild | 20 +-
20 3 files changed, 240 insertions(+), 39 deletions(-)
21
22 diff --git a/dev-python/tempita/files/tempita-0.5.3-2to3.patch b/dev-python/tempita/files/tempita-0.5.3-2to3.patch
23 new file mode 100644
24 index 00000000000..d2aaae6546c
25 --- /dev/null
26 +++ b/dev-python/tempita/files/tempita-0.5.3-2to3.patch
27 @@ -0,0 +1,233 @@
28 +commit d886499651add63bbb944c25fc56a276cc2a7884
29 +Author: Louis Sautier <sautier.louis@×××××.com>
30 +Date: Thu Sep 9 23:35:03 2021 +0200
31 +
32 + Stop using deprecated 2to3 option for setuptools
33 +
34 +diff --git a/setup.py b/setup.py
35 +index f575020..678b555 100644
36 +--- a/setup.py
37 ++++ b/setup.py
38 +@@ -36,5 +36,4 @@ more to learn about it.
39 + test_suite='nose.collector',
40 + include_package_data=True,
41 + zip_safe=True,
42 +- use_2to3=True,
43 + )
44 +diff --git a/tempita/__init__.py b/tempita/__init__.py
45 +index acc2fd9..a3cb8a1 100755
46 +--- a/tempita/__init__.py
47 ++++ b/tempita/__init__.py
48 +@@ -35,9 +35,9 @@ import os
49 + import re
50 + import sys
51 + import tokenize
52 +-from cStringIO import StringIO
53 ++from io import StringIO
54 + from html import escape
55 +-from urllib import quote as url_quote
56 ++from urllib.parse import quote as url_quote
57 + from tempita._looper import looper
58 + from tempita.compat3 import bytes, basestring_, next, is_unicode, coerce_text
59 +
60 +@@ -103,7 +103,7 @@ class Template(object):
61 + delimiters = (self.default_namespace['start_braces'],
62 + self.default_namespace['end_braces'])
63 + else:
64 +- assert len(delimiters) == 2 and all([isinstance(delimeter, basestring)
65 ++ assert len(delimiters) == 2 and all([isinstance(delimeter, str)
66 + for delimeter in delimiters])
67 + self.default_namespace = self.__class__.default_namespace.copy()
68 + self.default_namespace['start_braces'] = delimiters[0]
69 +@@ -198,7 +198,7 @@ class Template(object):
70 + position=None, name=self.name)
71 + templ = self.get_template(inherit_template, self)
72 + self_ = TemplateObject(self.name)
73 +- for name, value in defs.iteritems():
74 ++ for name, value in defs.items():
75 + setattr(self_, name, value)
76 + self_.body = body
77 + ns = ns.copy()
78 +@@ -294,7 +294,7 @@ class Template(object):
79 + try:
80 + try:
81 + value = eval(code, self.default_namespace, ns)
82 +- except SyntaxError, e:
83 ++ except SyntaxError as e:
84 + raise SyntaxError(
85 + 'invalid syntax in expression: %s' % code)
86 + return value
87 +@@ -306,12 +306,12 @@ class Template(object):
88 + else:
89 + arg0 = coerce_text(e)
90 + e.args = (self._add_line_info(arg0, pos),)
91 +- raise exc_info[0], e, exc_info[2]
92 ++ raise exc_info[0](e).with_traceback(exc_info[2])
93 +
94 + def _exec(self, code, ns, pos):
95 + __traceback_hide__ = True
96 + try:
97 +- exec code in self.default_namespace, ns
98 ++ exec(code, self.default_namespace, ns)
99 + except:
100 + exc_info = sys.exc_info()
101 + e = exc_info[1]
102 +@@ -319,7 +319,7 @@ class Template(object):
103 + e.args = (self._add_line_info(e.args[0], pos),)
104 + else:
105 + e.args = (self._add_line_info(None, pos),)
106 +- raise exc_info[0], e, exc_info[2]
107 ++ raise exc_info[0](e).with_traceback(exc_info[2])
108 +
109 + def _repr(self, value, pos):
110 + __traceback_hide__ = True
111 +@@ -328,7 +328,7 @@ class Template(object):
112 + return ''
113 + if self._unicode:
114 + try:
115 +- value = unicode(value)
116 ++ value = str(value)
117 + except UnicodeDecodeError:
118 + value = bytes(value)
119 + else:
120 +@@ -341,7 +341,7 @@ class Template(object):
121 + exc_info = sys.exc_info()
122 + e = exc_info[1]
123 + e.args = (self._add_line_info(e.args[0], pos),)
124 +- raise exc_info[0], e, exc_info[2]
125 ++ raise exc_info[0](e).with_traceback(exc_info[2])
126 + else:
127 + if self._unicode and isinstance(value, bytes):
128 + if not self.default_encoding:
129 +@@ -350,7 +350,7 @@ class Template(object):
130 + '(no default_encoding provided)' % value)
131 + try:
132 + value = value.decode(self.default_encoding)
133 +- except UnicodeDecodeError, e:
134 ++ except UnicodeDecodeError as e:
135 + raise UnicodeDecodeError(
136 + e.encoding,
137 + e.object,
138 +@@ -387,7 +387,7 @@ def paste_script_template_renderer(content, vars, filename=None):
139 + class bunch(dict):
140 +
141 + def __init__(self, **kw):
142 +- for name, value in kw.iteritems():
143 ++ for name, value in kw.items():
144 + setattr(self, name, value)
145 +
146 + def __setattr__(self, name, value):
147 +@@ -410,7 +410,7 @@ class bunch(dict):
148 +
149 + def __repr__(self):
150 + items = [
151 +- (k, v) for k, v in self.iteritems()]
152 ++ (k, v) for k, v in self.items()]
153 + items.sort()
154 + return '<%s %s>' % (
155 + self.__class__.__name__,
156 +@@ -463,7 +463,7 @@ def url(v):
157 +
158 +
159 + def attr(**kw):
160 +- kw = list(kw.iteritems())
161 ++ kw = list(kw.items())
162 + kw.sort()
163 + parts = []
164 + for name, value in kw:
165 +@@ -545,7 +545,7 @@ class TemplateDef(object):
166 + values = {}
167 + sig_args, var_args, var_kw, defaults = self._func_signature
168 + extra_kw = {}
169 +- for name, value in kw.iteritems():
170 ++ for name, value in kw.items():
171 + if not var_kw and name not in sig_args:
172 + raise TypeError(
173 + 'Unexpected argument %s' % name)
174 +@@ -568,7 +568,7 @@ class TemplateDef(object):
175 + raise TypeError(
176 + 'Extra position arguments: %s'
177 + % ', '.join(repr(v) for v in args))
178 +- for name, value_expr in defaults.iteritems():
179 ++ for name, value_expr in defaults.items():
180 + if name not in values:
181 + values[name] = self._template._eval(
182 + value_expr, self._ns, self._pos)
183 +@@ -614,7 +614,7 @@ class _Empty(object):
184 + return 'Empty'
185 +
186 + def __unicode__(self):
187 +- return u''
188 ++ return ''
189 +
190 + def __iter__(self):
191 + return iter(())
192 +@@ -1164,7 +1164,7 @@ def fill_command(args=None):
193 + vars.update(os.environ)
194 + for value in args:
195 + if '=' not in value:
196 +- print('Bad argument: %r' % value)
197 ++ print(('Bad argument: %r' % value))
198 + sys.exit(2)
199 + name, value = value.split('=', 1)
200 + if name.startswith('py:'):
201 +diff --git a/tempita/_looper.py b/tempita/_looper.py
202 +index 6784c7c..70aded7 100644
203 +--- a/tempita/_looper.py
204 ++++ b/tempita/_looper.py
205 +@@ -7,9 +7,9 @@ These can be awkward to manage in a normal Python loop, but using the
206 + looper you can get a better sense of the context. Use like::
207 +
208 + >>> for loop, item in looper(['a', 'b', 'c']):
209 +- ... print loop.number, item
210 ++ ... print(loop.number, item)
211 + ... if not loop.last:
212 +- ... print '---'
213 ++ ... print('---')
214 + 1 a
215 + ---
216 + 2 b
217 +@@ -161,3 +161,4 @@ class loop_pos(object):
218 + return getter(item) != getter(other)
219 + else:
220 + return item[getter] != other[getter]
221 ++
222 +diff --git a/tempita/compat3.py b/tempita/compat3.py
223 +index 5e18fa0..f17f588 100644
224 +--- a/tempita/compat3.py
225 ++++ b/tempita/compat3.py
226 +@@ -4,7 +4,7 @@ __all__ = ['b', 'basestring_', 'bytes', 'next', 'is_unicode']
227 +
228 + if sys.version < "3":
229 + b = bytes = str
230 +- basestring_ = basestring
231 ++ basestring_ = str
232 + else:
233 +
234 + def b(s):
235 +@@ -18,14 +18,14 @@ text = str
236 + if sys.version < "3":
237 +
238 + def next(obj):
239 +- return obj.next()
240 ++ return obj.__next__()
241 + else:
242 + next = next
243 +
244 + if sys.version < "3":
245 +
246 + def is_unicode(obj):
247 +- return isinstance(obj, unicode)
248 ++ return isinstance(obj, str)
249 + else:
250 +
251 + def is_unicode(obj):
252 +@@ -39,7 +39,7 @@ def coerce_text(v):
253 + else:
254 + attr = '__str__'
255 + if hasattr(v, attr):
256 +- return unicode(v)
257 ++ return str(v)
258 + else:
259 + return bytes(v)
260 + return v
261
262 diff --git a/dev-python/tempita/files/tempita-0.5.3-pypy-tests.patch b/dev-python/tempita/files/tempita-0.5.3-pypy-tests.patch
263 deleted file mode 100644
264 index cdef27276be..00000000000
265 --- a/dev-python/tempita/files/tempita-0.5.3-pypy-tests.patch
266 +++ /dev/null
267 @@ -1,26 +0,0 @@
268 -diff --git a/docs/index.txt b/docs/index.txt
269 -index 6d943f6..afe3aa2 100644
270 ---- a/docs/index.txt
271 -+++ b/docs/index.txt
272 -@@ -82,7 +82,7 @@ error (the name will be displayed)::
273 - >>> tmpl.substitute()
274 - Traceback (most recent call last):
275 - ...
276 -- NameError: name 'name' is not defined at line 1 column 6 in file tmpl
277 -+ NameError:... name 'name' is not defined at line 1 column 6 in file tmpl
278 -
279 - You can also give a namespace to use by default, which
280 - ``.substitute(...)`` will augment::
281 -diff --git a/tests/test_template.txt b/tests/test_template.txt
282 -index 9564a9a..d9eb55d 100644
283 ---- a/tests/test_template.txt
284 -+++ b/tests/test_template.txt
285 -@@ -144,7 +144,7 @@ for a variable, if no value is given::
286 - >>> sub('{{x}}')
287 - Traceback (most recent call last):
288 - ...
289 -- NameError: name 'x' is not defined at line 1 column 3
290 -+ NameError:... name 'x' is not defined at line 1 column 3
291 -
292 - And comments work::
293 -
294
295 diff --git a/dev-python/tempita/tempita-0.5.3-r3.ebuild b/dev-python/tempita/tempita-0.5.3-r3.ebuild
296 index 6d5c3b27dc9..be3b68c6bb5 100644
297 --- a/dev-python/tempita/tempita-0.5.3-r3.ebuild
298 +++ b/dev-python/tempita/tempita-0.5.3-r3.ebuild
299 @@ -1,9 +1,9 @@
300 # Copyright 1999-2021 Gentoo Authors
301 # Distributed under the terms of the GNU General Public License v2
302
303 -EAPI=7
304 +EAPI=8
305
306 -PYTHON_COMPAT=( pypy3 python3_{7..10} )
307 +PYTHON_COMPAT=( pypy3 python3_{8..10} )
308 # The package uses pkg_resources
309 DISTUTILS_USE_SETUPTOOLS=manual
310
311 @@ -20,22 +20,19 @@ S="${WORKDIR}/ianb-${PN}-${MY_COMMIT}"
312 LICENSE="MIT"
313 SLOT="0"
314 KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ppc ppc64 ~s390 sparc x86 ~amd64-linux ~x86-linux"
315 -IUSE="test"
316 -RESTRICT="!test? ( test )"
317
318 RDEPEND="dev-python/setuptools[${PYTHON_USEDEP}]"
319 -BDEPEND="
320 - dev-python/setuptools[${PYTHON_USEDEP}]
321 - test? ( dev-python/pytest[${PYTHON_USEDEP}] )
322 -"
323 +BDEPEND="${RDEPEND}"
324
325 PATCHES=(
326 - "${FILESDIR}/${P}-pypy-tests.patch"
327 # cgi.escape has been removed in Python 3.9
328 "${FILESDIR}/${P}-cgi-escape.patch"
329 + # The 2to3 option for setuptools is deprecated
330 + "${FILESDIR}/${P}-2to3.patch"
331 )
332
333 distutils_enable_sphinx docs
334 +distutils_enable_tests pytest
335
336 python_prepare_all() {
337 # Remove reference to a non-existent CSS file
338 @@ -45,8 +42,5 @@ python_prepare_all() {
339 }
340
341 python_test() {
342 - # We need to append to sys.path, otherwise pytest imports
343 - # the module from ${S} (before it was 2to3'd)
344 - pytest --import-mode=append -vv tests/test_template.txt docs/index.txt \
345 - || die "Tests failed with ${EPYTHON}"
346 + epytest tests/test_template.txt docs/index.txt
347 }