[packages/python-gast] - new; python2 patch taken from git
qboosh
qboosh at pld-linux.org
Sat Mar 26 19:16:39 CET 2022
commit 8b1a3820179591d5747c940a887bc67898fe30f2
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date: Sat Mar 26 19:18:30 2022 +0100
- new; python2 patch taken from git
gast-python2.patch | 250 +++++++++++++++++++++++++++++++++++++++++++++++++++++
python-gast.spec | 127 +++++++++++++++++++++++++++
2 files changed, 377 insertions(+)
---
diff --git a/python-gast.spec b/python-gast.spec
new file mode 100644
index 0000000..2ecfe0c
--- /dev/null
+++ b/python-gast.spec
@@ -0,0 +1,127 @@
+#
+# Conditional build:
+%bcond_without tests # unit tests
+%bcond_without python2 # CPython 2.x module
+%bcond_without python3 # CPython 3.x module
+
+Summary: Python AST that abstracts the underlying Python version
+Summary(pl.UTF-8): Pythonowe AST niezależne od wersji Pythona
+Name: python-gast
+Version: 0.5.3
+Release: 1
+License: BSD
+Group: Libraries/Python
+#Source0Download: https://pypi.org/simple/gast/
+Source0: https://files.pythonhosted.org/packages/source/g/gast/gast-%{version}.tar.gz
+# Source0-md5: fdff900805e03e9dd76d377eb4cbaed7
+Patch0: gast-python2.patch
+URL: https://pypi.org/project/gast/
+%if %{with python2}
+BuildRequires: python-modules >= 1:2.7
+BuildRequires: python-setuptools
+%endif
+%if %{with python3}
+BuildRequires: python3-modules >= 1:3.4
+BuildRequires: python3-setuptools
+%endif
+BuildRequires: rpm-pythonprov
+BuildRequires: rpmbuild(macros) >= 1.714
+Requires: python-modules >= 1:2.7
+BuildArch: noarch
+BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+A generic AST to represent Python2 and Python3's Abstract Syntax Tree
+(AST). GAST provides a compatibility layer between the AST of various
+Python versions, as produced by "ast.parse" from the standard "ast"
+module.
+
+%description -l pl.UTF-8
+Ogólne AST reprezentujące abstrakcyjne drzewo składniowe (Abstract
+Syntax Tree) Pythona 2 i 3. GAST zapewnia warstwę zgodności między AST
+różnych wersji Pythona, w postaci tworzonej przez "ast.parse" ze
+standardowego modułu "ast".
+
+%package -n python3-gast
+Summary: Python AST that abstracts the underlying Python version
+Summary(pl.UTF-8): Pythonowe AST niezależne od wersji Pythona
+Group: Libraries/Python
+Requires: python3-modules >= 1:3.4
+
+%description -n python3-gast
+A generic AST to represent Python2 and Python3's Abstract Syntax Tree
+(AST). GAST provides a compatibility layer between the AST of various
+Python versions, as produced by "ast.parse" from the standard "ast"
+module.
+
+%description -n python3-gast -l pl.UTF-8
+Ogólne AST reprezentujące abstrakcyjne drzewo składniowe (Abstract
+Syntax Tree) Pythona 2 i 3. GAST zapewnia warstwę zgodności między AST
+różnych wersji Pythona, w postaci tworzonej przez "ast.parse" ze
+standardowego modułu "ast".
+
+%prep
+%setup -q -n gast-%{version}
+%patch0 -p1
+
+%build
+%if %{with python2}
+%py_build
+# deprecated target, but sometimes still used: %{?with_tests:test}
+
+%if %{with tests}
+#PYTHONPATH=$(pwd)
+%{__python} -m unittest discover -s tests
+# -t $(pwd)
+## use explicit plugins list for reliable builds (delete PYTEST_PLUGINS if empty)
+#PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
+#PYTEST_PLUGINS= \
+#%{__python} -m pytest ...
+%endif
+%endif
+
+%if %{with python3}
+%py3_build
+# deprecated target, but sometimes still used: %{?with_tests:test}
+
+%if %{with tests}
+#PYTHONPATH=$(pwd)
+%{__python3} -m unittest discover -s tests
+## use explicit plugins list for reliable builds (delete PYTEST_PLUGINS if empty)
+#PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
+#PYTEST_PLUGINS= \
+#%{__python3} -m pytest ...
+%endif
+%endif
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+%if %{with python2}
+%py_install
+
+%py_postclean
+%endif
+
+%if %{with python3}
+%py3_install
+%endif
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%if %{with python2}
+%files
+%defattr(644,root,root,755)
+%doc LICENSE README.rst
+%{py_sitescriptdir}/gast
+%{py_sitescriptdir}/gast-%{version}-py*.egg-info
+%endif
+
+%if %{with python3}
+%files -n python3-gast
+%defattr(644,root,root,755)
+%doc LICENSE README.rst
+%{py3_sitescriptdir}/gast
+%{py3_sitescriptdir}/gast-%{version}-py*.egg-info
+%endif
diff --git a/gast-python2.patch b/gast-python2.patch
new file mode 100644
index 0000000..6e5a796
--- /dev/null
+++ b/gast-python2.patch
@@ -0,0 +1,250 @@
+From f6f2cbcc802e3112b0aac8d93a306744817baeea Mon Sep 17 00:00:00 2001
+From: serge-sans-paille <serge.guelton at telecom-bretagne.eu>
+Date: Thu, 24 Feb 2022 14:36:58 +0100
+Subject: [PATCH] Restore python2 testing and support
+
+Fix #66
+---
+ .github/workflows/core.yml | 2 +-
+ gast/gast.py | 2 +-
+ gast/unparser.py | 55 +++++++++++++++++++-------------------
+ 3 files changed, 29 insertions(+), 30 deletions(-)
+
+#diff --git a/.github/workflows/core.yml b/.github/workflows/core.yml
+#index 60c6225..9c1996a 100644
+#--- a/.github/workflows/core.yml
+#+++ b/.github/workflows/core.yml
+#@@ -12,7 +12,7 @@ jobs:
+# runs-on: ubuntu-18.04
+# strategy:
+# matrix:
+#- python-version: [3.6, 3.8, 3.9, 3.10-dev]
+#+ python-version: [2.7, 3.6, 3.8, 3.9, 3.10-dev]
+# steps:
+# - uses: actions/checkout at v2
+# - name: Setup Python ${{ matrix.python-version }}
+diff --git a/gast/gast.py b/gast/gast.py
+index 63327ca..a93fb4c 100644
+--- a/gast/gast.py
++++ b/gast/gast.py
+@@ -308,7 +308,7 @@ def parse(*args, **kwargs):
+
+
+ def unparse(gast_obj):
+- from gast.unparser import unparse
++ from .unparser import unparse
+ return unparse(gast_obj)
+
+
+diff --git a/gast/unparser.py b/gast/unparser.py
+index b43f847..2f07a9d 100644
+--- a/gast/unparser.py
++++ b/gast/unparser.py
+@@ -50,9 +50,9 @@
+ # Agreement.
+
+ import sys
+-from gast import *
++from . import *
+ from contextlib import contextmanager
+-from enum import auto, Enum
++from string import printable
+
+
+ class nullcontext(object):
+@@ -96,14 +96,14 @@ class _Precedence(object):
+
+ _SINGLE_QUOTES = ("'", '"')
+ _MULTI_QUOTES = ('"""', "'''")
+-_ALL_QUOTES = (*_SINGLE_QUOTES, *_MULTI_QUOTES)
++_ALL_QUOTES = _SINGLE_QUOTES + _MULTI_QUOTES
+
+ class _Unparser(NodeVisitor):
+ """Methods in this class recursively traverse an AST and
+ output source code for the abstract syntax; original formatting
+ is disregarded."""
+
+- def __init__(self, *, _avoid_backslashes=False):
++ def __init__(self, _avoid_backslashes=False):
+ self._source = []
+ self._buffer = []
+ self._precedences = {}
+@@ -158,7 +158,7 @@ def buffer(self):
+ return value
+
+ @contextmanager
+- def block(self, *, extra = None):
++ def block(self, extra = None):
+ """A context manager for preparing the source for blocks. It adds
+ the character':', increases the indentation on enter and decreases
+ the indentation on exit. If *extra* is given, it will be directly
+@@ -216,14 +216,14 @@ def get_raw_docstring(self, node):
+ def get_type_comment(self, node):
+ comment = self._type_ignores.get(node.lineno) or node.type_comment
+ if comment is not None:
+- return f" # type: {comment}"
++ return " # type: {}".format(comment)
+
+ def traverse(self, node):
+ if isinstance(node, list):
+ for item in node:
+ self.traverse(item)
+ else:
+- super().visit(node)
++ super(_Unparser, self).visit(node)
+
+ # Note: as visit() resets the output text, do NOT rely on
+ # NodeVisitor.generic_visit to handle any nodes (as it calls back in to
+@@ -245,7 +245,7 @@ def _write_docstring_and_traverse_body(self, node):
+
+ def visit_Module(self, node):
+ self._type_ignores = {
+- ignore.lineno: f"ignore{ignore.tag}"
++ ignore.lineno: "ignore{}".format(ignore.tag)
+ for ignore in node.type_ignores
+ }
+ self._write_docstring_and_traverse_body(node)
+@@ -372,7 +372,7 @@ def visit_Raise(self, node):
+ self.fill("raise")
+ if not node.exc:
+ if node.cause:
+- raise ValueError(f"Node can't use cause without an exception.")
++ raise ValueError("Node can't use cause without an exception.")
+ return
+ self.write(" ")
+ self.traverse(node.exc)
+@@ -510,7 +510,7 @@ def visit_AsyncWith(self, node):
+ self.traverse(node.body)
+
+ def _str_literal_helper(
+- self, string, *, quote_types=_ALL_QUOTES, escape_special_whitespace=False
++ self, string, quote_types=_ALL_QUOTES, escape_special_whitespace=False
+ ):
+ """Helper for writing string literals, minimizing escapes.
+ Returns the tuple (string literal to write, possible quote types).
+@@ -521,7 +521,7 @@ def escape_char(c):
+ if not escape_special_whitespace and c in "\n\t":
+ return c
+ # Always escape backslashes and other non-printable characters
+- if c == "\\" or not c.isprintable():
++ if c == "\\" or not all(cc in printable for cc in c):
+ return c.encode("unicode_escape").decode("ascii")
+ return c
+
+@@ -547,11 +547,11 @@ def escape_char(c):
+ escaped_string = escaped_string[:-1] + "\\" + escaped_string[-1]
+ return escaped_string, possible_quotes
+
+- def _write_str_avoiding_backslashes(self, string, *, quote_types=_ALL_QUOTES):
++ def _write_str_avoiding_backslashes(self, string, quote_types=_ALL_QUOTES):
+ """Write string literal value with a best effort attempt to avoid backslashes."""
+ string, quote_types = self._str_literal_helper(string, quote_types=quote_types)
+ quote_type = quote_types[0]
+- self.write(f"{quote_type}{string}{quote_type}")
++ self.write("{0}{1}{0}".format(quote_type, string))
+
+ def visit_JoinedStr(self, node):
+ self.write("f")
+@@ -582,7 +582,7 @@ def visit_JoinedStr(self, node):
+ new_buffer.append(value)
+ value = "".join(new_buffer)
+ quote_type = quote_types[0]
+- self.write(f"{quote_type}{value}{quote_type}")
++ self.write("{0}{1}{0}".format(quote_type, value))
+
+ def visit_FormattedValue(self, node):
+ self.write("f")
+@@ -614,7 +614,7 @@ def _fstring_FormattedValue(self, node, write):
+ conversion = chr(node.conversion)
+ if conversion not in "sra":
+ raise ValueError("Unknown f-string conversion.")
+- write(f"!{conversion}")
++ write("!{}".format(conversion))
+ if node.format_spec:
+ write(":")
+ meth = getattr(self, "_fstring_" + type(node.format_spec).__name__)
+@@ -637,7 +637,7 @@ def _write_constant(self, value):
+ self.write(
+ repr(value)
+ .replace("inf", _INFSTR)
+- .replace("nan", f"({_INFSTR}-{_INFSTR})")
++ .replace("nan", "({0}-{0})".format(_INFSTR))
+ )
+ elif self._avoid_backslashes and isinstance(value, str):
+ self._write_str_avoiding_backslashes(value)
+@@ -649,7 +649,7 @@ def visit_Constant(self, node):
+ if isinstance(value, tuple):
+ with self.delimit("(", ")"):
+ self.items_view(self._write_constant, value)
+- elif value is ...:
++ elif value is Ellipsis:
+ self.write("...")
+ else:
+ if node.kind == "u":
+@@ -811,7 +811,7 @@ def visit_BinOp(self, node):
+
+ self.set_precedence(left_precedence, node.left)
+ self.traverse(node.left)
+- self.write(f" {operator} ")
++ self.write(" {} ".format(operator))
+ self.set_precedence(right_precedence, node.right)
+ self.traverse(node.right)
+
+@@ -841,16 +841,15 @@ def visit_Compare(self, node):
+
+ def visit_BoolOp(self, node):
+ operator = self.boolops[node.op.__class__.__name__]
+- operator_precedence = self.boolop_precedence[operator]
++ operator_precedence = [self.boolop_precedence[operator]]
+
+ def increasing_level_traverse(node):
+- nonlocal operator_precedence
+- operator_precedence = operator_precedence + 1
+- self.set_precedence(operator_precedence, node)
++ operator_precedence[0] += 1
++ self.set_precedence(operator_precedence[0], node)
+ self.traverse(node)
+
+- with self.require_parens(operator_precedence, node):
+- s = f" {operator} "
++ with self.require_parens(operator_precedence[0], node):
++ s = " {} ".format(operator)
+ self.interleave(lambda: self.write(s), increasing_level_traverse, node.values)
+
+ def visit_Attribute(self, node):
+@@ -1035,7 +1034,7 @@ def visit_MatchStar(self, node):
+ name = node.name
+ if name is None:
+ name = "_"
+- self.write(f"*{name}")
++ self.write("*{}".format(name))
+
+ def visit_MatchMapping(self, node):
+ def write_key_pattern_pair(pair):
+@@ -1055,7 +1054,7 @@ def write_key_pattern_pair(pair):
+ if rest is not None:
+ if keys:
+ self.write(", ")
+- self.write(f"**{rest}")
++ self.write("**{}".format(rest))
+
+ def visit_MatchClass(self, node):
+ self.set_precedence(_Precedence.ATOM, node.cls)
+@@ -1069,7 +1068,7 @@ def visit_MatchClass(self, node):
+ if attrs:
+ def write_attr_pattern(pair):
+ attr, pattern = pair
+- self.write(f"{attr}=")
++ self.write("{}=".format(attr))
+ self.traverse(pattern)
+
+ if patterns:
+@@ -1091,7 +1090,7 @@ def visit_MatchAs(self, node):
+ with self.require_parens(_Precedence.TEST, node):
+ self.set_precedence(_Precedence.BOR, node.pattern)
+ self.traverse(node.pattern)
+- self.write(f" as {node.name}")
++ self.write(" as {}".format(node.name))
+
+ def visit_MatchOr(self, node):
+ with self.require_parens(_Precedence.BOR, node):
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/python-gast.git/commitdiff/8b1a3820179591d5747c940a887bc67898fe30f2
More information about the pld-cvs-commit
mailing list