Skip to main content

PyTCL allows control EDA tools directly from Python that use TCL

Project description

PyTCL

PyTCL allows control EDA tools directly from Python that use TCL.

Features

  • It executes Python method with provided positional arguments directly as TCL procedure For example invocation of Python <object>.<name>(*args) method is like calling TCL procedure <name> {*}${args}
  • Any Python value is converted to TCL value like for example Python list to TCL list
  • Result from invoked TCL procedure is returned as pytcl.TCLValue that can handle any TCL value (that is represented always as string) to Python str, int, bool, float, list, dict, ...
  • TCL error is returned as Python exception pytcl.TCLError
  • High performance and very low (unnoticeable) overhead by using Unix domain sockets for communication between Python and TCL in streamable way (sockets are always open and ready)
  • No external dependencies

Install

pip install pytcl-eda

Examples

Creating new Vivado project:

from pathlib import Path
from pytcl import Vivado

def main() -> None:
    """Create new Vivado project."""
    project_dir: Path = Path.cwd() / "my-awesome-project"

    with Vivado() as vivado:
        vivado.create_project(project_dir.name, project_dir)
        vivado.close_project()

if __name__ == "__main__":
    main()

Architecture

  • PyTCL will start new receiver listened on Unix domain socket /tmp/pytcl-XXXX/tx.sock for any incoming NDJSON messages {"result": "<tcl-result>", "status": <tcl-status>} from execute.tcl script file
  • PyTCL will call command line tool (by default tclsh) with execute.tcl script file and arguments receiver.py /tmp/pytcl-XXXX/rx.sock sender.py /tmp/pytcl-XXXX/tx.sock
  • Started execute.tcl will create own listener with Unix domain socket /tmp/pytcl-XXXX/rx.sock to receive incoming TCL expressions from PyTCL
  • PyTCL will start new client and connect to Unix domain socket /tmp/pytcl-XXXX/rx.sock to send TCL expressions with arguments to be evaluated by execute.tcl script file
  • PyTCL will transform any Python method call <object>.<name>(*args) to TCL expression <name> {*}${args}
  • PyTCL will send TCL expression to execute.tcl using Unix domain socket /tmp/pytcl-XXXX/rx.sock
  • execute.tcl will receive TCL expressions from Unix domain socket /tmp/pytcl-XXXX/rx.sock
  • Received TCL expression is evaluated by TCL eval within TCL catch
  • TCL result and status from evaluated TCL expression will be packed into NDJSON message {"result": "<tcl-result>", "status": <tcl-status>}
  • Packed NDJSON message with TCL result and status will be send back to PyTCL
  • PyTCL will return received NDJSON message as pytcl.TCLValue
  • PyTCL will raise a Python exception pytcl.TCLError if received TCL status was non-zero

Development

Create Python virtual environment:

python3 -m venv .venv

Activate created Python virtual environment:

. .venv/bin/activate

Upgrade pip:

pip install --upgrade pip

Install project in editable mode with pytest:

pip install --editable .[test]

Run tests:

pytest

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

pytcl_eda-0.1.2.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

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

pytcl_eda-0.1.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file pytcl_eda-0.1.2.tar.gz.

File metadata

  • Download URL: pytcl_eda-0.1.2.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for pytcl_eda-0.1.2.tar.gz
Algorithm Hash digest
SHA256 03a1f034d41c6cadd94c255ad3ed2aff88a406ed17844e975cd663e8830a3325
MD5 d7f57ad719487ffc688bdeb75f03bdd1
BLAKE2b-256 190b8cd64bbb2de4c112b1d51f1c046dd5d69568233dd4d768666dbe0e92757b

See more details on using hashes here.

File details

Details for the file pytcl_eda-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pytcl_eda-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for pytcl_eda-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3d67600d7c841dbf1bdb94227f9804f53e0bf3e65b05a40cbe0ac57721cf6cf0
MD5 bf85f3ef02d5d469d3eb385a420f7b6b
BLAKE2b-256 442318247fd25a00dcdf1a75656fb393a0c07b7787dfce831c69ac76f3e50393

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