-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile_proto.py
More file actions
46 lines (39 loc) · 1.18 KB
/
compile_proto.py
File metadata and controls
46 lines (39 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
Script to compile proto files for Python
"""
import subprocess
import sys
import os
def main():
proto_dir = "proto"
output_dir = "generated"
# Create output directory
os.makedirs(output_dir, exist_ok=True)
# Compile grSim-related proto files
proto_files = [
"grSim_Commands.proto",
"grSim_Replacement.proto",
"grSim_Packet.proto",
"ssl_vision_detection.proto",
"ssl_vision_geometry.proto",
"ssl_vision_wrapper.proto",
]
for proto_file in proto_files:
cmd = [
sys.executable, "-m", "grpc_tools.protoc",
f"--proto_path={proto_dir}",
f"--python_out={output_dir}",
f"{proto_dir}/{proto_file}"
]
print(f"Compiling {proto_file}...")
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode != 0:
print(f"Error: {result.stderr}")
sys.exit(1)
# Create __init__.py
init_file = os.path.join(output_dir, "__init__.py")
with open(init_file, "w") as f:
f.write("")
print("Proto files compiled successfully!")
if __name__ == "__main__":
main()