Skip to content

Commit d00e9fa

Browse files
committed
fix(python): let proto stub generation skip .pyi for older protoc
Add a --no-pyi option to generate_python_proto.py for toolchains whose protoc predates --pyi_out, such as Fedora's grpcio-tools 1.48, and list python3-googleapis-common-protos and python3-httpx in the spec's Recommends and dist-info Requires-Dist, which the SDK needs to import. Default behavior is unchanged. Contributes to NVIDIA#3510. Signed-off-by: politerealism <[email protected]>
1 parent db94c17 commit d00e9fa

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎openshell.spec‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ Summary: OpenShell Python SDK for agent execution and management
7373
# versions of grpcio (1.48) and protobuf (3.19) than the SDK needs.
7474
# Users on distros with older packages can install these via pip/uv.
7575
Recommends: python3-cloudpickle >= 3.0
76+
Recommends: python3-googleapis-common-protos >= 1.63
7677
Recommends: python3-grpcio >= 1.60
78+
Recommends: python3-httpx >= 0.27
7779
Recommends: python3-protobuf >= 4.25
7880
Recommends: %{name}
7981

@@ -207,7 +209,9 @@ Summary: OpenShell Python SDK for agent execution and management
207209
License: Apache-2.0
208210
Requires-Python: >=3.12
209211
Requires-Dist: cloudpickle>=3.0
212+
Requires-Dist: googleapis-common-protos>=1.63
210213
Requires-Dist: grpcio>=1.60
214+
Requires-Dist: httpx>=0.27
211215
Requires-Dist: protobuf>=4.25
212216
EOF
213217

‎tasks/scripts/generate_python_proto.py‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
"""Generate Python protobuf stubs and make their imports package-relative."""
55

6+
import argparse
67
import re
78
import subprocess
89
import sys
@@ -72,14 +73,25 @@
7273

7374

7475
def main() -> None:
76+
parser = argparse.ArgumentParser(description=__doc__)
77+
parser.add_argument(
78+
"--no-pyi",
79+
action="store_true",
80+
help=(
81+
"Skip .pyi type stubs. Needed with protoc older than 3.20 "
82+
"(e.g. Fedora's grpcio-tools 1.48), which has no --pyi_out."
83+
),
84+
)
85+
args = parser.parse_args()
86+
7587
subprocess.run(
7688
[
7789
sys.executable,
7890
"-m",
7991
"grpc_tools.protoc",
8092
"-Iproto",
8193
"--python_out=python/openshell/_proto",
82-
"--pyi_out=python/openshell/_proto",
94+
*([] if args.no_pyi else ["--pyi_out=python/openshell/_proto"]),
8395
"--grpc_python_out=python/openshell/_proto",
8496
*PROTO_FILES,
8597
],

0 commit comments

Comments
 (0)