o
    ۷i                     @  s   d dl mZ d dlZd dlZd dlmZ d dlmZ d dlZd dl	m
Z
 d dlZd dlmZ d dlmZ eejjd d	 Zed
d eddddfdddZdS )    )annotationsN)Path)	Annotated)print)custom_component_analytics)_get_executable_path	templatesfrontenddemozapp.py.	localhostappxAnnotated[Path, typer.Argument(help='The path to the app. By default, looks for demo/app.py in the current directory.')]component_directoryAnnotated[Path, typer.Option(help='The directory with the custom component source code. By default, uses the current directory.')]hostdAnnotated[str, typer.Option(help='The host to run the front end server on. Defaults to localhost.')]python_pathAnnotated[str | None, typer.Option(help='Path to python executable. If None, will use the default path found by `which python3`. If python3 is not found, `which python` will be tried. If both fail an error will be raised.')]gradio_pathAnnotated[str | None, typer.Option(help='Path to gradio executable. If None, will use the default path found by `shutil.which`.')]c           
      C  s  t dd d d d ||d | }td|  d td}|s"tdtd|dd	d
}td|dd}tj|ddgt	|d dd	d}|j
dkrJtd|jd }tj||d|dtdt| ddd|d|d|gtjtjd}	 |  |j }d }	|jr|j }	|dddddd d!}d|v r|d"t|d   d#7 }d$|v rqnt| |	rt|	d |j
d urtd% d S qo)&Ndev)r   r   z:recycle: [green]Launching[/] z in reload mode
nodez0node must be installed in order to run dev mode.pythonz--python-pathT)cli_arg_namecheck_3gradioz--gradio-path)r   z-ez/console.log(require.resolve('@gradio/preview'))r	   F)cwdcheckcapture_outputr   zYCould not find `@gradio/preview`. Run `npm i -D @gradio/preview` in your frontend folder.zutf-8z--component-directoryz--rootz--appz--modez--host)stdoutstderrzChanges detected in:z [orange3]Changed detected in:[/]z	Watching:z[orange3]Watching:[/]zRunning on local URLz[orange3]Backend Server[/]'z',zTo create a public linkz)Backend server failed to launch. Exiting.)r   resolver   shutilwhich
ValueErrorr   
subprocessrunr   
returncoder    decodestripPopengradio_template_pathstrPIPESTDOUTpollreadliner!   replace)
r   r   r   r   r   r   gradio_node_pathproctexterr r8   X/home/ubuntu/vllm_env/lib/python3.10/site-packages/gradio/cli/commands/components/dev.py_dev   s    	





r:   )
r   r   r   r   r   r   r   r   r   r   )
__future__r   r$   r'   pathlibr   typingr   typerrichr   r   gradio.analyticsr   0gradio.cli.commands.components.install_componentr   __file__parentr-   r:   r8   r8   r8   r9   <module>   s"    
	