Skip to content

Depend on betterproto2 runtime instead of the compiler - #46

Merged
merlimat merged 1 commit into
oxia-db:mainfrom
merlimat:fix/runtime-betterproto2-dep
Oct 4, 2026
Merged

merlimat merged 1 commit into
oxia-db:mainfrom
merlimat:fix/runtime-betterproto2-dep

Conversation

@merlimat

@merlimat merlimat commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Problem

pyproject.toml lists betterproto2-compiler as a runtime dependency. It is only the protoc plugin used by gen-proto.sh (--python_betterproto2_out); the code under src/ imports just betterproto2. As a result, everyone who installs oxia also gets ruff, jinja2, markupsafe and strenum.

Example

dependencies = [
    "betterproto2-compiler",
    "grpcio",
    "xxhash",
]

Runtime closure (uv export --no-dev) before: betterproto2, betterproto2-compiler, grpcio, jinja2, markupsafe, python-dateutil, ruff, six, strenum, typing-extensions, xxhash.

Change

dependencies = [
    # Generated stubs call betterproto2.check_compiler_version(), which requires
    # the runtime major.minor to match the betterproto2-compiler that produced them.
    "betterproto2>=0.9.0,<0.10",
    "grpcio",
    "xxhash",
]

[dependency-groups]
dev = [
    "betterproto2-compiler>=0.9.0",
    ...
]

The <0.10 upper bound is required: the generated stubs pin _COMPILER_VERSION = "0.9.0" and betterproto2.check_compiler_version() raises at import time unless the runtime major.minor matches. The compiler in the dev group needs no upper bound, since betterproto2-compiler 0.9.0 itself requires betterproto2>=0.9.0,<0.10.

Runtime closure after: betterproto2, grpcio, python-dateutil, six, typing-extensions, xxhash.

The uv.lock diff covers only the dependency move. Plain uv lock also rewrites the header requires-python = ">=3.13" to >=3.10 (the lock body already holds the 3.10 resolution); that unrelated line is left out.

Testing

  • uv run --frozen pytest: 68 passed.
  • With dev dependencies removed (uv sync --no-dev), import oxia and the generated proto module both work, and neither the compiler nor ruff is installed.
  • Regenerating stubs with the dev-group compiler matches the committed stubs except for the two intentional hand edits (get_sequence_updates and get_notifications return the cancellable call). Note: gen-proto.sh currently has to be run from src/, since its paths predate the move under src/; that's a separate fix.

The runtime code only imports betterproto2. betterproto2-compiler is the
protoc plugin used by gen-proto.sh, and listing it as a runtime dependency
made every install of oxia pull in ruff, jinja2, markupsafe and strenum.

Depend on betterproto2>=0.9.0,<0.10 at runtime: the generated stubs call
betterproto2.check_compiler_version("0.9.0"), which fails at import time
unless the runtime major.minor matches the compiler's. Move
betterproto2-compiler to the dev dependency group so gen-proto.sh keeps
working.

Signed-off-by: Matteo Merli <mmerli@apache.org>
@merlimat
merlimat merged commit d963320 into oxia-db:main Oct 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant