
    ;3h:                       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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j4                        j6                  dz  dz  Z ed      ddddf	 	 	 	 	 	 	 	 	 ddZy)    )annotationsN)Path)	AnnotatedOptional)dumpparse)custom_component_analytics)get_deep)run_command)_get_executable_path)LivePanelDisplay	templatesfrontend.TFc                `   t        dd d d d ||       t        |       j                         }|dz  j                         st	        d|       t               5 }|j                  dt        |j                         dd       t        | dz  j                               }t        |d	d
g      }t        d|dd      }t        |t              st	        d      	 t        j                  |       |rt        | dz  j                               }t#        j$                  |d	   d         j'                         }
|j                  d|
 d       t        |
      |d	   d<   t)        | dz  dd      5 }t+        ||       d d d        n|d	   d   }
|j                  d|
 d       |r=t        d      j                         }d}||z  }|dz  }t-        ||d|ddd|||d |d       |rI|j                  d        | j                         }t/        j0                  d!      }|st	        d"      t3        j4                  |d#d$gt        |d%z        dd&      }|j6                  d'k7  rt	        d(      |j8                  j;                  d      j=                         }||d)|d*t>        d+dd|g
}t3        j4                  |ddd,      }|j6                  d'k7  rR|j                  d-       |j                  |j@                         |j                  |j8                         tC        d.      |j                  d/       |d0dt        |      g}|j                  d1d2jE                  |       d3       t3        j4                  |ddd,      }|j6                  d'k7  r7|j                  d-       |j                  |j@                         tC        d4      |j                  d/       |j                  d5t        |d6z         d       	 d d d        y # t         $ r}	t	        d| d      |	d }	~	ww xY w# 1 sw Y   xY w# 1 sw Y   y xY w)7Nbuild)generate_docsbump_versionz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)r-   textr,   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)pathbuild_frontendr   r   python_pathr   r   r!   package_nameer   fr&   
_demo_namer%   r'   component_directoryr*   gradio_node_path	node_cmdspipecmdss                         d/var/www/html/audio-gradio/venv/lib/python3.12/site-packages/gradio/cli/commands/components/build.py_buildrX      s   ( #! :D##++->tfEFF		 yt5c$))n5ESIUX 	 	
 '7 7BBDEF0CD*k?D
 ,,P 	##L1 "D+;$;#F#F#HIN&..y))4jl  KK6wi @h h 47w<N9%i0d--sWE (^Q'( ( %Y/	:GKKA' Kd d
 V,,.I!J"Z/J+-L!$)-# $"%#)#  KK12"&,,.<<'D K   *~~tNO,z9:#	   **a/ o   066==gFLLN  '#$I >>$TD !#89DKK(DKK( !899ABT7CI6A#((4.AQQUVW~~d4d%P??aKK45KK$233KK=>KK;Cv<N;OsSoy y" # 	1, @[ [ 	( (Ay ysK   A?P$O6,A>P$*P7I5P$6	P?PPP$P!	P$$P-)
rK   zNAnnotated[Path, typer.Argument(help='The directory of the custom component.')]rL   zLAnnotated[bool, typer.Option(help='Whether to build the frontend as well.')]r   zWAnnotated[bool, typer.Option(help='Whether to bump the version number automatically.')]r   zTAnnotated[bool, typer.Option(help='Whether to generate the documentation as well.')]rM   zAnnotated[Optional[str], 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.')])
__future__r   r8   r?   rA   pathlibr   typingr   r   r;   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__parentrG   rX        rW   <module>rh      s    "     &     7 < Q 8FOO,33kAJN  	S	 	 	 	 	%ZZ	ZZZZrg   