Metadata-Version: 2.4
Name: litexpy
Version: 0.0.7
Summary: Python runner for an interactive litex terminal session.
Project-URL: Homepage, https://github.com/litexlang/litexpy
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.4
Description-Content-Type: text/markdown
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: project-url
Dynamic: requires-python
Dynamic: summary

# litexpy

Python runner for an interactive `litex` terminal session.

## Links

- PyPI: https://pypi.org/project/litexpy/
- GitHub: https://github.com/litexlang/litexpy

## Prerequisites

`litexpy` starts the local `litex` command in an interactive terminal session.
It does not bundle the Litex executable, so install Litex first if `litex` is
not already available in your terminal.

### If you already have Litex

If `litex -version` works in your terminal, install only the Python package:

```bash
pip install litexpy
```

### If you have not installed Litex

Install Litex first locally on your machine, then install `litexpy`.

Setup guide: https://litexlang.com/doc/Setup

## Usage

Create a runner:

```python
import litexpy

runner = litexpy.Runner()
```

Run Litex code and read the JSON results:

```python
results = runner.run("1 = 1")

print(results[0]["result"])
print(results[0]["stmt"])
```

Run multiple input lines in the same interactive Litex session:

```python
results = runner.run("1 = 1\n0 = 0")
```

Clear the Litex session:

```python
clear_result = runner.clear()
```

Close the Litex process:

```python
runner.quit()
```

`Runner()` starts the `litex` command from your `PATH` in an interactive
terminal process. `run(script)` sends script to that process and returns the
JSON results as a list of Python `dict` objects. `clear()` is equivalent to
`run("clear")`. `quit()` closes the running `litex` process.
