Crates.io | depyler |
lib.rs | depyler |
version | 3.1.0 |
created_at | 2025-07-07 12:40:29.249089+00 |
updated_at | 2025-08-21 16:21:45.271594+00 |
description | A Python-to-Rust transpiler focusing on energy-efficient, safe code generation with progressive verification |
homepage | https://github.com/paiml/depyler |
repository | https://github.com/paiml/depyler |
max_upload_size | |
id | 1741174 |
size | 279,020 |
Energy-efficient Python-to-Rust transpiler with progressive verification capabilities. Transform Python code into safe, performant Rust while reducing energy consumption by 75-85%. Built with zero tolerance for technical debt and extreme quality standards following the Toyota Way.
Enterprise Testing Excellence: v2.2.2 delivers enterprise-grade testing infrastructure with 350+ tests across property-based, mutation, fuzzing, and coverage testing frameworks. Features comprehensive CI/CD integration, automated quality gates, and cross-platform testing matrix. Maintains zero defects policy with formal verification readiness and ownership inference. Line coverage: 70% | Function coverage: 74%
Install depyler
using one of the following methods:
From Crates.io (Recommended):
cargo install depyler
From Source:
git clone https://github.com/paiml/depyler
cd depyler
cargo build --release
cargo install --path crates/depyler
From GitHub Releases: Pre-built binaries are available on the releases page.
# Transpile a Python file to Rust (default)
depyler transpile example.py
# Transpile to Ruchy script format (v3.0.0+)
depyler transpile example.py --target=ruchy
# Transpile with verification
depyler transpile example.py --verify
# Analyze code complexity before transpilation
depyler analyze example.py
# Interactive mode with AI suggestions
depyler interactive example.py --suggest
# Check transpilation compatibility
depyler check example.py
# Inspect AST/HIR representations
depyler inspect example.py --repr hir
# Start Language Server for IDE integration
depyler lsp
# Profile Python code for performance analysis
depyler profile example.py --flamegraph
# Generate documentation from Python code
depyler docs example.py --output ./docs
Add to your Cargo.toml
:
[dependencies]
depyler = "3.0.0"
Basic usage:
use depyler::{transpile_file, TranspileOptions};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let options = TranspileOptions::default()
.with_verification(true)
.with_optimization_level(2);
let rust_code = transpile_file("example.py", options)?;
println!("{}", rust_code);
Ok(())
}
Depyler now supports transpiling Python to Ruchy script format, a functional programming language with pipeline operators and actor-based concurrency:
# Transpile to Ruchy format
depyler transpile example.py --target=ruchy
# Output will have .ruchy extension
depyler transpile example.py --target=ruchy -o example.ruchy
Ruchy Features:
|>
)Example Transformation:
# Python
result = [x * 2 for x in range(10) if x > 5]
# Ruchy
result = range(10) |> filter(x => x > 5) |> map(x => x * 2)
panic=abort
int
, float
, str
, bool
)List
, Dict
, Tuple
, Set
, FrozenSet
)if
, while
, for
, break
, continue
)Result<T, E>
eval
, exec
)# Basic transpilation
depyler transpile input.py # Creates input.rs
depyler transpile input.py -o output.rs # Custom output
depyler transpile src/ -o rust/ # Directory mode
# Analysis and verification
depyler check input.py # Compatibility check
depyler analyze input.py # Complexity metrics
depyler verify output.rs # Verify generated code
depyler inspect input.py --repr ast # View AST/HIR
# Interactive features
depyler interactive input.py # Interactive session
depyler interactive input.py --suggest # With AI suggestions
# Quality enforcement
depyler transpile input.py --verify # With verification
depyler quality-check input.py # Toyota Way scoring
# Developer tools
depyler lsp # Start Language Server
depyler debug --tips # Debugging guide
depyler profile input.py # Performance profiling
depyler docs input.py # Generate documentation
# Add to Claude Code
claude mcp add depyler ~/.local/bin/depyler
# Start MCP server
depyler serve --mcp
# Available MCP tools:
# - transpile_python: Convert Python to Rust
# - analyze_complexity: Code complexity analysis
# - verify_transpilation: Verify semantic equivalence
# - suggest_annotations: Optimization hints
# Start HTTP server
depyler serve --port 8080 --cors
# API endpoints
curl "http://localhost:8080/health"
curl "http://localhost:8080/api/v1/transpile" \
-H "Content-Type: application/json" \
-d '{"code":"def add(a: int, b: int) -> int: return a + b"}'
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Python AST โโโโโโถโ HIR โโโโโโถโ Rust AST โ
โ (rustpython) โ โ (Intermediate) โ โ (syn) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Type Inference โ โ Optimizations โ โ Code Generation โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
name: Transpile and Verify
on: [push, pull_request]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: Install depyler
run: cargo install depyler
- name: Check Python compatibility
run: depyler check src/**/*.py
- name: Transpile to Rust
run: depyler transpile src/ -o rust/ --verify
- name: Run quality checks
run: depyler quality-check src/**/*.py --strict
This project exemplifies the Toyota Way philosophy through disciplined quality practices:
# Run all tests
cargo test --workspace
# Run with coverage
cargo tarpaulin --out Html
# Run property tests
cargo test --features quickcheck
# Run benchmarks
cargo bench
# Run specific test suites
cargo test -p depyler-core # Core transpilation
cargo test -p depyler-verify # Verification
cargo test -p depyler-mcp # MCP integration
pmat_quality_check
tool for validating Rust code qualityWe welcome contributions! Please follow our quality standards:
cargo clippy -- -D warnings
cargo fmt
See CONTRIBUTING.md for detailed guidelines.
See ROADMAP.md for detailed plans.
Licensed under either of:
at your option.
Built with extreme quality standards by the Depyler team