Back to Ast Grep

ast-grep python binding

crates/pyo3/README.md

0.42.11.5 KB
Original Source

ast-grep python binding

<p align=center> </p>

ast-grep

ast-grep is a tool for code structural search, lint, and rewriting.

This crate intends to build a native python binding of ast-grep and provide a python API for programmatic usage.

Installation

bash
pip install ast-grep-py

Usage

You can take our tests as examples. For example, test_simple.py shows how to use ast-grep to search for a pattern in a file.

Please see the API usage guide and API reference for more details.

Other resources include ast-grep's official site and repository.

Development

Setup virtualenv

shell
python -m venv venv

Activate venv

shell
source venv/bin/activate

Install maturin

shell
pip install maturin[patchelf]

MacOS: Install patchelf and maturin

shell
brew install patchelf
pip install maturin

Build bindings

shell
maturin develop

Run tests

shell
pytest

All tests files are under tests directory.

License

This project is licensed under the MIT license.