Skip to content

Split protobuf tools out to a new frequenz-protobufutil-python repo #442

@llucax

Description

@llucax

What's needed?

Move all protobuf-related functionality into a single repository named frequenz-protobufutil-python that provides a small stdlib-only core (config + helpers) and optional extras for build and docs.

Proposed solution

Files to move

  • src/frequenz/repo/config/protobuf.pyProtobufConfig (single source of truth for proto paths/globs/include_paths)
  • src/frequenz/repo/config/setuptools/grpc_tools.py — the setuptools command to compile .proto → Python (CompileProto or equivalent)
  • src/frequenz/repo/config/mkdocs/api_pages.py — the functions that generate protobuf API docs
  • Any helper modules used exclusively by the above (e.g., utils that touch proto compilation or doc generation).

Suggested new repository layout

  • frequenz.protobufutil (package)
    • __init__.py (re-export ProtobufConfig at top-level)
    • config.py (move/rename from protobuf.py)
    • setuptools.py
    • mkdocs.py

Packaging & extras

  • Default/core: only stdlib; exposes ProtobufConfig and tiny helpers. No heavyweight imports at module-import time.
  • [setuptools] extra: grpcio-tools, mypy-protobuf, setuptools-related packages. Declares the setuptools entry point for CompileProto.
  • [mkdocs] extra: mkdocs-gen-files, mkdocstrings (if needed); keep mkdocs imports lazy.

Entry points

  • Provide a distutils/setuptools entry point only when [setuptools] extra is installed. The package should register e.g. distutils.commands or another suitable entry point that downstream projects can call. Keep heavy imports inside the command implementation so importing the package doesn't pull build deps.

Downstream usage examples

Build-time

Compilation of .proto files during build.

[build-system]
requires = [
  "setuptools == ...",
  "setuptools_scm[toml]  == ...",
  "frequenz-protobuf[setuptools] == ...",
]
build-backend = "setuptools.build_meta"

Documentation generation

Add to docs/dev or docs extra:

[project.optional-dependencies]
mkdocs = [
  "frequenz-protobuf[mkdocs] == ...",
]

and in the mkdocs script:

from frequenz.protobufutils.mkdocs import generate_protobuf_api_pages

generate_protobuf_api_pages()

Metadata

Metadata

Assignees

Labels

part:mkdocsAffects the configuration of mkdocspart:only-apiAffects the configuration of a api repopart:protobufAffects the protobuf toolstype:tech-debtImproves the project without visible changes for users

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions