pub fn build(
pyproject: Option<&str>,
no_verify: bool,
_postprocess_only: bool,
) -> Result<()>Expand description
Execute the build command to generate Python code from proto files.
This is the main entry point for the code generation pipeline. It performs the complete workflow: loading configuration, generating code, applying post-processing transformations, and running verification checks.
§Arguments
pyproject- Optional path to the pyproject.toml file. If None, uses “pyproject.toml”no_verify- If true, skips the verification step after generation_postprocess_only- If true, skips generation and only runs post-processing (experimental)
§Returns
Returns Ok(()) on successful completion, or an error if any step fails.
§Pipeline Steps
- Configuration: Load and validate pyproject.toml settings
- Generation: Run protoc or buf to generate Python files
- Post-processing:
- Create
__init__.pyfiles if configured - Convert absolute imports to relative imports
- Add type checker suppression headers
- Create
- Verification: Run import tests and optional type checking
§Example
use python_proto_importer::commands::build;
// Standard build
build(None, false, false)?;
// Build without verification
build(None, true, false)?;
// Build with custom config file
build(Some("custom.toml"), false, false)?;