
    Pi=                       d dl mZ d dl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
Z
d dlmZmZ d dlZd dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ  eej                  j        dz  dz  Z ed          ddddfddZdS )    )annotationsN)Path)	Annotated)dumpparse)custom_component_analytics)get_deep)run_command)_get_executable_path)LivePanelDisplay	templatesfrontend.TFpathNAnnotated[Path, typer.Argument(help='The directory of the custom component.')]build_frontendLAnnotated[bool, typer.Option(help='Whether to build the frontend as well.')]bump_versionWAnnotated[bool, typer.Option(help='Whether to bump the version number automatically.')]generate_docsTAnnotated[bool, typer.Option(help='Whether to generate the documentation as well.')]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.')]c                	   t          dd d d d ||           t          |                                           }|dz                                  st	          d|           t                      5 }|                    dt          |j                   dd           t          | dz  
                                          }t          |d	d
g          }t          d|dd          }t          |t                    st	          d          	 t          j        |           n&# t           $ r}	t	          d| d          |	d }	~	ww xY w|rt          | dz  
                                          }t#          j        |d	         d                                                   }
|                    d|
 d           t          |
          |d	         d<   t)          | dz  dd          5 }t+          ||           d d d            n# 1 swxY w Y   n'|d	         d         }
|                    d|
 d           |rIt          d                                          }d}||z  }|dz  }t-          ||d|ddd|||d |d           |r`|                    d            |                                 }t/          j        d!          }|st	          d"          t3          j        |d#d$gt          |d%z            dd&          }|j        d'k    rt	          d(          |j                            d                                          }||d)|d*t>          d+dd|g
}t3          j        |ddd,          }|j        d'k    rX|                    d-           |                    |j                    |                    |j                   tC          d.          |                    d/           |d0dt          |          g}|                    d1d2"                    |           d3           t3          j        |ddd,          }|j        d'k    r>|                    d-           |                    |j                    tC          d4          |                    d/           |                    d5t          |d6z             d           	 d d d            d S # 1 swxY w Y   d S )7Nbuild)r   r   zpyproject.tomlz#Cannot find pyproject.toml file in z':package: Building package in [orange3]z[/]g?)	add_sleepprojectnamepythonz--python-pathT)check_3z>Your pyproject.toml file does not have a [project] name field!zYour custom component package (z\) is not installed! Please install it with the gradio cc install command before building it.versionz$:1234: Using version [bold][magenta]z][/][/]. Set [bold][magenta]--no-bump-version[/][/] to use the version in pyproject.toml file.wzutf-8)encodingz/:1234: Package will use version [bold][magenta]zx[/][/] defined in pyproject.toml file. Set [bold][magenta]--bump-version[/][/] to automatically bump the version number.demozapp.pyz	README.mdFsimple)liver   suppress_demo_checkpyproject_tomlgenerate_spacegenerate_readme	type_mode
_demo_path	_demo_dir_readme_path	space_url_component_dirr%   z:art: Building frontendnodez5node must be installed in order to run build command.z-ez/console.log(require.resolve('@gradio/preview'))r   )cwdcheckcapture_outputr   zYCould not find `@gradio/preview`. Run `npm i -D @gradio/preview` in your frontend folder.z--component-directoryz--rootz--mode)r4   textr3   z:red_square: Build failed!zFrontend build failedz#:white_check_mark: Build succeeded!z-mz+:construction_worker: Building... [grey37]( z)[/]zPython build failedz):ferris_wheel: Wheel located in [orange3]dist)#r   r   resolveexists
ValueErrorr   updatestrr   r   	read_textr	   r   
isinstance	importlibimport_moduleModuleNotFoundErrorsemantic_versionVersion
next_patchopenr   r
   shutilwhich
subprocessrun
returncodestdoutdecodestripgradio_template_pathstderr
SystemExitjoin)r   r   r   r   r   r   r&   r(   package_nameer!   fr-   
_demo_namer,   r.   component_directoryr1   gradio_node_path	node_cmdspipecmdss                         x/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/gradio/cli/commands/components/build.py_buildr\      sX   ( #!    ::D##++-- GEtEEFFF			 ytIc$)nnIIIUX 	 	
 	
 	
 '7 7BBDDEEF0CDD*k?D
 
 
 ,,, 	P  	#L1111" 	 	 	[, [ [ [  	
  	"D+;$;#F#F#H#HIIN&.y))4 jll  KKhw h h h   47w<<N9%i0d--sWEEE (^Q'''( ( ( ( ( ( ( ( ( ( ( ( ( ( ( %Y/	:GKKd' d d d  
  	V,,..I!J"Z/J+-L!$)-# $"%#)#      -	CKK1222"&,,..<''D  K    *~tNO,z9::#	       *a// o    06==gFFLLNN  '#$I >$T  D !##8999DK(((DK((( !8999ABBBT7CII6V#((4..VVVWWW~d4d%PPP?aKK4555KK$$$2333KK=>>>KKSCv<N<NSSS   oy y y y y y y y y y y y y y y y y ys]   /BSD S 
E*D>>EB!S$H5SH	SH		J7SSS)
r   r   r   r   r   r   r   r   r   r   )
__future__r   r?   rF   rH   pathlibr   typingr   rB   typertomlkitr   r   gradiogradio.analyticsr   *gradio.cli.commands.components._docs_utilsr	   #gradio.cli.commands.components.docsr
   0gradio.cli.commands.components.install_componentr   gradio.cli.commands.displayr   __file__parentrN   r\        r[   <module>rl      sd   " " " " " "                                    7 7 7 7 7 7      < ; ; ; ; ; Q Q Q Q Q Q 8 8 8 8 8 8tFO,,3kAJN  	S		 	 	 	 	%Z Z Z Z Z Z Zrk   