A Python package powered by Rust, featuring a text analysis library with PyO3 bindings.
rust-py-project/
├── justfile # Main orchestration
├── rust_core/ # Rust library → Python package
│ ├── Cargo.toml # Rust dependencies
│ ├── pyproject.toml # Maturin build config
│ ├── .python-version # Python version (3.11)
│ └── src/
│ └── lib.rs # TextAnalyzer implementation with PyO3
└── python_app/ # Python project using rust_core
├── pyproject.toml # Python dependencies + local rust_core
├── .python-version # Python version (3.11)
├── src/
│ └── python_app/
│ └── __init__.py # Python wrapper and utilities
└── tests/
├── __init__.py
└── test_integration.py # Pytest integration tests
The rust_core package provides a TextAnalyzer class with:
word_count()- Count word frequencies (case-insensitive, strips punctuation)char_count()- Count total characters including whitespacemost_common(n)- Get top N most frequent wordsget_text()- Retrieve original text
# Initial setup (installs Rust, maturin, rust_core deps)
just setup
# Build and install in development mode
just dev
# Run all tests
just test
# Format all code
just fmt
# Lint all code
just lint
# Clean and rebuild everything
just rebuild
# Check project health (format, lint, test)
just checkfrom rust_core import TextAnalyzer
# Create analyzer
analyzer = TextAnalyzer("The quick brown fox jumps over the lazy dog")
# Get word frequencies
counts = analyzer.word_count()
print(counts) # {'the': 2, 'quick': 1, 'brown': 1, ...}
# Get character count
print(analyzer.char_count()) # 44
# Get top 3 most common words
top_words = analyzer.most_common(3)
print(top_words) # [('the', 2), ('brown', 1), ('dog', 1)]Setup:
just setup- Install Rust and rust_core dependenciesjust setup-rust- Install/update Rust toolchainjust setup-rust-python- Install maturin and rust_core dependenciesjust setup-test-python- Sync python_app dependencies
Build:
just dev- Build and install in development modejust build-release- Build optimized release wheel
Testing:
just test- Run all tests
Code Quality:
just fmt- Format all codejust fmt-rust- Format Rust codejust fmt-python- Format Python codejust lint- Lint all codejust lint-rust- Lint Rust codejust lint-python- Lint Python codejust check- Full health check (format + lint + test)
Cleanup:
just clean- Remove all build artifactsjust clean-rust- Remove Rust build artifactsjust clean-python- Remove Python artifactsjust rebuild- Clean and rebuild from scratch
Utilities:
just inspect- Show project structure
- Make changes to Rust code in
rust_core/src/lib.rs - Run
just devto rebuild and install - Run
just testto verify all tests pass - Format and lint with
just check
- rust_core: Rust library compiled to a Python extension module using PyO3 and maturin
- python_app: Python application that depends on
rust_coreas an editable local dependency - All state-changing operations are managed through the justfile for consistency