Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Development

## Recompiling the lib proto files

After some updates in the compiler, it might be useful to recompile the standard Google proto files. As the proto files
are distributed with `protoc`, their path might depend on your installation.

```bash
mkdir lib
protoc \
--python_betterproto2_opt=INCLUDE_GOOGLE \
--python_betterproto2_out=lib \
-I /usr/include/ \
/usr/include/google/protobuf/*.proto
```

The generated files should be distributed in the `betterproto2` package.

!!! warning
These proto files are written with the `proto2` syntax, which is not supported by betterproto. For the compiler to
work, you need to manually patch the generated file to mark the field `oneof_index` in `Field` and
`FieldDescriptorProto` optional.

In the compiler, you also need to compile the [plugin.proto](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/compiler/plugin.proto)
file in `src/betterproto2_compiler/lib/google.protobug/compiler/__init__.py`.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ nav:
- Betterproto2 compiler:
- index.md
- Getting started: getting-started.md
- Development: development.md

plugins:
- mkdocstrings
Expand Down
472 changes: 232 additions & 240 deletions poetry.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "betterproto2_compiler"
version = "0.1.0"
version = "0.1.1"
description = "Compiler for betterproto2"
authors = ["Adrien Vannson <[email protected]>", "Daniel G. Taylor <[email protected]>"]
readme = "README.md"
Expand All @@ -13,7 +13,7 @@ packages = [

[tool.poetry.dependencies]
python = "^3.10"
betterproto2 = "0.0.2"
betterproto2 = "^0.1.1"
# The Ruff version is pinned. To update it, also update it in .pre-commit-config.yaml
ruff = "~0.7.4"
grpclib = "^0.4.1"
Expand Down Expand Up @@ -102,13 +102,13 @@ cmd = "ruff check src tests"
help = "Check the code with the Ruff linter"

[tool.poe.tasks.generate_lib]
cmd = """
protoc
--plugin=protoc-gen-custom=src/betterproto2_compiler/plugin/main.py
--custom_opt=INCLUDE_GOOGLE
--custom_out=src/betterproto/lib/std
-I /usr/local/include/
/usr/local/include/google/protobuf/**/*.proto
shell = """
protoc \
--plugin=protoc-gen-custom=src/betterproto2_compiler/plugin/main.py \
--custom_opt=INCLUDE_GOOGLE \
--custom_out=src/betterproto2_compiler/lib \
-I /usr/include/ \
/usr/include/google/protobuf/**/*.proto
"""
help = "Regenerate the types in betterproto.lib.std.google"

Expand Down
3 changes: 2 additions & 1 deletion src/betterproto2_compiler/compile/importing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
TYPE_CHECKING,
)

from betterproto2.lib.google import protobuf as google_protobuf

from ..casing import safe_snake_case
from ..lib.google import protobuf as google_protobuf
from .naming import pythonize_class_name

if TYPE_CHECKING:
Expand Down
Loading
Loading