Skip to content

Commit e66ce7e

Browse files
committed
python protobuf files restructured to work as a module
1 parent ef7710d commit e66ce7e

8 files changed

Lines changed: 28 additions & 9 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
_*
2+
!__init__.py
23
cmake-build-*
34
.idea

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CMAKE_MINIMUM_REQUIRED(VERSION 3.25 FATAL_ERROR)
22
PROJECT(fleet-protocol C CXX)
33

4-
SET(FLEET_PROTOCOL_VERSION 2.0.0)
4+
SET(FLEET_PROTOCOL_VERSION 2.0.3)
55
SET(FLEET_PROTOCOL_NAMESPACE "fleet-protocol-interface::")
66

77
OPTION(BRINGAUTO_PACKAGE "Package creation" OFF)

protobuf/README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ TARGET_LINK_LIBRARIES(<target> PUBLIC protobuf::libprotobuf protobuf-cpp-interfa
1818

1919
## Compilation
2020

21-
Compile to all languages:
21+
Compile to all languages: (compiling python requires an extra step!)
2222

2323
```
24-
find protobuf/definition -name "*.proto" -exec protoc -I=protobuf/definition --cpp_out=compiled/cpp --csharp_out=compiled/cs --python_out=compiled/python --go_out=compiled/go/ --go_opt=paths=source_relative {} +
24+
find definition -name "*.proto" -exec protoc -I=./definition --cpp_out=./compiled/cpp --csharp_out=./compiled/cs
25+
--python_out=./compiled/python/fleet_protocol_protobuf_files --go_out=./compiled/go/ --go_opt=paths=source_relative {} +
2526
```
2627

2728
To compile files to a specific language only, use the specific `*_out` options in command.
@@ -30,21 +31,29 @@ Note that protoc doesn't support double asterisks (**), so it should be used wit
3031
**C++**
3132

3233
```
33-
find protobuf/definition -name "*.proto" -exec protoc -I=./definition --cpp_out=./compiled/cpp {} +
34+
find definition -name "*.proto" -exec protoc -I=./definition --cpp_out=./compiled/cpp {} +
3435
```
3536

3637
**C#**
3738

3839
```
39-
find protobuf/definition -name "*.proto" -exec protoc -I=./definition --csharp_out=./compiled/cpp {} +
40+
find definition -name "*.proto" -exec protoc -I=./definition --csharp_out=./compiled/cs {} +
4041
```
4142

4243
**Python**
4344

4445
```
45-
find protobuf/definition -name "*.proto" -exec protoc -I=./definition --python_out=./compiled/cpp {} +
46+
find definition -name "*.proto" -exec protoc -I=./definition --python_out=./compiled/python/fleet_protocol_protobuf_files {} +
4647
```
4748

49+
Afterwards, edit all local imports to start with `fleet_protocol_protobuf_files.`
50+
51+
e.g.:
52+
53+
from `import InternalProtocol_pb2 as InternalProtocol__pb2`
54+
55+
to `import fleet_protocol_protobuf_files.InternalProtocol_pb2 as InternalProtocol__pb2`
56+
4857
**GO**
4958

5059
protoc-gen-go needs to be installed!
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build
2+
*.egg-info

protobuf/compiled/python/ExternalProtocol_pb2.py renamed to protobuf/compiled/python/fleet_protocol_protobuf_files/ExternalProtocol_pb2.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protobuf/compiled/python/InternalProtocol_pb2.py renamed to protobuf/compiled/python/fleet_protocol_protobuf_files/InternalProtocol_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protobuf/compiled/python/fleet_protocol_protobuf_files/__init__.py

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[project]
2+
name = "fleet_protocol_protobuf_files"
3+
version = "2.0.3"
4+
5+
6+
[tool.setuptools.packages.find]
7+
include = ["fleet_protocol_protobuf_files"]

0 commit comments

Comments
 (0)