Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
XFY9326 committed Feb 26, 2024
1 parent ce93bd5 commit 1d6fc0a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
python-version: "3.10"
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
python-version: "3.10"
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
Expand Down
19 changes: 15 additions & 4 deletions build_protobuf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from pathlib import Path

PROJECT_ROOT = Path(__file__).parent.absolute()
PROJECT_ROOT = Path(__file__).resolve().parent.absolute()

PROTOC_PATH = "protoc"
PROTO_DIR = PROJECT_ROOT.joinpath("proto")
Expand All @@ -12,6 +12,7 @@
print("protoc not found")
exit(1)

print()
if PYTHON_OUTPUT_DIR.exists():
old_files = [i for i in os.listdir(PYTHON_OUTPUT_DIR) if i.endswith(("_pb2.py", "_pb2.pyi"))]
if len(old_files) > 0:
Expand All @@ -23,11 +24,21 @@
PYTHON_OUTPUT_DIR.mkdir()
PYTHON_OUTPUT_DIR.joinpath("__init__.py").touch()

print()
print("Creating protobuf files")
os.system(" ".join([
proto_files = [f"\"{i}\"" for i in PROTO_DIR.glob("*.proto")]
protoc_cmd = [
str(PROTOC_PATH),
f"--proto_path=\"{PROTO_DIR}\"",
f"--pyi_out=\"{PYTHON_OUTPUT_DIR}\"",
f"--python_out=\"{PYTHON_OUTPUT_DIR}\"",
f"\"{PROTO_DIR.joinpath('*')}\""
]))
*proto_files
]
print("Commands:", "\n".join(protoc_cmd))

result = os.system(" ".join(protoc_cmd))
print()
if result == 0:
print("Protobuf files create success")
else:
print("Protobuf files create failed")

0 comments on commit 1d6fc0a

Please sign in to comment.