From 9ade20ddbaf71678a824304887265d43528dd7ee Mon Sep 17 00:00:00 2001 From: shixuantong Date: Sat, 8 Jan 2022 15:26:37 +0800 Subject: [PATCH] Fix build with py-setuptools 58.0.0+ and delete python3-nose buildrequire --- ...th-python-setuptools-58.0.0-or-later.patch | 191 ++++++++++++++++++ python-tempita.spec | 8 +- 2 files changed, 197 insertions(+), 2 deletions(-) create mode 100644 backport-Fix-build-with-python-setuptools-58.0.0-or-later.patch diff --git a/backport-Fix-build-with-python-setuptools-58.0.0-or-later.patch b/backport-Fix-build-with-python-setuptools-58.0.0-or-later.patch new file mode 100644 index 0000000..758a324 --- /dev/null +++ b/backport-Fix-build-with-python-setuptools-58.0.0-or-later.patch @@ -0,0 +1,191 @@ +From 1abbc5aa310aa58e909f856829559cf9b8ad4a3a Mon Sep 17 00:00:00 2001 +From: Po-Chuan Hsieh +Date: Tue, 21 Sep 2021 11:27:46 +0800 +Subject: textproc/py-Tempita: Fix build with py-setuptools 58.0.0+ + +===> Configuring for py38-Tempita-0.5.2 +error in Tempita setup command: use_2to3 is invalid. +*** Error code 1 + +Stop. +make: stopped in /usr/ports/textproc/py-Tempita + +Reference: https://github.com/pypa/setuptools/blob/main/CHANGES.rst + https://github.com/pypa/setuptools/issues/2769 +patch from https://cgit.freebsd.org/ports/commit/?id=1abbc5aa310aa58e909f856829559cf9b8ad4a3a +--- + setup.py | 1 - + tempita/__init__.py | 36 ++++++++++++++++++------------------ + 2 files changed, 18 insertions(+), 19 deletions(-) + +diff --git a/setup.py b/setup.py +index 5daba94..9b8f2bb 100644 +--- a/setup.py ++++ b/setup.py +@@ -36,5 +36,4 @@ more to learn about it. + test_suite='nose.collector', + include_package_data=True, + zip_safe=True, +- use_2to3=True, + ) +diff --git a/tempita/__init__.py b/tempita/__init__.py +index 91407b3..96dd019 100644 +--- a/tempita/__init__.py ++++ b/tempita/__init__.py +@@ -32,10 +32,10 @@ If there are syntax errors ``TemplateError`` will be raised. + import re + import sys + import cgi +-from urllib import quote as url_quote ++from urllib.parse import quote as url_quote + import os + import tokenize +-from cStringIO import StringIO ++from io import StringIO + from tempita._looper import looper + from tempita.compat3 import bytes, basestring_, next, is_unicode, coerce_text + +@@ -101,7 +101,7 @@ class Template(object): + delimiters = (self.default_namespace['start_braces'], + self.default_namespace['end_braces']) + else: +- assert len(delimiters) == 2 and all([isinstance(delimeter, basestring) ++ assert len(delimiters) == 2 and all([isinstance(delimeter, str) + for delimeter in delimiters]) + self.default_namespace = self.__class__.default_namespace.copy() + self.default_namespace['start_braces'] = delimiters[0] +@@ -196,7 +196,7 @@ class Template(object): + position=None, name=self.name) + templ = self.get_template(inherit_template, self) + self_ = TemplateObject(self.name) +- for name, value in defs.iteritems(): ++ for name, value in defs.items(): + setattr(self_, name, value) + self_.body = body + ns = ns.copy() +@@ -292,7 +292,7 @@ class Template(object): + try: + try: + value = eval(code, self.default_namespace, ns) +- except SyntaxError, e: ++ except SyntaxError as e: + raise SyntaxError( + 'invalid syntax in expression: %s' % code) + return value +@@ -304,12 +304,12 @@ class Template(object): + else: + arg0 = coerce_text(e) + e.args = (self._add_line_info(arg0, pos),) +- raise exc_info[0], e, exc_info[2] ++ raise exc_info[0](e).with_traceback(exc_info[2]) + + def _exec(self, code, ns, pos): + __traceback_hide__ = True + try: +- exec code in self.default_namespace, ns ++ exec(code, self.default_namespace, ns) + except: + exc_info = sys.exc_info() + e = exc_info[1] +@@ -317,7 +317,7 @@ class Template(object): + e.args = (self._add_line_info(e.args[0], pos),) + else: + e.args = (self._add_line_info(None, pos),) +- raise exc_info[0], e, exc_info[2] ++ raise exc_info[0](e).with_traceback(exc_info[2]) + + def _repr(self, value, pos): + __traceback_hide__ = True +@@ -326,7 +326,7 @@ class Template(object): + return '' + if self._unicode: + try: +- value = unicode(value) ++ value = str(value) + except UnicodeDecodeError: + value = bytes(value) + else: +@@ -339,7 +339,7 @@ class Template(object): + exc_info = sys.exc_info() + e = exc_info[1] + e.args = (self._add_line_info(e.args[0], pos),) +- raise exc_info[0], e, exc_info[2] ++ raise exc_info[0](e).with_traceback(exc_info[2]) + else: + if self._unicode and isinstance(value, bytes): + if not self.default_encoding: +@@ -348,7 +348,7 @@ class Template(object): + '(no default_encoding provided)' % value) + try: + value = value.decode(self.default_encoding) +- except UnicodeDecodeError, e: ++ except UnicodeDecodeError as e: + raise UnicodeDecodeError( + e.encoding, + e.object, +@@ -385,7 +385,7 @@ def paste_script_template_renderer(content, vars, filename=None): + class bunch(dict): + + def __init__(self, **kw): +- for name, value in kw.iteritems(): ++ for name, value in kw.items(): + setattr(self, name, value) + + def __setattr__(self, name, value): +@@ -408,7 +408,7 @@ class bunch(dict): + + def __repr__(self): + items = [ +- (k, v) for k, v in self.iteritems()] ++ (k, v) for k, v in self.items()] + items.sort() + return '<%s %s>' % ( + self.__class__.__name__, +@@ -461,7 +461,7 @@ def url(v): + + + def attr(**kw): +- kw = list(kw.iteritems()) ++ kw = list(kw.items()) + kw.sort() + parts = [] + for name, value in kw: +@@ -543,7 +543,7 @@ class TemplateDef(object): + values = {} + sig_args, var_args, var_kw, defaults = self._func_signature + extra_kw = {} +- for name, value in kw.iteritems(): ++ for name, value in kw.items(): + if not var_kw and name not in sig_args: + raise TypeError( + 'Unexpected argument %s' % name) +@@ -566,7 +566,7 @@ class TemplateDef(object): + raise TypeError( + 'Extra position arguments: %s' + % ', '.join(repr(v) for v in args)) +- for name, value_expr in defaults.iteritems(): ++ for name, value_expr in defaults.items(): + if name not in values: + values[name] = self._template._eval( + value_expr, self._ns, self._pos) +@@ -612,7 +612,7 @@ class _Empty(object): + return 'Empty' + + def __unicode__(self): +- return u'' ++ return '' + + def __iter__(self): + return iter(()) +@@ -1156,7 +1156,7 @@ def fill_command(args=None): + vars.update(os.environ) + for value in args: + if '=' not in value: +- print('Bad argument: %r' % value) ++ print(('Bad argument: %r' % value)) + sys.exit(2) + name, value = value.split('=', 1) + if name.startswith('py:'): +-- +1.8.3.1 + diff --git a/python-tempita.spec b/python-tempita.spec index 0c005e3..b6c891c 100644 --- a/python-tempita.spec +++ b/python-tempita.spec @@ -1,20 +1,21 @@ %global srcname tempita Name: python-%{srcname} Version: 0.5.2 -Release: 1 +Release: 2 Summary: A small templating language for text substitution License: MIT URL: https://pypi.org/project/Tempita/%{version}/#description Source0: %{pypi_source} BuildArch: noarch +Patch6000: backport-Fix-build-with-python-setuptools-58.0.0-or-later.patch %global common_description %{expand:Tempita is a small templating language for text substitution. This isn't meant to be the Next Big Thing in templating; it is just a handy little templating language for when your project outgrows string.Template or % substitution. It is small, it embeds Python in strings, and it does not do much else.} -BuildRequires:python3-devel python3-setuptools python3-nose +BuildRequires:python3-devel python3-setuptools %description %{common_description} @@ -48,6 +49,9 @@ Summary: A small templating language for text substitution %{python3_sitelib}/*.egg-info %changelog +* Sat Jan 08 2022 shixuantong - 0.5.2-2 +- Fix build with py-setuptools 58.0.0+ and delete python3-nose buildrequire + * Thu Jan 28 2021 liudabo - 0.5.2-1 - upgrade version to 0.5.2