mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-11-13 10:43:59 +01:00
27 lines
784 B
Plaintext
27 lines
784 B
Plaintext
|
#!/usr/bin/env python3
|
||
|
|
||
|
from subprocess import check_call
|
||
|
from pathlib import Path
|
||
|
import os
|
||
|
|
||
|
root_dir = Path(__file__).absolute().parent.parent
|
||
|
os.chdir(root_dir)
|
||
|
|
||
|
check_call([
|
||
|
"protoc", "--python_out=aioesphomeapi", "-I", "aioesphomeapi",
|
||
|
"aioesphomeapi/api.proto", "aioesphomeapi/api_options.proto"
|
||
|
])
|
||
|
|
||
|
# https://github.com/protocolbuffers/protobuf/issues/1491
|
||
|
api_file = root_dir / 'aioesphomeapi' / 'api_pb2.py'
|
||
|
content = api_file.read_text().replace(
|
||
|
"import api_options_pb2 as api__options__pb2",
|
||
|
"from . import api_options_pb2 as api__options__pb2"
|
||
|
)
|
||
|
api_file.write_text(content)
|
||
|
|
||
|
for fname in ['api_pb2.py', 'api_options_pb2.py']:
|
||
|
file = root_dir / 'aioesphomeapi' / fname
|
||
|
content = '# type: ignore\n' + file.read_text()
|
||
|
file.write_text(content)
|