Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Transpilers

Batuta orchestrates three transpilers, each targeting a specific source language. All three are standalone Rust binaries installed via cargo install and discovered through PATH at runtime.

The Three Transpilers

TranspilerDirectionInputOutput
DepylerPython to Rust.py files and projectsIdiomatic Rust with trueno/aprender
DecyC/C++ to Rust.c, .cpp, .h filesSafe Rust with ownership inference
BashrsRust to ShellRust source with bashrs macrosPortable POSIX shell scripts

Note that Bashrs operates in the reverse direction: it takes Rust as input and produces shell scripts. This solves the bootstrap problem where installers need to run on systems that do not yet have Rust installed.

Automatic Detection

Batuta detects transpilers via PATH lookup at pipeline startup:

$ batuta transpile --input ./my_project
Detecting tools...
  Depyler 3.20.0    /home/user/.cargo/bin/depyler
  Decy 2.1.0        /home/user/.cargo/bin/decy
  Bashrs 6.41.0     /home/user/.cargo/bin/bashrs

If the required transpiler is missing, Batuta halts with installation instructions rather than silently skipping files.

Common Transpilation Patterns

Single File

# Python file
batuta transpile --input script.py --output script.rs

# C file
batuta transpile --input parser.c --output parser.rs

Full Project

# Transpile entire Python project to a Cargo workspace
batuta transpile --input ./python_app --output ./rust_app --format project

Batuta delegates to the appropriate transpiler based on the file extension and detected language.

Mixed-Language Projects

For projects with multiple source languages, Batuta runs each transpiler on its respective files:

# Project contains .py, .c, and .sh files
batuta transpile --input ./mixed_project --output ./rust_project

# Internal dispatch:
#   *.py  -> depyler transpile
#   *.c   -> decy transpile
#   *.sh  -> (flagged for bashrs review)

Transpiler Invocation

Batuta calls each transpiler through run_tool(), which captures stdout/stderr and propagates errors. Failures are surfaced immediately (Jidoka), with the full tool stderr included in the error report.

Installation

# Install all three transpilers
cargo install depyler decy bashrs

# Verify
depyler --version
decy --version
bashrs --version

Next Steps


Navigate: Table of Contents