Typed Python builders for EDA scripts and command files
Project description
RosettaKit
RosettaKit is a small Python library for building typed EDA script documents and rendering them into tool-facing text such as Tcl fragments and command files.
API Stability
RosettaKit 0.2.0 treats the public node, value, document, and builder APIs as stable:
rosettakit.tcl:Script,TclBuilder,Scalar,PathValue,ListValue,VarRef,Expr,CommandSubstitution,Raw,Condition,Comment,BlankLine,Set,Command,If,RawLine, and helper functions such asword,path,list_value,var,expr,call,raw, andfile_isdirectory.rosettakit.cmdfile:CommandFile,CommandFileBuilder,ValueType,ValueQuoting,CommandFileDialect,TCL_WORD_DIALECT,PLAIN_DIALECT,Comment,BlankLine,Flag,Option, andRawLine.rosettakit.diagnostics.Diagnosticand the exception hierarchy inrosettakit.errors.
Generated text is part of the compatibility surface. Patch releases should not change quoting, indentation, line ordering, or default raw-content policy unless the current output is unsafe or invalid.
RosettaKit only builds script text. It does not parse Tcl, execute EDA tools, manage subprocesses, or model a host workflow.
Tcl API
from rosettakit import tcl
script = tcl.Script()
script.comment("Auto-generated by RosettaKit")
script.set("top_design", tcl.word("gcd_core"))
script.set("clk_freq_mhz", 500)
script.set_path("final_netlist_file", "build out/gcd final.v")
script.set_list("lib_list", ["libs/fast corner.lib", "libs/slow.lib"])
script.set_expr("clk_period_ps", "1000000.0 / $clk_freq_mhz")
script.set_path("tmp_dir", "build out/tmp")
script.file_mkdir(tcl.var("tmp_dir"))
text = script.build()
Use script.validate() to inspect diagnostics before building. Raw Tcl is an
explicit escape hatch through tcl.raw(...) or script.raw_line(...); builds
fail on raw content unless allow_unsafe_raw=True is passed.
Command File API
from rosettakit import cmdfile
cmd = cmdfile.CommandFile(prefix="-")
cmd.flag("useOpenSTA")
cmd.option("top", "gcd_core")
cmd.option("def", "build out/input.def", value_type=cmdfile.ValueType.PATH)
cmd.options("lef", ["tech/sky130.lef", "macro lef/sram.lef"], value_type=cmdfile.ValueType.PATH)
text = cmd.build()
Command files preserve insertion order, support flags, single options,
repeated options, optional omission of empty values, and path-aware quoting.
PLAIN_DIALECT emits unquoted whitespace-delimited option values and rejects
values that cannot be represented safely in that form.
Examples
The first-party examples use only RosettaKit and Python standard-library modules:
uv run python examples/yosys_global_var.py
uv run python examples/sizer_cmd_file.py
uv run python examples/sizer_env_file.py
They write generated output under ignored paths:
examples/out/yosys/global_var.tcl
examples/out/sizer/design.cmd_file
examples/out/sizer/design.env_file
To verify the generated Tcl with a local Tcl shell:
uv run python examples/yosys_global_var.py
tclsh examples/out/yosys/global_var.tcl
Development
uv sync
uv run pytest
uv run ruff check
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rosettakit-0.2.0.tar.gz.
File metadata
- Download URL: rosettakit-0.2.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"26.11","id":"zokor","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1dc16cc89ff9c145828bc0e7609846a197081e829b4560b41ee47d01cad181c6
|
|
| MD5 |
0bd76c13de65cfc96e04509177c8cb35
|
|
| BLAKE2b-256 |
24fe2c917fa388180165d8553d48dbc53fe43985f7f6aef73307cd172a114db3
|
File details
Details for the file rosettakit-0.2.0-py3-none-any.whl.
File metadata
- Download URL: rosettakit-0.2.0-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"26.11","id":"zokor","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b91438a445a1d14f5e70442b4152ea4fd398641a0b62955fc0f156ce7771b1de
|
|
| MD5 |
cc36eb9e3011a7e4079cf919f5c43f0b
|
|
| BLAKE2b-256 |
73e1716c06dc81db6065db98325fbba92631198de9c288ad57d50231cee6277f
|