From 40947a2f6defdcde0acaace688a035bcc105ad3a Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Dec 21 2016 22:52:14 +0000 Subject: 1.4.9, fix py3.6 compat, tests, modernize, rename py2 package --- diff --git a/.gitignore b/.gitignore index ce75ee5..3c65689 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ /astroid-1.4.4.tar.gz /astroid-1.4.5.tar.gz /astroid-1.4.8.tar.gz +/astroid-1.4.9.tar.gz diff --git a/365-rebased.patch b/365-rebased.patch new file mode 100644 index 0000000..6ad9086 --- /dev/null +++ b/365-rebased.patch @@ -0,0 +1,166 @@ +From db75314805c2b5df57883f49b7d93c62a079189e Mon Sep 17 00:00:00 2001 +From: Jared Garst +Date: Sun, 2 Oct 2016 07:22:51 -0700 +Subject: [PATCH] add format string support + +format strings require support for two new nodes: +FormattedValue(expr valu, int? conversion, expr? format_spec) +JoinedStr(expr* values) +--- + astroid/as_string.py | 15 ++++++++++++++- + astroid/node_classes.py | 22 ++++++++++++++++++++++ + astroid/nodes.py | 2 ++ + astroid/rebuilder.py | 12 ++++++++++++ + astroid/tests/unittest_python3.py | 11 +++++++++-- + tox.ini | 4 ++-- + 6 files changed, 61 insertions(+), 5 deletions(-) + +diff --git a/astroid/as_string.py b/astroid/as_string.py +index 3d669c4..8eaebc1 100644 +--- a/astroid/as_string.py ++++ b/astroid/as_string.py +@@ -481,6 +481,19 @@ def visit_asyncwith(self, node): + def visit_asyncfor(self, node): + return 'async %s' % self.visit_for(node) + ++ def visit_joinedstr(self, node): ++ # Special treatment for constants, ++ # as we want to join literals not reprs ++ string = ''.join( ++ value.value if type(value).__name__ == 'Const' ++ else value.accept(self) ++ for value in node.values ++ ) ++ return "f'%s'" % string ++ ++ def visit_formattedvalue(self, node): ++ return '{%s}' % node.value.accept(self) ++ + + def _import_string(names): + """return a list of (name, asname) formatted as a string""" +@@ -490,7 +503,7 @@ def _import_string(names): + _names.append('%s as %s' % (name, asname)) + else: + _names.append(name) +- return ', '.join(_names) ++ return ', '.join(_names) + + + if sys.version_info >= (3, 0): +diff --git a/astroid/node_classes.py b/astroid/node_classes.py +index 42fdf7c..9873158 100644 +--- a/astroid/node_classes.py ++++ b/astroid/node_classes.py +@@ -1863,6 +1863,28 @@ class DictUnpack(NodeNG): + """Represents the unpacking of dicts into dicts using PEP 448.""" + + ++class FormattedValue(bases.NodeNG): ++ """Represents a PEP 498 format string.""" ++ _astroid_fields = ('value', 'format_spec') ++ value = None ++ conversion = None ++ format_spec = None ++ ++ def postinit(self, value, conversion=None, format_spec=None): ++ self.value = value ++ self.conversion = conversion ++ self.format_spec = format_spec ++ ++ ++class JoinedStr(bases.NodeNG): ++ """Represents a list of string expressions to be joined.""" ++ _astroid_fields = ('values',) ++ value = None ++ ++ def postinit(self, values=None): ++ self.values = values ++ ++ + # constants ############################################################## + + CONST_CLS = { +diff --git a/astroid/nodes.py b/astroid/nodes.py +index 1c279cc..3397294 100644 +--- a/astroid/nodes.py ++++ b/astroid/nodes.py +@@ -37,6 +37,7 @@ + TryExcept, TryFinally, Tuple, UnaryOp, While, With, Yield, YieldFrom, + const_factory, + AsyncFor, Await, AsyncWith, ++ FormattedValue, JoinedStr, + # Backwards-compatibility aliases + Backquote, Discard, AssName, AssAttr, Getattr, CallFunc, From, + # Node not present in the builtin ast module. +@@ -75,4 +76,5 @@ + UnaryOp, + While, With, + Yield, YieldFrom, ++ FormattedValue, JoinedStr, + ) +diff --git a/astroid/rebuilder.py b/astroid/rebuilder.py +index d80033f..91774cf 100644 +--- a/astroid/rebuilder.py ++++ b/astroid/rebuilder.py +@@ -984,6 +984,24 @@ def visit_await(self, node, parent): + return self._visit_with(new.AsyncWith, node, parent, + assign_ctx=assign_ctx) + ++ def visit_joinedstr(self, node, parent, assign_ctx=None): ++ newnode = new.JoinedStr() ++ newnode.lineno = node.lineno ++ newnode.col_offset = node.col_offset ++ newnode.parent = parent ++ newnode.postinit([self.visit(child, newnode) ++ for child in node.values]) ++ return newnode ++ ++ def visit_formattedvalue(self, node, parent, assign_ctx=None): ++ newnode = new.FormattedValue() ++ newnode.lineno = node.lineno ++ newnode.col_offset = node.col_offset ++ newnode.parent = parent ++ newnode.postinit(self.visit(node.value, newnode), ++ node.conversion, ++ _visit_or_none(node, 'format_spec', self, newnode, assign_ctx=assign_ctx)) ++ return newnode + + if sys.version_info >= (3, 0): + TreeRebuilder = TreeRebuilder3k +diff --git a/astroid/tests/unittest_python3.py b/astroid/tests/unittest_python3.py +index ad8e57b..e555bb4 100644 +--- a/astroid/tests/unittest_python3.py ++++ b/astroid/tests/unittest_python3.py +@@ -87,7 +87,7 @@ def test_metaclass_error(self): + @require_version('3.0') + def test_metaclass_imported(self): + astroid = self.builder.string_build(dedent(""" +- from abc import ABCMeta ++ from abc import ABCMeta + class Test(metaclass=ABCMeta): pass""")) + klass = astroid.body[1] + +@@ -98,7 +98,7 @@ class Test(metaclass=ABCMeta): pass""")) + @require_version('3.0') + def test_as_string(self): + body = dedent(""" +- from abc import ABCMeta ++ from abc import ABCMeta + class Test(metaclass=ABCMeta): pass""") + astroid = self.builder.string_build(body) + klass = astroid.body[1] +@@ -239,6 +239,13 @@ def test_unpacking_in_dict_getitem(self): + self.assertIsInstance(value, nodes.Const) + self.assertEqual(value.value, expected) + ++ @require_version('3.6') ++ def test_format_string(self): ++ code = "f'{greetings} {person}'" ++ node = extract_node(code) ++ self.assertEqual(node.as_string(), code) ++ ++ + + if __name__ == '__main__': + unittest.main() diff --git a/python-astroid.spec b/python-astroid.spec index fb9d8c0..fad4b9b 100644 --- a/python-astroid.spec +++ b/python-astroid.spec @@ -1,96 +1,137 @@ +%global github_owner PyCQA +%global github_name astroid +%global github_commit 890d8baf1fa8d3456cb9bf0db4a76229f7a29773 + +%global sum Common base representation of python source code for pylint and other projects +%global desc The aim of this module is to provide a common base representation of python \ +source code for projects such as pychecker, pyreverse, pylint... \ +It provides a compatible representation which comes from the _ast module. It \ +rebuilds the tree generated by the builtin _ast module by recursively walking \ +down the AST and building an extended ast. The new node classes have additional \ +methods and attributes for different usages. They include some support for \ +static inference and local name scopes. Furthermore, astroid builds partial \ +trees by inspecting living objects. + +# Enable Python 3 builds for Fedora + EPEL >6 +%if 0%{?fedora} || 0%{?rhel} >= 6 +# If the definition isn't available for python3_pkgversion, define it +%{?!python3_pkgversion:%global python3_pkgversion 3} +%bcond_without python3 +%else +%bcond_with python3 +%endif + +# Requirements for tests (BuildRequires) and run (Requires) +# EPEL builds do not provide python2-* +%global t_requires python-six python-wrapt python-lazy-object-proxy python-singledispatch +%global t3_requires python%{python3_pkgversion}-six python%{python3_pkgversion}-wrapt python%{python3_pkgversion}-lazy-object-proxy +# singledispatch comes from functools on py3 + %if 0%{?fedora} > 12 %global with_python3 1 %else -%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")} +%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")} %endif Name: python-astroid -Version: 1.4.8 +Version: 1.4.9 Release: 1%{?dist} -Summary: Python Abstract Syntax Tree New Generation +Summary: %{sum} Group: Development/Languages License: GPLv2+ -URL: http://www.astroid.org -Source0: https://github.com/PyCQA/astroid/archive/astroid-%{version}.tar.gz +URL: https://github.com/%{github_owner}/%{github_name} +Source0: https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}/%{github_name}-%{version}.tar.gz Patch0001: 0001-Ignore-PyGIWarning.patch +# Fix for Python 3.6 compatibility. This is: +# https://patch-diff.githubusercontent.com/raw/PyCQA/astroid/pull/365.patch +# re-based on 1.4.9. +Patch0002: 365-rebased.patch +# Re-diffed backport of 1b34d34e87a014d1ad96263169b25ecf34e900cb +#Patch0003: test.patch -Provides: python-astroid = %{version}-%{release} Obsoletes: python-logilab-astng <= 0.24.1 -Requires: python-six -Requires: python-wrapt -Requires: python-lazy-object-proxy BuildArch: noarch -BuildRequires: python-devel python-setuptools python-tools -BuildRequires: python-six -BuildRequires: python-wrapt -BuildRequires: python-lazy-object-proxy +BuildRequires: python2-devel +BuildRequires: python-setuptools +BuildRequires: python-tools +BuildRequires: python-nose +BuildRequires: python-enum34 +BuildRequires: %{t_requires} BuildRequires: git %description -The aim of this module is to provide a common base representation of -python source code for projects such as pychecker, pyreverse, -pylint, and others. It extends the class defined in the compiler.ast -python module with some additional methods and attributes. +%{desc} + + +%package -n python2-%{github_name} +Summary: %{sum} +Requires: %{t_requires} +%{?python_provide:%python_provide python2-%{github_name}} + +%description -n python2-%{github_name} +%{desc} + +This package provides the Python 2 implementation. + %if 0%{?with_python3} -%package -n python3-astroid -Summary: Python Abstract Syntax Tree New Generation +%package -n python%{python3_pkgversion}-astroid +Summary: %{sum} Group: Development/Languages -Requires: python3-six -Requires: python3-wrapt -Requires: python3-lazy-object-proxy -BuildRequires: python3-devel python3-setuptools python3-tools -BuildRequires: python3-six -BuildRequires: python3-wrapt -BuildRequires: python3-lazy-object-proxy +Requires: %{t3_requires} +BuildRequires: python%{python3_pkgversion}-devel +BuildRequires: python%{python3_pkgversion}-setuptools +BuildRequires: python%{python3_pkgversion}-tools +BuildRequires: python%{python3_pkgversion}-nose +BuildRequires: %{t3_requires} BuildRequires: git -%description -n python3-astroid -The aim of this module is to provide a common base representation of -python source code for projects such as pychecker, pyreverse, -pylint, and others. It extends the class defined in the compiler.ast -python module with some additional methods and attributes. +%description -n python%{python3_pkgversion}-astroid +%{desc} + +This package provides the Python 2 implementation. %endif # if with_python3 + %prep -%setup -q -n astroid-astroid-%{version} -%patch0001 -p1 +%autosetup -n %{github_name}-%{github_commit} -p1 -%if 0%{?with_python3} -rm -rf %{py3dir} -cp -a . %{py3dir} -%endif # with_python3 %build -%{__python} setup.py build +%py2_build -%if 0%{?with_python3} -pushd %{py3dir} -%{__python3} setup.py build -popd +%if %{with python3} +%py3_build %endif # with_python3 + %install %if 0%{?with_python3} -pushd %{py3dir} -%{__python3} setup.py install -O1 --skip-build --root %{buildroot} +%py3_install rm -rf %{buildroot}%{python3_sitelib}/astroid/tests -popd %endif # with_python3 -%{__python} setup.py install -O1 --skip-build --root %{buildroot} -rm -rf %{buildroot}%{python_sitelib}/astroid/tests +%py2_install +rm -rf %{buildroot}%{python2_sitelib}/astroid/tests + + +%check +PYTHONPATH=./ %{__python2} -m unittest discover -p "unittest*.py" +%if 0%{?with_python3} +PYTHONPATH=./ %{__python3} -m unittest discover -p "unittest*.py" +%endif # with_python3 + -%files +%files -n python2-%{github_name} %doc README.rst %license COPYING -%{python_sitelib}/astroid -%{python_sitelib}/astroid*.egg-info +%{python2_sitelib}/astroid +%{python2_sitelib}/astroid*.egg-info %if 0%{?with_python3} -%files -n python3-astroid +%files -n python%{python3_pkgversion}-astroid %doc README.rst %license COPYING %{python3_sitelib}/astroid @@ -98,6 +139,13 @@ rm -rf %{buildroot}%{python_sitelib}/astroid/tests %endif # with_python3 %changelog +* Wed Dec 21 2016 Adam Williamson - 1.4.9-1 +- New release 1.4.9 +- Backport a patch from master branch to fix Python 3.6 compatibility +- Modernize spec file somewhat +- Rename python2 package +- Enable tests + * Wed Dec 14 2016 Charalampos Stratakis - 1.4.8-1 - Upstream 1.4.8 diff --git a/sources b/sources index 50dfd08..cb33c11 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (astroid-1.4.8.tar.gz) = 25265f22c6f2e6ac52b6d0973dcab3fc7fd336bf95d6657569f7a1d1be0ac18f17b762eaa0be4a2b092a15efe74b9e45eee7216f1d243382fa2fa84fcf9bfa59 +SHA512 (astroid-1.4.9.tar.gz) = ce4f0613d543f980c17ca7039b26c8e2d30ec1f21a853d888c9fae6bce6b20a4ece24fa22f084bdb25b548daaf5f6e351e8842fe0c254ba40bbbee9c21c656a2