Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Depyler
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%
๐ Installation
Install depyler
using one of the following methods:
-
From Crates.io (Recommended):
-
From Source:
-
From GitHub Releases: Pre-built binaries are available on the releases page.
Requirements
- Rust: 1.83.0 or later
- Python: 3.8+ (for test validation)
๐ฏ New in v3.1.0: Background Agent Mode
Continuous transpilation with Claude Code integration! Depyler now includes a background agent that provides real-time Python-to-Rust transpilation through the Model Context Protocol (MCP).
# Start the agent for Claude Code
# Monitor a Python project
# Check agent status
See AGENT.md for complete agent documentation and Claude Code setup instructions.
๐ Getting Started
Quick Start
# Transpile a Python file to Rust (default)
# Transpile to Ruchy script format (v3.0.0+)
# Transpile with verification
# Analyze code complexity before transpilation
# Interactive mode with AI suggestions
# Check transpilation compatibility
# Inspect AST/HIR representations
# Start Language Server for IDE integration
# Profile Python code for performance analysis
# Generate documentation from Python code
Using as a Library
Add to your Cargo.toml
:
[]
= "3.0.0"
Basic usage:
use ;
๐ Multi-Target Support (v3.0.0+)
Ruchy Script Format
Depyler now supports transpiling Python to Ruchy script format, a functional programming language with pipeline operators and actor-based concurrency:
# Transpile to Ruchy format
# Output will have .ruchy extension
Ruchy Features:
- Pipeline Operators - List comprehensions โ functional pipelines (
|>
) - String Interpolation - f-strings โ native interpolation
- Pattern Matching - isinstance() โ match expressions
- Actor Concurrency - async/await โ actor-based model
- DataFrame Support - NumPy/Pandas โ native DataFrame API
Example Transformation:
# Python
=
# Ruchy
result = range(10) |> filter(x => x > 5) |> map(x => x * 2)
Key Features
๐ Core Transpilation
- Python AST to HIR - High-level intermediate representation for safe transformations
- Type Inference - Smart type analysis with annotation support
- Memory Safety - Automatic ownership and borrowing inference
- Direct Rules Engine - Pattern-based Python-to-Rust transformations
- String Optimization - Interning for frequently used literals, Cow for flexible ownership
โก Performance & Efficiency
- Energy Reduction - 75-85% lower energy consumption vs Python
- Binary Optimization - Compile with LTO, strip, and
panic=abort
- Zero-Copy Strings - Smart string allocation strategies with Cow
- LLVM Backend - Leverages Rust's optimizing compiler
- String Interning - Automatic interning for strings used >3 times
๐ก๏ธ Safety & Verification
- Property-Based Testing - QuickCheck for semantic equivalence
- Memory Safety Analysis - Prevents use-after-free and data races
- Bounds Checking - Automatic insertion where needed
- Contract Verification - Pre/post condition checking
- Formal Verification Ready - Structured for future SMT integration
๐ค AI Integration
- Model Context Protocol - Full MCP v1.0 support
- Interactive Mode - AI-powered transpilation assistance
- Annotation Suggestions - Smart optimization hints
- Complexity Analysis - Migration difficulty assessment
๐ ๏ธ Developer Tools
- Language Server Protocol - VSCode, Neovim, and other IDE support
- Debugging Support - Source mapping and debugger integration
- Performance Profiling - Hot path detection and optimization
- Documentation Generation - Auto-generate API docs from Python
๐ฏ Supported Python Features
โ Production Ready
- Functions with type annotations
- Basic types (
int
,float
,str
,bool
) - Collections (
List
,Dict
,Tuple
,Set
,FrozenSet
) - Control flow (
if
,while
,for
,break
,continue
) - List, dict, and set comprehensions
- Exception handling โ
Result<T, E>
- Classes with methods, properties, dataclasses
- Static methods and class methods
- Basic async/await support
- Lambda functions
- Power operator (**) and floor division (//)
- String optimization (interning, Cow support)
- Protocol to Trait mapping
- Const generic array inference
- With statements (context managers)
- Iterator protocol (iter, next)
๐ง In Development
- Full async/await (async iterators, generators)
- Generator expressions with yield
- Advanced decorators
- Class inheritance
- Match/case statements (Python 3.10+)
- Package imports and relative imports
โ Not Supported
- Dynamic features (
eval
,exec
) - Runtime reflection
- Monkey patching
- Multiple inheritance
๐ Tool Usage
CLI Interface
# Basic transpilation
# Analysis and verification
# Interactive features
# Quality enforcement
# Developer tools
MCP Integration
Using with Claude Code
# Add to Claude Code
MCP Server Mode
# Start MCP server
# Available MCP tools:
# - transpile_python: Convert Python to Rust
# - analyze_complexity: Code complexity analysis
# - verify_transpilation: Verify semantic equivalence
# - suggest_annotations: Optimization hints
HTTP API
# Start HTTP server
# API endpoints
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Python AST โโโโโโถโ HIR โโโโโโถโ Rust AST โ
โ (rustpython) โ โ (Intermediate) โ โ (syn) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Type Inference โ โ Optimizations โ โ Code Generation โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
๐ฆ CI/CD Integration
GitHub Actions Example
name: Transpile and Verify
on:
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
Toyota Way Quality Standards
This project exemplifies the Toyota Way philosophy through disciplined quality practices:
่ชๅๅ (Jidoka) - Build Quality In
- ZERO SATD: No TODO, FIXME, HACK, or placeholder implementations
- ZERO Incomplete: All features fully implemented with unreachable!() removed
- ZERO High Complexity: No function exceeds cyclomatic complexity of 20
- 100% Verification: All generated code must compile and pass tests
็พๅฐ็พ็ฉ (Genchi Genbutsu) - Go and See
- Real-World Testing: Validated against actual Python codebases
- Performance Profiling: Energy consumption measured on real hardware
- Direct Debugging: Debug at the generated Rust level, not just HIR
ๆนๅ (Kaizen) - Continuous Improvement
- v1.0.1: Fixed all SATD markers and incomplete implementations
- v1.0.2: Enhanced string optimization with interning and Cow
- Next: Lifetime analysis enhancements for better borrowing inference
๐งช Testing
# Run all tests
# Run with coverage
# Run property tests
# Run benchmarks
# Run specific test suites
Recent Updates
๐ v2.3.0 - MCP and Quality Enhancements
- Updated MCP Integration: Upgraded pmcp SDK from 0.6.3 to 1.2.1
- PMAT Quality Integration: Added automatic quality validation for transpiled code
- Quality scoring system (0-100) with pass/fail thresholds
- Automated suggestions for improving code quality
- Todo task management for multi-file projects
- New MCP Tools: Added
pmat_quality_check
tool for validating Rust code quality
๐งช v2.2.2 - Enhanced Test Coverage & Quality
- Improved Test Coverage: Achieved 70% line coverage with 350+ tests
- Added comprehensive property-based tests for core modules
- Added unit tests for migration_suggestions, direct_rules, lsp, module_mapper
- Added doctests for all public APIs
- Fixed interactive tests to be non-blocking in CI
- Advanced Testing Frameworks: Multiple testing paradigms
- Property-based testing with custom generators
- Mutation testing for code robustness
- Multi-strategy fuzzing (security, unicode, performance)
- Specialized coverage testing with error path analysis
- Quality Automation: Continuous monitoring and metrics
- PMAT metrics dashboard with TDG scoring
- Automated quality gates and thresholds
- Performance regression detection
- CI/CD Integration: Comprehensive GitHub Actions workflows
- Cross-platform testing matrix (Linux, macOS, Windows)
- Automated release workflows
- Quality gate enforcement
๐ ๏ธ v2.1.0 - Developer Tooling Suite
- IDE Integration (LSP): Full Language Server Protocol support
- Symbol navigation, hover info, completions, diagnostics
- Go-to-definition and find-references
- Debugging Support: Source mapping and debugger integration
- Debug levels: None, Basic (line mapping), Full (variable state)
- GDB/LLDB script generation
- Performance Profiling: Analyze transpiled code performance
- Hot path detection and flamegraph generation
- Performance predictions and optimization hints
- Documentation Generation: Auto-generate docs from Python
- API references, usage guides, migration notes
- Markdown and HTML output formats
๐ v2.0.0 - Production Ready
- Optimization Framework: Dead code elimination, constant propagation
- Enhanced Diagnostics: Context-aware errors with suggestions
- Migration Analysis: Python-to-Rust idiom recommendations
- Performance Warnings: Detect O(nยฒ) algorithms and inefficiencies
- Type Inference: Intelligent parameter and return type suggestions
- Function Inlining: Smart inlining with cost-benefit analysis
๐ฏ v1.x Series - Core Features
- v1.6.0: Extended standard library mappings (20+ modules)
- v1.5.0: Basic module system and imports
- v1.4.0: Async/await support
- v1.3.0: Advanced type features (with statements, iterators)
- v1.2.0: Full OOP support (classes, methods, properties)
- v1.1.0: Core language completeness (operators, collections)
๐ค Contributing
We welcome contributions! Please follow our quality standards:
- Write tests first - TDD is mandatory
- Maintain coverage - 85%+ for all new code
- Zero warnings -
cargo clippy -- -D warnings
- Format code -
cargo fmt
- Document changes - Update relevant docs
See CONTRIBUTING.md for detailed guidelines.
๐ Documentation
- Agent Mode Guide - Background agent with MCP integration โจ
- API Documentation - Complete API reference
- Docker Guide - Container deployment
- Troubleshooting - Common issues and solutions
- Release Checklist - Release process guide
- Architecture - System architecture
- Changelog - Version history
- Contributing - Development guide
๐ฆ Roadmap
โ v2.2 - Enterprise Testing (Released)
- Property-based testing framework
- Mutation testing infrastructure
- Security-focused fuzzing
- CI/CD integration with quality gates
โ v2.1 - Developer Experience (Released)
- Complete IDE integration with LSP
- Comprehensive debugging support
- Performance profiling tools
- Documentation generation
โ v2.0 - Production Ready (Released)
- Advanced optimization passes
- Enhanced error reporting
- Migration suggestions
- Performance analysis
โ v1.x - Feature Complete (Released)
- Core language support
- Object-oriented programming
- Type system enhancements
- Async/await basics
- Module system
- Standard library mappings
๐ฎ v3.0 - Advanced Features (Future)
- Full generator support with yield
- Advanced decorator patterns
- Complete async ecosystem
- Package management integration
See ROADMAP.md for detailed plans.
๐ License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Built with extreme quality standards by the Depyler team