o
    Vh7                     @  sN  d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlmZmZ d dlmZ d dlmZmZ d dlZddlmZmZ ddlmZ dd	lmZmZmZ dd
l m!Z!m"Z"m#Z# ddlm$Z$ ddddddddZ%dd e%D Z&ej'de%dZ(doddZ)dpdqd"d#Z*		drdsd-d.Z+e, j-d/ Z.e.d krd0Z.eej/d1e.d2Z0dd3dtd6d7Z1dud9d:Z2dvdwd=d>Z3dxdAdBZ4dydLdMZ5	Ndzd{dQdRZ6d|dTdUZ7ej8d}dWdXZ9d~dZd[Z:		\	N	]ddd`daZ;		\	N	]dddbdcZ<ddedfZ=dddidjZ>dodkdlZ?e@dmkr!e>e	jAdd dn djdfgZBdS )    )annotationsN)IteratorSequence)partial)NoReturnTextIO   )ProjectBuilder_ctx)env)BuildBackendExceptionBuildExceptionFailedProcessError)ConfigSettingsDistributionStrPath)DefaultIsolatedEnvz[91mz[92mz[93mz[1mz[2mz[4mz[0m)redgreenyellowbolddim	underlineresetc                 C  s   i | ]}|d qS )  ).0colorr   r   b/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/build/__main__.py
<dictcomp>(   s    r   _styles)defaultreturnNonec                   C  sT   dt jv rdt jv rtjddd tt ndt jv s!tj	 r#d S tt d S )NNO_COLORFORCE_COLORzLBoth NO_COLOR and FORCE_COLOR environment variables are set, disabling color   )
stacklevel)
osenvironwarningswarnr    set
_NO_COLORSsysstdoutisattyr   r   r   r   _init_colors.   s   

r1   r   fmtstrmsgfileTextIO | Nonec                 C  s$   t | j|fi t |dd d S )NT)r5   flush)printformatr    get)r2   r4   r5   r   r   r   _cprint8   s   $r;   messageWarning | strcategorytype[Warning]filenamelinenointline
str | Nonec                 C  s   t dt|  d S )Nz{yellow}WARNING{reset} {})r;   r3   )r<   r>   r@   rA   r5   rC   r   r   r   _showwarning<   s   rE   r&   N     )subsequent_indentwidth)originrJ   tuple[str, ...] | Nonec                C  s   |d u r"|   ^}}tdt|dd |D ]
}tt|dd qd S |d dkrO|d dkr0d	nd
}|d dkr;tjnd }|   D ]}tdt||d|d qAd S d S )Nz{bold}{}{reset}z* )initial_indentrG   r   
subprocessr   cmdz> z< stderrz{dim}{}{reset})r5   )
splitlinesr;   _fillr8   r.   rO   )r<   rJ   firstrestrC   rL   r5   r   r   r   _logO   s   rT   	verbosityc                 C  s\   t t_t dkrz
dd l}|  W n	 ty   Y nw t  t	j
t t	j|  d S )NWindowsr   )rE   r*   showwarningplatformsystemcoloramainitModuleNotFoundErrorr1   r
   LOGGERr,   rT   	VERBOSITY)rU   rZ   r   r   r   
_setup_cli]   s   r_   coder   c                 C  s   t d|  t|)z
    Print an error message and exit. Will color the output when writing to a TTY.

    :param msg: Error message
    :param code: Error code
    z{red}ERROR{reset} {})r;   
