Repository navigation
Depend on betterproto2 runtime instead of the compiler - #46
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
pyproject.tomllistsbetterproto2-compileras a runtime dependency. It is only the protoc plugin used bygen-proto.sh(--python_betterproto2_out); the code undersrc/imports justbetterproto2. As a result, everyone who installsoxiaalso gets ruff, jinja2, markupsafe and strenum.Example
Runtime closure (
uv export --no-dev) before: betterproto2, betterproto2-compiler, grpcio, jinja2, markupsafe, python-dateutil, ruff, six, strenum, typing-extensions, xxhash.Change
The
<0.10upper bound is required: the generated stubs pin_COMPILER_VERSION = "0.9.0"andbetterproto2.check_compiler_version()raises at import time unless the runtime major.minor matches. The compiler in the dev group needs no upper bound, sincebetterproto2-compiler0.9.0 itself requiresbetterproto2>=0.9.0,<0.10.Runtime closure after: betterproto2, grpcio, python-dateutil, six, typing-extensions, xxhash.
The
uv.lockdiff covers only the dependency move. Plainuv lockalso rewrites the headerrequires-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.uv sync --no-dev),import oxiaand the generated proto module both work, and neither the compiler nor ruff is installed.get_sequence_updatesandget_notificationsreturn the cancellable call). Note:gen-proto.shcurrently has to be run fromsrc/, since its paths predate the move undersrc/; that's a separate fix.