-
Notifications
You must be signed in to change notification settings - Fork 11
/
setup.py
45 lines (36 loc) · 1.39 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from shlex import split
from subprocess import CalledProcessError, check_call
from textwrap import dedent
from setuptools import setup
from setuptools.command.build_py import build_py
from setuptools.errors import SetupError
class BuildPyAndGenerateGrpc(build_py):
"""build python module using protoc to prepare generated files."""
proto_source = "vllm_tgis_adapter/grpc/pb/generation.proto"
def run(self):
print(f"Invoking protoc on {self.proto_source}")
# NOTE: imports in generated files will be broken unless some care is given in
# how --proto_path, --*_out and .proto paths are given.
#
# See https://github.com/grpc/grpc/issues/9575#issuecomment-293934506
try:
check_call(
split(
dedent(
f"""
python -m grpc_tools.protoc \
--proto_path=src \
--python_out=src/ \
--grpc_python_out=src/ \
--mypy_out=src/ \
{self.proto_source}
""",
),
)
)
except CalledProcessError as exc:
raise SetupError(f"protoc failed, exit code {exc.returncode}") from exc
super().run()
setup(
cmdclass={"build_py": BuildPyAndGenerateGrpc},
)