Skip to main content

Python runner for an interactive litex terminal session.

Project description

litexpy

Python runner for an interactive litex terminal session.

Links

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.

Full setup guide:

If you already have Litex

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

pip install litexpy

If you have not installed Litex

Install Litex first, then install litexpy.

macOS:

brew install litexlang/tap/litex
pip install litexpy
litex -version

Linux (Ubuntu/Debian, amd64):

tag=$(curl -fsSL https://api.github.com/repos/litexlang/golitex/releases/latest | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
wget "https://github.com/litexlang/golitex/releases/download/${tag}/litex_${tag}_amd64.deb"
sudo dpkg -i "litex_${tag}_amd64.deb"
pip install litexpy
litex -version

Windows PowerShell:

$ErrorActionPreference = 'Stop'
$repo = 'litexlang/golitex'
$tag = (Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/releases/latest" -Headers @{ 'User-Agent' = 'litex-install' }).tag_name
$name = "litex_${tag}_windows_amd64.exe"
$url = "https://github.com/$repo/releases/download/$tag/$name"
$dir = Join-Path $env:LOCALAPPDATA 'litex'
$exe = Join-Path $dir 'litex.exe'
New-Item -ItemType Directory -Force -Path $dir | Out-Null
Invoke-WebRequest -Uri $url -OutFile $exe
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
if (-not $userPath) { $userPath = '' }
if ($userPath -notlike "*$dir*") {
    $newPath = if ($userPath) { "$userPath;$dir" } else { $dir }
    [Environment]::SetEnvironmentVariable('Path', $newPath, 'User')
}
$env:Path = "$dir;$env:Path"
pip install litexpy
litex -version

Usage

import litexpy

runner = litexpy.Runner()

results = runner.run("1 = 1\n0 = 0")
clear_result = runner.clear()
runner.quit()

litexpy.Runner() starts the litex command 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"), and quit() closes the running litex process.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

litexpy-0.0.5.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

litexpy-0.0.5-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file litexpy-0.0.5.tar.gz.

File metadata

  • Download URL: litexpy-0.0.5.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for litexpy-0.0.5.tar.gz
Algorithm Hash digest
SHA256 414632380751ec70393a07898936534f223ca49e9a7552a5076c763cac301637
MD5 4dd767e469af35dfdb6eaf80352c51fb
BLAKE2b-256 746994e845efec26276b81c4d15c7925f5e039159b71b37362f52da797e3cf88

See more details on using hashes here.

File details

Details for the file litexpy-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: litexpy-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for litexpy-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d380c439f31e7402f659230b6d5ea527ae48e88b65315f9d9a9d873e1f26fbed
MD5 3e3215e5b68a0d7dc0bf286bfe7814ca
BLAKE2b-256 040f39a4bf0f78a1c3b616b20b1a5e41f7d475722612d3a8cb65950ce094b678

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page