SystemExit)r4   r`   r   r   r   _errorn   s   
rb   	dep_chainSequence[str]c                 C  s   d dd | D S )Nz -> c                 s  s"    | ]}| d d  V  qdS );r   N)	partitionstrip)r   depr   r   r   	<genexpr>z   s     z$_format_dep_chain.<locals>.<genexpr>)join)rc   r   r   r   _format_dep_chainy   s   rk   srcdirr   outdirdistributionr   config_settingsConfigSettings | None	installer_env.Installerc                 C  sn   t |d(}t|| }||j ||||pi  ||||p$i W  d    S 1 s0w   Y  d S )N)rq   )r   r	   from_isolated_envinstallbuild_system_requiresget_requires_for_buildbuild)rl   rm   rn   ro   rq   r   builderr   r   r   _build_in_isolated_env}   s   $ry   Fskip_dependency_checkboolc                 C  sZ   t | }|s$|||pi }|r$ddd |D }t  td|  ||||p+i S )Nr   c                 s  s:    | ]}|d  t |dd fD ]	}|rd| V  qqdS )r   r   Nz
	)rk   )r   depsrh   r   r   r   ri      s   8 z(_build_in_current_env.<locals>.<genexpr>zMissing dependencies:)r	   check_dependenciesrj   r;   rb   rw   )rl   rm   rn   ro   rz   rx   missingdependenciesr   r   r   _build_in_current_env   s   r   	isolationc                 C  s$   | r
t |||||S t|||||S N)ry   r   )r   rl   rm   rn   ro   rz   rq   r   r   r   _build   s   	r   Iterator[None]c               
   c  s.   zd V  W d S  t tfy" }  ztt|  W Y d } ~ d S d } ~ w tyr }  zEt| jtjr9t	  tt|  | j
rTtj| j
d | j
d | j
d dd}d|}ntd}t	d|d tt|  W Y d } ~ d S d } ~ w ty }  zt d}t	d| tt|  W Y d } ~ d S d } ~ ww )	Nr   r   r&   )limitr   z
{dim}{}{reset}

)r   r   rb   r3   r   
isinstance	exceptionrM   CalledProcessErrorr;   exc_info	tracebackformat_exceptionrj   
format_excrg   	Exception)etb_linestbr   r   r   _handle_build_error   s8   

r   elementsc                 C  sJ   t | dkrd}t|t | dkr| d S dd| d d | d S )Nr   zno elementsr   z	{} and {}z, r   )len
IndexErrorr9   rj   )r   r4   r   r   r   _natural_language_list   s   r   TpipdistributionsSequence[Distribution]c           
   	   C  s8   g }|D ]}t || |||||}	|tj|	 q|S )a  
    Run the build process.

    :param srcdir: Source directory
    :param outdir: Output directory
    :param distribution: Distribution to build (sdist or wheel)
    :param config_settings: Configuration settings to be passed to the backend
    :param isolation: Isolate the build in a separate environment
    :param skip_dependency_check: Do not perform the dependency check
    )r   appendr(   pathbasename)
rl   rm   r   ro   r   rz   rq   builtrn   outr   r   r   build_package   s
   r   c                 C  s  ddl m} d|v rd}t|t|| |d|||}	tj|	}
tjdd}g }|r|j	
|	P}|| z:tdt| d tj||
d	td
  } |D ]}t|| |||||}|tj| qRW tj|dd ntj|dd w W d	   n1 sw   Y  |
g|S )a  
    Build a sdist and then the specified distributions from it.

    :param srcdir: Source directory
    :param outdir: Output directory
    :param distribution: Distribution to build (only wheel)
    :param config_settings: Configuration settings to be passed to the backend
    :param isolation: Isolate the build in a separate environment
    :param skip_dependency_check: Do not perform the dependency check
    r   )tarfilesdistz=Only binary distributions are allowed but sdist was specifiedzbuild-via-sdist-)prefixz	Building z from sdistNz.tar.gzT)ignore_errors)_compatr   
ValueErrorr   r(   r   r   tempfilemkdtempTarFileopen
extractallr
   logr   rj   r   r   shutilrmtree)rl   rm   r   ro   r   rz   rq   r   r4   r   
sdist_name	sdist_outr   trn   r   r   r   r   build_package_via_sdist   s*   
"

r   argparse.ArgumentParserc               
   C  s*  t jttd dtt jtt	ddd} | j
dtdt dd	 | j
d
dddtj ddtj dd | j
ddddddd | j
ddddddd | j
d d!ddd"d#d | j
d$d%td&tj d'd(d) | j
d*d+d,d-d. |  }|j
d/d0d,d1d. |j
d2tjd3d4 | j
d5d6d7d8d9d:d; | S )<z$
    Construct the main parser.
    a  
                A simple, correct Python build frontend.

                By default, a source distribution (sdist) is built from {srcdir}
                and a binary distribution (wheel) is built from the sdist.
                This is recommended as it will ensure the sdist can be used
                to build wheels.

                Pass -s/--sdist and/or -w/--wheel to build a specific distribution.
                If you do this, the default behavior will be disabled, and all
                artifacts will be built from {srcdir} (even if you combine
                -w/--wheel with -s/--sdist, the wheel will be built from {srcdir}).
                z       )rI   )descriptionformatter_classrl   ?z0source directory (defaults to current directory))typenargsr!   helpz	--versionz-Vversionzbuild z (,))actionr   z	--verbosez-vrU   countr   zincrease verbosity)destr   r!   r   z--sdistz-sr   append_constr   z;build a source distribution (disables the default behavior))r   r   constr   z--wheelz-wwheelz-build a wheel (disables the default behavior)z--outdirz-oz&output directory (defaults to {srcdir}zdist)PATH)r   r   metavarz--skip-dependency-checkz-x
store_truez2do not check that build dependencies are installed)r   r   z--no-isolationz-nzdisable building the project in an isolated virtual environment. Build dependencies must be installed separately when this option is usedz--installerz1Python package installer to use (defaults to pip))choicesr   z--config-settingz-Cro   r   zsettings to pass to the backend.  Multiple settings can be provided. Settings beginning with a hyphen will erroneously be interpreted as options to build if separated by a space character; use ``--config-setting=--my-setting -C--my-other-setting``zKEY[=VALUE])r   r   r   r   )argparseArgumentParsertextwrapindentdedentrg   r   RawDescriptionHelpFormattermin_max_terminal_widthadd_argumentr3   r(   getcwdrw   __version__rj   __path__sepadd_mutually_exclusive_group_env
INSTALLERS)parser	env_groupr   r   r   main_parser   s   
r   cli_argsprogc              	   C  s(  t  }|r||_|| }t|jd i }|jrD|jD ](}|d\}}}||vr.|||< qt|| ts<|| g||< || 	| q|j
du rQtj|jdn|j
}	|j}
|
r\t}nt}dg}
t & ||j|	|
||j |j|j}tdd |D }td| W d   dS 1 sw   Y  dS )	z
    Parse the CLI arguments and invoke the build process.

    :param cli_args: CLI arguments
    :param prog: Program name to show in help text
    )rU   =Ndistr   c                 S  s"   g | ]}d j |fi t qS )z!{underline}{}{reset}{bold}{green})r9   r    r:   )r   artifactr   r   r   
<listcomp>  s   " zmain.<locals>.<listcomp>z){bold}{green}Successfully built {}{reset})r   r   
parse_argsr_   rU   ro   rf   r   listr   rm   r(   r   rj   rl   r   r   r   r   no_isolationrz   rq   r   r;   )r   r   r   argsro   argsetting_valuerm   r   
build_callr   artifact_listr   r   r   main  sF   


 	"r   c                   C  s   t tjdd   d S )Nr   )r   r.   argvr   r   r   r   
entrypoint  s   r   __main__zpython -m build)r"   r#   )r   r   N)r2   r3   r4   r3   r5   r6   r"   r#   )NN)r<   r=   r>   r?   r@   r3   rA   rB   r5   r6   rC   rD   r"   r#   )r<   r3   rJ   rK   r"   r#   )rU   rB   r"   r#   )r   )r4   r3   r`   rB   r"   r   )rc   rd   r"   r3   )rl   r   rm   r   rn   r   ro   rp   rq   rr   r"   r3   )F)rl   r   rm   r   rn   r   ro   rp   rz   r{   r"   r3   )r   r{   rl   r   rm   r   rn   r   ro   rp   rz   r{   rq   rr   r"   r3   )r"   r   )r   rd   r"   r3   )NTFr   )rl   r   rm   r   r   r   ro   rp   r   r{   rz   r{   rq   rr   r"   rd   )r"   r   r   )r   rd   r   rD   r"   r#   )C
__future__r   r   
contextlibcontextvarsr(   rX   r   rM   r.   r   r   r   r*   collections.abcr   r   	functoolsr   typingr   r   rw   r   r	   r
   r   r   _exceptionsr   r   r   _typesr   r   r   r   _COLORSr-   
ContextVarr    r1   r;   rE   get_terminal_sizecolumnsr   fillrQ   rT   r_   rb   rk   ry   r   r   contextmanagerr   r   r   r   r   r   r   __name__r   __all__r   r   r   r   <module>   s   	

	





-g
5
