[ANN] first release of pyast

I have the pleasure to announce the first release of pyast, a library provides versioned abstract syntax tree for all Python versions from Python 2.5 to Python 3.10.

Available on opam: opam install pyast

The purpose of this library is very close to pyre-ast, namely being able to give access from OCaml programs to the Python own parser and to the ASTs it builds. There are two main differences:

  • pyre-ast exposes the AST of Python 3.10 whereas pyast exposes the ASTs of all Python versions from Python 2.5 to Python 3.10 (in versioned modules à la ocaml-migrate-parsetree), providing converters between them. The AST of the latest version of Python (currently, 3.10) is provided in Pyast.Latest.

  • pyre-ast embeds its own version of the Python interpreter, whereas pyast uses the Python interpreter available on the machine (via pyml), converting the AST to the expected version if necessary.

The development of pyast was motivated when some handwritten code using pyml to access the Python parser broke after a Python upgrade because of a change in the AST!