Skip to content

Commit b204563

Browse files
fix(rpm): build the Python SDK from older protoc and install every SDK module (ai-openshell/openshell#4439)
* 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 ai-openshell/openshell#3510. Signed-off-by: politerealism <burdcat17@gmail.com> * fix(rpm): install every SDK module and record the license accounting The python3-openshell %install copied only __init__.py, sandbox.py and _proto/, but the package imports .errors, .mutations and .providers and ships a py.typed marker, so an installed RPM could not import openshell. Install the missing files and add a %check that fails if any relative import in the installed package has no matching installed module. Importing the package needs grpcio, which the build environment lacks, so the check is static. Set License to the minimal SPDX expression covering every crate linked into the shipped binaries, keep the pure-Python subpackage at Apache-2.0, and note how the non-crate content is covered. Signed-off-by: politerealism <burdcat17@gmail.com> --------- Signed-off-by: politerealism <burdcat17@gmail.com>
1 parent 76cc814 commit b204563

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎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)