pythran: fix required gast version
This commit is contained in:
parent
d87a3ef08e
commit
be3128d221
|
@ -0,0 +1,76 @@
|
|||
From 840a0e706ec39963aec6bcd1f118bf33177c20b4 Mon Sep 17 00:00:00 2001
|
||||
From: serge-sans-paille <serge.guelton@telecom-bretagne.eu>
|
||||
Date: Sat, 29 Jun 2024 19:13:02 +0200
|
||||
Subject: [PATCH] Bump gast requirement to 0.6.0
|
||||
|
||||
This mostly helps for harmonious behavior wrt. gast.dump
|
||||
---
|
||||
docs/TUTORIAL.rst | 8 ++++----
|
||||
pythran/utils.py | 2 +-
|
||||
requirements.txt | 2 +-
|
||||
3 files changed, 6 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/docs/TUTORIAL.rst b/docs/TUTORIAL.rst
|
||||
index 09f6902f9..7692547eb 100644
|
||||
--- a/docs/TUTORIAL.rst
|
||||
+++ b/docs/TUTORIAL.rst
|
||||
@@ -20,7 +20,7 @@ Python ships a standard module, ``ast`` to turn Python code into an AST. For ins
|
||||
>>> code = "a=1"
|
||||
>>> tree = ast.parse(code) # turn the code into an AST
|
||||
>>> print(ast.dump(tree)) # view it as a string
|
||||
- Module(body=[Assign(targets=[Name(id='a', ctx=Store(), annotation=None, type_comment=None)], value=Constant(value=1, kind=None), type_comment=None)], type_ignores=[])
|
||||
+ Module(body=[Assign(targets=[Name(id='a', ctx=Store())], value=Constant(value=1, kind=None))])
|
||||
|
||||
Deciphering the above line, one learns that the single assignment is parsed as
|
||||
a module containing a single statement, which is an assignment to a single
|
||||
@@ -33,7 +33,7 @@ Eventually, one needs to parse more complex codes, and things get a bit more cry
|
||||
... return n if n< 2 else fib(n-1) + fib(n-2)"""
|
||||
>>> tree = ast.parse(fib_src)
|
||||
>>> print(ast.dump(tree))
|
||||
- Module(body=[FunctionDef(name='fib', args=arguments(args=[Name(id='n', ctx=Param(), annotation=None, type_comment=None)], posonlyargs=[], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[]), body=[Return(value=IfExp(test=Compare(left=Name(id='n', ctx=Load(), annotation=None, type_comment=None), ops=[Lt()], comparators=[Constant(value=2, kind=None)]), body=Name(id='n', ctx=Load(), annotation=None, type_comment=None), orelse=BinOp(left=Call(func=Name(id='fib', ctx=Load(), annotation=None, type_comment=None), args=[BinOp(left=Name(id='n', ctx=Load(), annotation=None, type_comment=None), op=Sub(), right=Constant(value=1, kind=None))], keywords=[]), op=Add(), right=Call(func=Name(id='fib', ctx=Load(), annotation=None, type_comment=None), args=[BinOp(left=Name(id='n', ctx=Load(), annotation=None, type_comment=None), op=Sub(), right=Constant(value=2, kind=None))], keywords=[]))))], decorator_list=[], returns=None, type_comment=None)], type_ignores=[])
|
||||
+ Module(body=[FunctionDef(name='fib', args=arguments(args=[Name(id='n', ctx=Param())]), body=[Return(value=IfExp(test=Compare(left=Name(id='n', ctx=Load()), ops=[Lt()], comparators=[Constant(value=2, kind=None)]), body=Name(id='n', ctx=Load()), orelse=BinOp(left=Call(func=Name(id='fib', ctx=Load()), args=[BinOp(left=Name(id='n', ctx=Load()), op=Sub(), right=Constant(value=1, kind=None))]), op=Add(), right=Call(func=Name(id='fib', ctx=Load()), args=[BinOp(left=Name(id='n', ctx=Load()), op=Sub(), right=Constant(value=2, kind=None))]))))])])
|
||||
|
||||
The idea remains the same. The whole Python syntax is described in
|
||||
http://docs.python.org/2/library/ast.html and is worth a glance, otherwise
|
||||
@@ -199,7 +199,7 @@ constant expressions. In the previous code, there is only two constant
|
||||
|
||||
>>> ce = pm.gather(analyses.ConstantExpressions, tree)
|
||||
>>> sorted(map(ast.dump, ce))
|
||||
- ["Attribute(value=Name(id='math', ctx=Load(), annotation=None, type_comment=None), attr='cos', ctx=Load())", 'Constant(value=3, kind=None)']
|
||||
+ ["Attribute(value=Name(id='math', ctx=Load()), attr='cos', ctx=Load())", 'Constant(value=3, kind=None)']
|
||||
|
||||
One of the most critical analyse of Pythran is the points-to analysis. There
|
||||
are two flavors of this analyse, one that computes an over-set of the aliased
|
||||
@@ -210,7 +210,7 @@ variable, and one that computes an under set. ``Aliases`` computes an over-set::
|
||||
>>> al = pm.gather(analyses.Aliases, tree)
|
||||
>>> returned = tree.body[-1].body[-1].value
|
||||
>>> print(ast.dump(returned))
|
||||
- Name(id='b', ctx=Load(), annotation=None, type_comment=None)
|
||||
+ Name(id='b', ctx=Load())
|
||||
>>> sorted(a.id for a in al[returned])
|
||||
['c', 'd']
|
||||
|
||||
diff --git a/pythran/utils.py b/pythran/utils.py
|
||||
index 2d7a67327..55a7e8ad6 100644
|
||||
--- a/pythran/utils.py
|
||||
+++ b/pythran/utils.py
|
||||
@@ -106,7 +106,7 @@ def get_variable(assignable):
|
||||
... slice=ast.Name('j', ast.Load(), None, None),
|
||||
... ctx=ast.Load())
|
||||
>>> ast.dump(get_variable(ref))
|
||||
- "Name(id='a', ctx=Load(), annotation=None, type_comment=None)"
|
||||
+ "Name(id='a', ctx=Load())"
|
||||
"""
|
||||
msg = "Only name and subscript can be assigned."
|
||||
assert isinstance(assignable, (ast.Name, ast.Subscript)), msg
|
||||
diff --git a/requirements.txt b/requirements.txt
|
||||
index fd6a738e5..c7a25c52a 100644
|
||||
--- a/requirements.txt
|
||||
+++ b/requirements.txt
|
||||
@@ -1,5 +1,5 @@
|
||||
ply>=3.4
|
||||
setuptools
|
||||
-gast~=0.5.0
|
||||
+gast~=0.6.0
|
||||
numpy
|
||||
beniget~=0.4.0
|
|
@ -1,7 +1,7 @@
|
|||
# Template file for 'pythran'
|
||||
pkgname=pythran
|
||||
version=0.16.1
|
||||
revision=1
|
||||
revision=2
|
||||
build_style=python3-pep517
|
||||
hostmakedepends="python3-setuptools python3-wheel"
|
||||
depends="python3-ply python3-gast python3-beniget python3-numpy
|
||||
|
|
Loading…
Reference in New Issue