o
    
۾i                     @   s<   d Z ddlZddlmZ dd Zedkree  dS dS )a  
Compile vLLM protobuf definitions into Python code.

This script uses grpcio-tools to generate *_pb2.py, *_pb2_grpc.py, and
*_pb2.pyi (type stubs) files from the vllm_engine.proto definition.

NOTE: Proto compilation happens automatically during package build (via setup.py).
This script is provided for developers who want to regenerate protos manually,
e.g., after modifying vllm_engine.proto.

Usage:
    python vllm/grpc/compile_protos.py

Requirements:
    pip install grpcio-tools
    N)Pathc            
   
   C   s  t tj} | jj}| d }| std|  dS td|  td|   zzddlm} |dd	| d
| d| d| t| d g}|dkrd}| d | d | d fD ]}| ru|	 }|
dsu|d }|||  q[td td| d   td| d   td| d  d W dS td|  |W S  ty   td td Y dS  ty }	 ztd|	  W Y d}	~	dS d}	~	ww )zCompile protobuf definitions.zvllm_engine.protozError: Proto file not found at    zCompiling protobuf: zOutput directory: r   )protoczgrpc_tools.protocz--proto_path=z--python_out=z--grpc_python_out=z
--pyi_out=zk# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
zvllm_engine_pb2.pyzvllm_engine_pb2_grpc.pyzvllm_engine_pb2.pyiz# SPDX-License-Identifierz# mypy: ignore-errors
u$   ✓ Protobuf compilation successful!z  Generated: z (type stubs)zError: protoc returned z!Error: grpcio-tools not installedz&Install with: pip install grpcio-toolszError during compilation: N)r   __file__parentexistsprint
grpc_toolsr   mainstr	read_text
startswith
write_textImportError	Exception)

script_dirvllm_package_root
proto_filer   resultspdx_headergenerated_filecontentheadere r   L/home/ubuntu/.local/lib/python3.10/site-packages/vllm/grpc/compile_protos.pycompile_protos   s`   


r   __main__)__doc__syspathlibr   r   __name__exitr   r   r   r   <module>   s   D