Skip to content

Commit f51cec9

Browse files
committed
Add frequenz-api-common to the default submodules
Practically all API clients will need to include `frequenz-api-common`, and for the ones who don't, it is much easier to remove stuff thant to add it. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 49c727a commit f51cec9

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
[submodule "submodules/api-common-protos"]
33
path = submodules/api-common-protos
44
url = https://github.com/googleapis/api-common-protos.git
5+
[submodule "frequenz-api-common"]
6+
path = submodules/frequenz-api-common
7+
url = https://github.com/frequenz-floss/frequenz-api-common.git
58
{% endif -%}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ dependencies = [ # TODO(cookiecutter): Remove and add more if appropriate
3838
]
3939
{%- elif cookiecutter.type == "api" %}
4040
dependencies = [ # TODO(cookiecutter): Remove and add more if appropriate
41+
"frequenz-api-common >= 0.2.0, < 0.3.0",
4142
"googleapis-common-protos >= 1.56.2, < 2",
4243
"grpcio >= 1.51.1, < 2",
4344
]

src/frequenz/repo/config/__init__.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# License: MIT
22
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH
33

4-
"""Frequenz project setup tools and common configuration.
4+
r"""Frequenz project setup tools and common configuration.
55
66
The tools are provided to configure the main types of repositories most commonly used at
77
Frequenz, defined in
@@ -166,15 +166,21 @@
166166
- `pytests/`: Directory containing the tests for the Python code.
167167
- `submodules/api-common-protos`: Directory containing the submodule with the
168168
`google/api-common-protos` repository.
169+
- `submodules/frequenz-api-common`: Directory containing the submodule with the
170+
`frequenz-floss/frequenz-api-common` repository.
169171
170172
Normally Frequenz APIs use basic types from
171-
[`google/api-common-protos`](https://github.com/googleapis/api-common-protos),
172-
so you need to make sure the proper submodule is added to your project:
173+
[`google/api-common-protos`](https://github.com/googleapis/api-common-protos) and
174+
[`frequenz-floss/frequenz-api-common`](https://github.com/frequenz-floss/frequenz-api-common),
175+
so you need to make sure the proper submodules are added to your project:
173176
174177
```sh
175178
mkdir submodules
176-
git submodule add https://github.com:googleapis/api-common-protos.git submodules/api-common-protos
177-
git commit -m "Add Google api-common-protos submodule" submodules/api-common-protos
179+
git submodule add https://github.com/googleapis/api-common-protos.git \
180+
submodules/api-common-protos
181+
git submodule add https://github.com/frequenz-floss/frequenz-api-common.git \
182+
submodules/frequenz-api-common
183+
git commit -m "Add api-common-protos and frequenz-api-common submodules" submodules
178184
```
179185
180186
Then you need to add this package as a build dependency and a few extra
@@ -190,6 +196,7 @@
190196
191197
[project]
192198
dependencies = [
199+
"frequenz-api-common == 0.2.0",
193200
"googleapis-common-protos == 1.56.2",
194201
"grpcio == 1.51.0",
195202
]
@@ -222,6 +229,7 @@
222229
223230
```
224231
recursive-include submodules/api-common-protos/google *.proto
232+
recursive-include submodules/frequenz-api-common/proto *.proto
225233
```
226234
227235
If the defaults are not suitable for you (for example you need to use more or less
@@ -236,8 +244,8 @@
236244
# Glob pattern to use to find the proto files in the proto_path (default: "*.proto")
237245
proto_glob = "*.prt" # Default: "*.proto"
238246
# List of paths to pass to the protoc compiler as include paths (default:
239-
# ["submodules/api-common-protos"])
240-
include_paths = []
247+
# ["submodules/api-common-protos", "submodules/frequenz-api-common/proto"])
248+
include_paths = ["submodules/api-common-protos"]
241249
# Path where to generate the Python files (default: "py")
242250
py_path = "generated"
243251
```

src/frequenz/repo/config/setuptools/grpc_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class CompileProto(_setuptools.Command):
6262
DEFAULT_OPTIONS: dict[str, str] = {
6363
"proto_path": "proto",
6464
"proto_glob": "*.proto",
65-
"include_paths": "submodules/api-common-protos",
65+
"include_paths": "submodules/api-common-protos,submodules/frequenz-api-common/proto",
6666
"py_path": "py",
6767
}
6868

0 commit comments

Comments
 (0)