plexus-python-protobuf-setup 1.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,68 @@
1
+ import importlib.metadata
2
+ from os import PathLike
3
+ from typing import Iterable
4
+
5
+ try:
6
+ __version__ = importlib.metadata.version("plexus-python-protobuf-setup")
7
+ except importlib.metadata.PackageNotFoundError:
8
+ __version__ = "unknown"
9
+
10
+
11
+ def compile_protos(
12
+ out_dir: str | PathLike[str],
13
+ proto_dirs: Iterable[str | PathLike[str]],
14
+ include_dirs: Iterable[str | PathLike[str]],
15
+ *,
16
+ descriptor_path: str | PathLike[str] | None = None,
17
+ with_grpc: bool = False,
18
+ ) -> None:
19
+ """
20
+ Compiles .proto files in the specified directory
21
+
22
+ :param out_dir: Directory where the compiled files will be placed.
23
+ :param proto_dirs: Directories containing .proto files which are used for generating target source codes
24
+ :param include_dirs: Directories containing .proto files which are used only in compiling
25
+ :param descriptor_path: Optional path to output the descriptor set file.
26
+ :param with_grpc: If True, also generates gRPC Python code.
27
+ :raises FileNotFoundError: If the proto directory does not exist.
28
+ """
29
+ import glob
30
+ import os
31
+ import subprocess
32
+ import sys
33
+
34
+ proto_files = []
35
+ for proto_dir in proto_dirs:
36
+ if not os.path.exists(proto_dir):
37
+ raise FileNotFoundError(f"proto directory '{proto_dir}' does not exist")
38
+ proto_files.extend(glob.glob(os.path.join(proto_dir, "**", "*.proto"), recursive=True))
39
+
40
+ if not proto_files:
41
+ print("No .proto files found")
42
+ return
43
+
44
+ cmd = [sys.executable, "-m", "grpc_tools.protoc"]
45
+
46
+ for include_dir in include_dirs:
47
+ if not os.path.exists(include_dir):
48
+ raise FileNotFoundError(f"include directory '{include_dir}' does not exist")
49
+ cmd.extend(("--proto_path", include_dir))
50
+
51
+ cmd.extend(("--python_out", out_dir))
52
+ cmd.extend(("--pyi_out", out_dir))
53
+ if with_grpc:
54
+ cmd.extend(("--grpc_python_out", out_dir))
55
+
56
+ if descriptor_path:
57
+ cmd.extend(("--descriptor_set_out",
58
+ descriptor_path,
59
+ "--include_imports",
60
+ "--include_source_info",
61
+ "--retain_options",
62
+ ))
63
+ cmd.extend(proto_files)
64
+
65
+ if not os.path.exists(out_dir):
66
+ os.makedirs(out_dir)
67
+
68
+ subprocess.check_call(cmd)
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: plexus-python-protobuf-setup
3
+ Version: 1.0.2
4
+ Classifier: Programming Language :: Python :: 3
5
+ Classifier: Programming Language :: Python :: 3.11
6
+ Classifier: Programming Language :: Python :: 3.12
7
+ Classifier: Programming Language :: Python :: 3.13
8
+ Requires-Python: <3.14,>=3.11
9
+ Requires-Dist: protobuf>=5.0
10
+ Requires-Dist: grpcio-tools>=1.71
11
+ Provides-Extra: all
12
+ Requires-Dist: plexus-python-protobuf-setup; extra == "all"
13
+ Provides-Extra: test
14
+ Requires-Dist: pytest-cov>=5.0; extra == "test"
15
+ Requires-Dist: pytest-order>=1.3; extra == "test"
16
+ Requires-Dist: pytest>=8.3; extra == "test"
@@ -0,0 +1,5 @@
1
+ plexus/protobuf/setup/__init__.py,sha256=pZfGposWx1McjwFGVdBi19yQ0ld-6sPCibCbvXDXmbg,2279
2
+ plexus_python_protobuf_setup-1.0.2.dist-info/METADATA,sha256=oA1QwkcPIZL79qPj8MOXm1t14uIKJmkyP452g_qsqp8,609
3
+ plexus_python_protobuf_setup-1.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
4
+ plexus_python_protobuf_setup-1.0.2.dist-info/top_level.txt,sha256=ug_g7CVwaMQuas5UzAXbHUrQvKGCn8ezc6ZNvvRlJOE,7
5
+ plexus_python_protobuf_setup-1.0.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+