Skip to content

Commit 6d49ce5

Browse files
authored
Pin protobuf related dependencies (#309)
We can't use wide dependencies because otherwise when building the wheel, the latest version is used, but the generate code should use the minimum supported version for the generation, not the latest one. See: https://protobuf.dev/support/cross-version-runtime-guarantee/. For doing this we also need to depend on `frequence-api-common` v0.6.2+ because it is the version that contains the same fix for the generated files. We also take the opportunity to remove the `google-common-protos` dependency from the API projects by default and to bump the `grpcio` dependency to `1.66.1` and to fix an issue with `mkdocstrings` and newer `griffe` versions.
2 parents 21cb7f1 + fe51015 commit 6d49ce5

File tree

14 files changed

+58
-43
lines changed

14 files changed

+58
-43
lines changed

RELEASE_NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
### Cookiecutter template
2020

2121
* Group GitHub Actions dependabot updates.
22+
* API projects don't include the `google-common-protos` dependency by default.
23+
* API projects updated the `grpcio` dependency to `1.66.1`.
24+
* API projects updated the `frequenz-api-common` dependency to `0.6`.
2225

2326
## Bug Fixes
2427

cookiecutter/{{cookiecutter.github_repo_name}}/.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{% if cookiecutter.type == "api" -%}
2-
[submodule "submodules/api-common-protos"]
3-
path = submodules/api-common-protos
4-
url = https://github.com/googleapis/api-common-protos.git
52
[submodule "submodules/frequenz-api-common"]
63
path = submodules/frequenz-api-common
74
url = https://github.com/frequenz-floss/frequenz-api-common.git

cookiecutter/{{cookiecutter.github_repo_name}}/mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ plugins:
124124
- https://frequenz-floss.github.io/frequenz-channels-python/v0.16/objects.inv
125125
- https://frequenz-floss.github.io/frequenz-sdk-python/v0.25/objects.inv
126126
{%- elif cookiecutter.type == "api" %}
127-
- https://frequenz-floss.github.io/frequenz-api-common/v0.3/objects.inv
127+
- https://frequenz-floss.github.io/frequenz-api-common/v0.6/objects.inv
128128
- https://grpc.github.io/grpc/python/objects.inv
129129
{%- endif %}
130130
- https://typing-extensions.readthedocs.io/en/stable/objects.inv

cookiecutter/{{cookiecutter.github_repo_name}}/pyproject.toml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ requires = [
66
"setuptools == 70.1.1",
77
"setuptools_scm[toml] == 8.1.0",
88
"frequenz-repo-config[{{cookiecutter.type}}] == 0.10.0",
9+
{%- if cookiecutter.type == "api" %}
10+
# We need to pin the protobuf, grpcio and grpcio-tools dependencies to make
11+
# sure the code is generated using the minimum supported versions, as older
12+
# versions can't work with code that was generated with newer versions.
13+
# https://protobuf.dev/support/cross-version-runtime-guarantee/#backwards
14+
"protobuf == 5.28.0",
15+
"grpcio-tools == 1.66.1",
16+
"grpcio == 1.66.1",
17+
{%- endif %}
918
]
1019
build-backend = "setuptools.build_meta"
1120

@@ -43,9 +52,15 @@ dependencies = [
4352
]
4453
{%- elif cookiecutter.type == "api" %}
4554
dependencies = [
46-
"frequenz-api-common >= 0.5.0, < 0.6.0",
47-
"googleapis-common-protos >= 1.56.2, < 2",
48-
"grpcio >= 1.51.1, < 2",
55+
"frequenz-api-common >= 0.6.2, < 0.7.0",
56+
# We can't widen beyond the current value unless we bump the minimum
57+
# requirements too because of protobuf cross-version runtime guarantees:
58+
# https://protobuf.dev/support/cross-version-runtime-guarantee/#major
59+
"protobuf >= 5.28.0, < 7", # Do not widen beyond 7!
60+
# We couldn't find any document with a spec about the cross-version runtime
61+
# guarantee for grpcio, so unless we find one in the future, we'll assume
62+
# major version jumps are not compatible
63+
"grpcio >= 1.66.1, < 2", # Do not widen beyond 2!
4964
]
5065
{%- else %}
5166
dependencies = [
@@ -76,8 +91,8 @@ dev-mkdocs = [
7691
"mkdocs-literate-nav == 0.6.1",
7792
"mkdocs-macros-plugin == 1.0.5",
7893
"mkdocs-material == 9.5.27",
79-
"mkdocstrings[python] == 0.25.1",
80-
"mkdocstrings-python == 1.10.5",
94+
"mkdocstrings[python] == 0.26.1",
95+
"mkdocstrings-python == 1.11.1",
8196
"frequenz-repo-config[{{cookiecutter.type}}] == 0.10.0",
8297
]
8398
dev-mypy = [

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ dev-mkdocs = [
8282
"mkdocs-literate-nav == 0.6.1",
8383
"mkdocs-macros-plugin == 1.0.5",
8484
"mkdocs-material == 9.5.30",
85-
"mkdocstrings[python] == 0.25.2",
86-
"mkdocstrings-python == 1.10.7",
85+
"mkdocstrings[python] == 0.26.1",
86+
"mkdocstrings-python == 1.11.1",
8787
]
8888
dev-mypy = [
8989
"mypy == 1.11.1",

src/frequenz/repo/config/__init__.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@
340340
# Glob pattern to use to find the proto files in the proto_path (default: "*.proto")
341341
proto_glob = "*.prt" # Default: "*.proto"
342342
# List of paths to pass to the protoc compiler as include paths (default:
343-
# ["submodules/api-common-protos", "submodules/frequenz-api-common/proto"])
344-
include_paths = ["submodules/api-common-protos"]
343+
# ["submodules/frequenz-api-common/proto"])
344+
include_paths = ["submodules/frequenz-api-common/proto"]
345345
# Path where to generate the Python files (default: "py")
346346
py_path = "generated"
347347
# Path where to generate the documentation files (default: "protobuf-reference")
@@ -376,23 +376,18 @@
376376
section plus the following:
377377
378378
- `pytests/`: Directory containing the tests for the Python code.
379-
- `submodules/api-common-protos`: Directory containing the Git submodule with the
380-
`google/api-common-protos` repository.
381379
- `submodules/frequenz-api-common`: Directory containing the Git submodule with the
382380
`frequenz-floss/frequenz-api-common` repository.
383381
384382
Normally Frequenz APIs use basic types from
385-
[`google/api-common-protos`](https://github.com/googleapis/api-common-protos) and
386383
[`frequenz-floss/frequenz-api-common`](https://github.com/frequenz-floss/frequenz-api-common),
387384
so you need to make sure the proper submodules are added to your project:
388385
389386
```sh
390387
mkdir submodules
391-
git submodule add https://github.com/googleapis/api-common-protos.git \
392-
submodules/api-common-protos
393388
git submodule add https://github.com/frequenz-floss/frequenz-api-common.git \
394389
submodules/frequenz-api-common
395-
git commit -m "Add api-common-protos and frequenz-api-common submodules" submodules
390+
git commit -m "Add frequenz-api-common submodule" submodules
396391
```
397392
398393
Then you need to add this package as a build dependency and a few extra
@@ -435,13 +430,11 @@
435430
```
436431
437432
Finally you need to make sure to include the generated `*.pyi` files in the
438-
source distribution, as well as the Google api-common-protos files, as it
439-
is not handled automatically yet
433+
source distribution, as it is not handled automatically yet
440434
([#13](https://github.com/frequenz-floss/frequenz-repo-config-python/issues/13)).
441435
Make sure to include these lines in the `MANIFEST.in` file:
442436
443437
```
444-
recursive-include submodules/api-common-protos/google *.proto
445438
recursive-include submodules/frequenz-api-common/proto *.proto
446439
```
447440

src/frequenz/repo/config/protobuf.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ class ProtobufConfig:
2727
proto_glob: str = "*.proto"
2828
"""The glob pattern to use to find the protobuf files."""
2929

30-
include_paths: Sequence[str] = (
31-
"submodules/api-common-protos",
32-
"submodules/frequenz-api-common/proto",
33-
)
30+
include_paths: Sequence[str] = ("submodules/frequenz-api-common/proto",)
3431
"""The paths to add to the include path when compiling the protobuf files."""
3532

3633
py_path: str = "py"

tests_golden/integration/test_cookiecutter_generation/actor/frequenz-actor-test/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ dev-mkdocs = [
5858
"mkdocs-literate-nav == 0.6.1",
5959
"mkdocs-macros-plugin == 1.0.5",
6060
"mkdocs-material == 9.5.27",
61-
"mkdocstrings[python] == 0.25.1",
62-
"mkdocstrings-python == 1.10.5",
61+
"mkdocstrings[python] == 0.26.1",
62+
"mkdocstrings-python == 1.11.1",
6363
"frequenz-repo-config[actor] == 0.10.0",
6464
]
6565
dev-mypy = [
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[submodule "submodules/api-common-protos"]
2-
path = submodules/api-common-protos
3-
url = https://github.com/googleapis/api-common-protos.git
41
[submodule "submodules/frequenz-api-common"]
52
path = submodules/frequenz-api-common
63
url = https://github.com/frequenz-floss/frequenz-api-common.git

tests_golden/integration/test_cookiecutter_generation/api/frequenz-api-test/mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ plugins:
120120
# TODO(cookiecutter): You might want to add other external references here
121121
# See https://mkdocstrings.github.io/python/usage/#import for details
122122
- https://docs.python.org/3/objects.inv
123-
- https://frequenz-floss.github.io/frequenz-api-common/v0.3/objects.inv
123+
- https://frequenz-floss.github.io/frequenz-api-common/v0.6/objects.inv
124124
- https://grpc.github.io/grpc/python/objects.inv
125125
- https://typing-extensions.readthedocs.io/en/stable/objects.inv
126126
# Note this plugin must be loaded after mkdocstrings to be able to use macros

0 commit comments

Comments
 (0)