Documentation
¶
Overview ¶
Package python implements the Python protobuf compiler.
Index ¶
- func DefaultExcludeImports() []string
- func ValidateWorkDir(workDir string) error
- type Compiler
- func (c *Compiler) Compile(ctx context.Context, files []compiler.ProtoFile, opts compiler.CompileOptions) (*compiler.CompileResult, error)
- func (c *Compiler) GetOutputPath(file compiler.ProtoFile, opts compiler.CompileOptions) string
- func (c *Compiler) Name() string
- func (c *Compiler) RequiredTools() []string
- func (c *Compiler) Validate() error
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultExcludeImports ¶ added in v1.2.0
func DefaultExcludeImports() []string
DefaultExcludeImports returns the default list of module prefixes to exclude from import fixing These are well-known protobuf/grpc packages that come from external sources
func ValidateWorkDir ¶ added in v1.1.1
ValidateWorkDir validates that the workdir is a valid Python module path. A valid Python module path consists of dot-separated identifiers, where each identifier starts with a letter or underscore and contains only letters, digits, and underscores. Empty string is valid (no workdir prefix). Examples: "myapp", "my_project.api", "app123.module_name"
Types ¶
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler implements the compiler.Compiler interface for Python
func (*Compiler) Compile ¶
func (c *Compiler) Compile(ctx context.Context, files []compiler.ProtoFile, opts compiler.CompileOptions) (*compiler.CompileResult, error)
Compile compiles the given proto files to Python
func (*Compiler) GetOutputPath ¶
GetOutputPath returns the output path for a proto file
func (*Compiler) RequiredTools ¶
RequiredTools returns the list of required external tools
type Options ¶
type Options struct {
// ProtocPath is the path to the protoc binary
ProtocPath string
// GrpcPythonPluginPath is the path to the grpc_python_plugin
GrpcPythonPluginPath string
// GenerateGrpc enables gRPC code generation
GenerateGrpc bool
// GenerateTyping enables .pyi stub file generation
GenerateTyping bool
// GenerateInit enables __init__.py generation
GenerateInit bool
// PythonPackagePrefix is the Python package prefix for imports
PythonPackagePrefix string
// WorkDir is the working directory prefix for imports (e.g., "myapp" -> "from myapp.generated.python import ...")
WorkDir string
// ExcludeImports is a list of module prefixes to exclude from import path fixing
// These are typically external dependencies like google.protobuf, grpc, etc.
ExcludeImports []string
}
Options contains Python-specific compilation options
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions returns default options for Python compiler