Debian Codegraph @

pypy/module/_hpy_universal/tools/autogen.py

raw symbols SCIP
1 import sys
2 import py
3 if sys.version_info[0] < 3:
4 print('ERROR: autogen.py should be run on top of Python 3.x')
5 sys.exit(1)
6 if len(sys.argv) != 2:
7 print('USAGE: autogen.py /path/to/hpy_repo')
8 sys.exit(1)
9
10 HPY_PATH = sys.argv[1]
11 sys.path.insert(0, HPY_PATH)
12
13 from hpy.tools.autogen.parse import HPyAPI, PUBLIC_API_H, toC
14 from hpy.tools.autogen.autogenfile import AutoGenFile
15
16 # NOTE: autogen_interp_slots.py is no longer used. We keep the code around
17 # because it's useful as an example for when we will need to autogen other
18 # files
19 class autogen_example_py(AutoGenFile):
20 PATH = 'autogen_example.py'
21 LANGUAGE = 'Python'
22 DISCLAIMER = '## DO NOT EDIT THIS FILE, IT IS AUTOGENERATED'
23
24 def generate(self):
25 lines = []
26 w = lines.append
27 #
28 w(f'# example file')
29 return '\n'.join(lines)
30
31
32 def main():
33 OUTDIR = py.path.local(__file__).dirpath('..')
34 api = HPyAPI.parse(PUBLIC_API_H)
35 for cls in (autogen_example_py,):
36 cls(api).write(OUTDIR)
37
38
39
40 if __name__ == '__main__':
41 main()