Development Setup
Development Setup¶
Set up your environment to contribute to pyrs-yaml.
Prerequisites¶
- Python ≥ 3.8 (CPython)
- Rust ≥ 1.70 (via rustup)
- Git
- uv (recommended) or pip
- NumPy — required for running the NumPy serialization test suite (
pytest tests/test_numpy.py)
Clone and Install¶
Clone and install
git clone https://github.com/759401524/pyrs-yaml.git
cd pyrs-yaml
# Using uv (recommended)
uv sync
# Or using pip (without uv)
pip install maturin
maturin develop --release
Verify Installation¶
Verify installation
# Run Rust tests
cargo test
# Run Python tests (with uv lockfile for reproducible deps)
uv run --frozen pytest tests/
# Run benchmarks
cargo bench
Project Structure¶
Project layout
pyrs-yaml/
├── src/
│ ├── lib.rs # PyO3 module entry
│ ├── ast.rs # Custom AST (CustomNode)
│ ├── serializer.rs # YAML serialization
│ ├── i18n.rs # i18n configuration
│ ├── i18n/ # Internationalization bundles
│ ├── parser/
│ │ ├── mod.rs # Core parsing logic (AstReceiver)
│ │ ├── stream.rs # Streaming event parser
│ │ └── yaml/ # YAML-specific parsing
│ │ ├── comment.rs # Comment extraction
│ │ ├── merge.rs # Merge key (<<) resolution
│ │ ├── scalar.rs # Escape sequences & chomping
│ │ ├── schema.rs # YAML schema resolution
│ │ └── types.rs # YAML 1.2 type resolution
│ ├── py/ # PyO3 Python bindings
│ │ ├── mod.rs # Module definition & exports
│ │ ├── convert.rs # Rust → Python type conversion
│ │ ├── ndarray.rs # NumPy ndarray conversion
│ │ ├── python_types.rs # Python → CustomNode conversion
│ │ └── stream_events.rs# Stream event types
│ └── integration/ # Integration test helpers
├── python/pyrs_yaml/
│ ├── __init__.py # Python package init
│ ├── py.typed # PEP 561 marker
│ └── async_dump.py # Async dump utilities
├── tests/ # Python test suite (~395 tests)
├── benches/ # Rust benchmarks
├── docs/ # Documentation (mkdocs)
├── ruff.toml # Ruff linter config
├── pytest.ini # Pytest config
└── Cargo.toml # Rust dependencies
Build Commands¶
Build commands
# Build Python extension (with uv lockfile)
uv run --frozen maturin develop --release
# Build wheel
uv run --frozen maturin build --release --out dist
# Build with debug info
cargo build
Development Workflow¶
- Write tests first (TDD)
- Implement changes in
src/ - Run
cargo testto verify Rust tests - Run
uv run --frozen pytest tests/to verify Python tests - Run
cargo clippy -- -D warningsto check code quality - Run
cargo fmtto format code