Skip to content

fastgrpc compile

Generate a complete client bundle: the .proto source plus pre-compiled _pb2.py and _pb2_grpc.py Python modules.

fastgrpc compile <file> --out <dir> [--package PACKAGE]

Arguments

Argument Default Description
<file> required Path to the Python file containing your @service classes
--out, -o .fastgrpc Directory to write the bundle into
--package fastgrpc Protobuf package declaration in the output

Example

fastgrpc compile main.py --out ./client/
client/
├── fastgrpc.proto
├── fastgrpc_pb2.py
└── fastgrpc_pb2_grpc.py

A client team consuming this bundle just imports it:

import grpc
from client.fastgrpc_pb2 import GetUserRequest
from client.fastgrpc_pb2_grpc import UserServiceStub

with grpc.insecure_channel("localhost:50051") as channel:
    stub = UserServiceStub(channel)
    user = stub.GetUser(GetUserRequest(user_id=1))
    print(user.name)

When to use this

  • Distributing a client library to teams that consume your service
  • Schema repository workflow where multiple services publish artifacts to a shared repo
  • Polyglot environments where you want a Python client built but other clients (Go, Java, etc.) build from the .proto themselves

The output directory is self-contained — you can commit it, package it as a wheel, or upload it as a CI artifact.

Behavior

fastgrpc compile runs the same codegen pipeline as dev and run, including:

  • The lock pass (consults and updates .fastgrpc.lock)
  • Validation
  • The protoc compiler step

If the lock file enforces a field number that's no longer present in your code, the field is tombstoned (never reused by future fields).

Difference from proto

fastgrpc proto fastgrpc compile
Output .proto source to stdout .proto + _pb2.py + _pb2_grpc.py to a directory
Use case Quick inspection, copying Distributable client bundle
Runs protoc no yes