
    .Ph7                       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 e%D             Z& ej'        de%          Z(d_dZ)d`dad Z*	 	 dbdcd*Z+ ej,                    j-        d+z
  Z.e.d k    rd,Z. eej/        d-e..          Z0dd/ddd2Z1ded4Z2dfdgd7Z3dhd:Z4didDZ5	 djdkdHZ6dldJZ7ej8        dmdL            Z9dndNZ:	 	 	 	 dodpdSZ;	 	 	 	 dodpdTZ<dqdVZ=drdsdYZ>d_dZZ?e@d[k    r e>e	jA        dd         d\           d]d^gZBdS )t    )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                    i | ]}|d S )  ).0colors     N/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/build/__main__.py
<dictcomp>r!   (   s    ---EeR---    _styles)defaultreturnNonec                 D   dt           j        v rDdt           j        v rt          j        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    _init_colorsr5   .   s    RZBJ&&MhuvwwwwJ	"*	$	$
(9(9(;(;	$KK
r"   r   fmtstrmsgfileTextIO | Nonec                p    t           | j        |fi t                                          |d           d S )NT)r9   flush)printformatr#   get)r6   r8   r9   s      r    _cprintr@   8   s9    	*#*S
*
*GKKMM
*
*TBBBBBBr"   messageWarning | strcategorytype[Warning]filenamelinenointline
str | Nonec                @    t          dt          |                      d S )Nz{yellow}WARNING{reset} {})r@   r7   )rA   rC   rE   rF   r9   rH   s         r    _showwarningrK   <   s!     'W66666r"   r*   N     )subsequent_indentwidth)originrP   tuple[str, ...] | Nonec                  |Z|                                  ^}}t          dt          |d                     |D ] }t          t          |d                     !d S |d         dk    rb|d         dk    rd	nd
}|d         dk    rt          j        nd }|                                  D ]%}t          dt          ||          |           $d S d S )Nz{bold}{}{reset}z* )initial_indentrM   r   
subprocessr	   cmdz> z< stderrz{dim}{}{reset})r9   )
splitlinesr@   _fillr=   r2   rV   )rA   rP   firstrestrH   rS   r9   s          r    _logr[   O   s
   ~ ++--!5t#D#D#DEEE 	4 	4D%T2223333	4 	4 
l	"	"!'e!3!3#AY(22szz&&(( 	] 	]D$eD&P&P&PW[\\\\\	 
#	"	] 	]r"   	verbosityc                L   t           t          _        t          j                    dk    r*	 dd l}|                                 n# t          $ r Y nw xY wt                       t          j
                            t                     t          j                            |            d S )NWindowsr   )rK   r.   showwarningplatformsystemcoloramainitModuleNotFoundErrorr5   r   LOGGERr0   r[   	VERBOSITY)r\   rb   s     r    
_setup_clirg   ]   s    'HI%%	OOOMMOOOO" 	 	 	D	 NNNKOODNy!!!!!s   A 
AAcoder   c                @    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)r8   rh   s     r    _errorrk   n   s#     "C(((
T

r"   	dep_chainSequence[str]c                @    d                     d | D                       S )Nz -> c              3  p   K   | ]1}|                     d           d                                         V  2dS );r   N)	partitionstrip)r   deps     r    	<genexpr>z$_format_dep_chain.<locals>.<genexpr>z   s?      JJs}}S))!,2244JJJJJJr"   )join)rl   s    r    _format_dep_chainrv   y   s#    ;;JJ	JJJJJJr"   srcdirr   outdirdistributionr   config_settingsConfigSettings | None	installer_env.Installerc                <   t          |          5 }t          j        ||           }|                    |j                   |                    |                    ||pi                      |                    |||pi           cd d d            S # 1 swxY w Y   d S )N)r|   )r   r
   from_isolated_envinstallbuild_system_requiresget_requires_for_buildbuild)rw   rx   ry   rz   r|   r   builders          r    _build_in_isolated_envr   }   s     
i	0	0	0 JC 23??G1222G22<AVTVWWXXX}}\6?3HbIIJ J J J J J J J J J J J J J J J J Js   A3BBBFskip_dependency_checkboolc                   t          |           }|sY|                    ||pi           }|r?d                    d |D                       }t                       t	          d|            |                    |||pi           S )Nr   c              3  h   K   | ]-}|d          t          |dd                   fD ]}|d|z   V  .dS )r   r	   Nz
	)rv   )r   depsrs   s      r    rt   z(_build_in_current_env.<locals>.<genexpr>   s[      "}"}DPTUVPWYjkopqprprksYtYtOu"}"}y|"}6C<"}"}"}"}"}"}"}r"   zMissing dependencies:)r
   check_dependenciesru   r@   rk   r   )rw   rx   ry   rz   r   r   missingdependenciess           r    _build_in_current_envr      s     V$$G  ;,,\?;PbQQ 	;77"}"}G"}"}"}}}LIII9<99:::==v/D"EEEr"   	isolationc                R    | rt          |||||          S t          |||||          S N)r   r   )r   rw   rx   ry   rz   r   r|   s          r    _buildr      s;      k%fflOU^___$VV\?Tijjjr"   Iterator[None]c               #  ^  K   	 d V  d S # t           t          f$ r'} t          t          |                      Y d } ~ d S d } ~ wt          $ r} t          | j        t          j                  r*t                       t          t          |                      | j
        rOt          j        | j
        d         | j
        d         | j
        d         d          }d                    |          }nt          j        d          }t          d|                    d                     t          t          |                      Y d } ~ d S d } ~ wt           $ r]} t          j                                        d          }t          d|           t          t          |                      Y d } ~ d S d } ~ ww xY w)	Nr   r	   r*   )limitr   z
{dim}{}{reset}

)r   r   rk   r7   r   
isinstance	exceptionrT   CalledProcessErrorr@   exc_info	tracebackformat_exceptionru   
format_excrr   	Exception)etb_linestbs      r    _handle_build_errorr      s     ./   s1vv    ak:#@AA 	III3q66NNN: 		* 1
1
1
1	  H ""BB%b))B$bhhtnn555s1vv   !##))$//$b)))s1vvs,   
 F,=F,
C2EF,AF''F,elementsc                    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
IndexErrorr>   ru   )r   r8   s     r    _natural_language_listr      su    
8}}oo	X!		{!!IIhssm$$RL
 
 	
r"   TpipdistributionsSequence[Distribution]c           
         g }|D ]I}t          || |||||          }	|                    t          j                            |	                     J|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)
rw   rx   r   rz   r   r   r|   builtry   outs
             r    build_packager      s]    & E% , ,YoOdfoppRW%%c**++++Lr"   c                $   ddl m} d|v rd}t          |          t          || |d|||          }	t          j                            |	          }
t          j        d          }g }|r#|j	        
                    |	          5 }|                    |           	 t          j        dt          |           d           t          j                            ||
d	t!          d
                              } |D ]I}t          || |||||          }|                    t          j                            |                     J	 t%          j        |d           n# t%          j        |d           w xY w	 d	d	d	           n# 1 swxY w 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   ru   r   r   shutilrmtree)rw   rx   r   rz   r   r   r|   r   r8   r   
sdist_name	sdist_outr   try   r   s                   r    build_package_via_sdistr      s   & !     -Moo9ffgH]_hiiE!!%((J (:;;;IE =_!!%(( 		=ALL###=W%;M%J%JWWWXXXi<Ms9~~o<M1NOO$1 8 8L FFL/[pr{||CLL!1!1#!6!677778 it<<<<<it<<<<<<		= 		= 		= 		= 		= 		= 		= 		= 		= 		= 		= 		= 		= 		= 		= s+   FB'EFE22FF	Fargparse.ArgumentParserc                    t          j        t          j        t          j        d                                          d          t          t           j        t          t          d                              } | 
                    dt          dt          j                    d	           | 
                    d
dddt          j         dd                    t          j                   d           | 
                    dddddd           | 
                    dddddd           | 
                    d d!ddd"d#           | 
                    d$d%t          d&t          j         d'd()           | 
                    d*d+d,d-.           |                                 }|
                    d/d0d,d1.           |
                    d2t(          j        d34           | 
                    d5d6d7d8d9d:;           | 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       )rO   )descriptionformatter_classrw   ?z0source directory (defaults to current directory))typenargsr$   helpz	--versionz-Vversionzbuild z (,))actionr   z	--verbosez-vr\   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-Crz   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dedentrr   r   RawDescriptionHelpFormattermin_max_terminal_widthadd_argumentr7   r,   getcwdr   __version__ru   __path__sepadd_mutually_exclusive_group_env
INSTALLERS)parser	env_groups     r    main_parserr      s    $OO  egg!
 
(   DCPcehLiLijjj+  F. 	?     I*IIchhu~.F.FIII	     !     J     <     EEEE     !A	     3355IS	     @    
 [   	 	 	 Mr"   cli_argsprogc           
         t                      }|r||_        |                    |           }t          |j                   i }|j        ro|j        D ]g}|                    d          \  }}}||vr|||<   %t          ||         t                    s||         g||<   ||         	                    |           h|j
        %t          j                            |j        d          n|j
        }	|j        }
|
rt           }n
t"          }dg}
t%                      5   ||j        |	|
||j         |j        |j                  }t-          d |D                       }t/          d|           ddd           dS # 1 swxY w 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
    )r\   =Ndistr   c                X    g | ]'} d j         |fi t                                          (S )z!{underline}{}{reset}{bold}{green})r>   r#   r?   )r   artifacts     r    
<listcomp>zmain.<locals>.<listcomp>  s8    iiiW_707RRGKKMMRRiiir"   z){bold}{green}Successfully built {}{reset})r   r   
parse_argsrg   r\   rz   rq   r   listr   rx   r,   r   ru   rw   r   r   r   r   no_isolationr   r|   r   r@   )r   r   r   argsrz   argsetting_valuerx   r   
build_callr   artifact_lists                 r    mainr    s    ]]F X&&D((((O 	7' 	7 	7C #c 2 2GQo--+0((!/'":DAA J0?0H/IOG,(//6666 37+2ERW\\$+v...4;F(,(:M ""

,
 				 L L
K!!&N
 
 /iichiii
 
 	;]KKKL L L L L L L L L L L L L L L L L Ls   AE33E7:E7c                 H    t          t          j        dd                     d S )Nr	   )r  r2   argvr   r"   r    
entrypointr    s     !""r"   __main__zpython -m buildr  r   )r%   r&   )r   r   N)r6   r7   r8   r7   r9   r:   r%   r&   )NN)rA   rB   rC   rD   rE   r7   rF   rG   r9   r:   rH   rI   r%   r&   )rA   r7   rP   rQ   r%   r&   )r\   rG   r%   r&   )r	   )r8   r7   rh   rG   r%   r   )rl   rm   r%   r7   )rw   r   rx   r   ry   r   rz   r{   r|   r}   r%   r7   )F)rw   r   rx   r   ry   r   rz   r{   r   r   r%   r7   )r   r   rw   r   rx   r   ry   r   rz   r{   r   r   r|   r}   r%   r7   )r%   r   )r   rm   r%   r7   )NTFr   )rw   r   rx   r   r   r   rz   r{   r   r   r   r   r|   r}   r%   rm   )r%   r   r   )r   rm   r   rI   r%   r&   )C
__future__r   r   
contextlibcontextvarsr,   r`   r   rT   r2   r   r   r   r.   collections.abcr   r   	functoolsr   typingr   r   r   r   r
   r   r   r   _exceptionsr   r   r   _typesr   r   r   r   _COLORSr1   
ContextVarr#   r5   r@   rK   get_terminal_sizecolumnsr   fillrX   r[   rg   rk   rv   r   r   r   contextmanagerr   r   r   r   r   r  r  __name__r  __all__r   r"   r    <module>r     s   # " " " " "          				       



        . . . . . . . .       # # # # # # # #  " " " " " " " "       R R R R R R R R R R 9 9 9 9 9 9 9 9 9 9 # # # # # #   .-W---
 !+
 G
<
<
<   C C C C C 7 7 7 7 7 /f.0081< ! 	=PQQQ <@ ] ] ] ] ] ]" " " ""    K K K KJ J J J* #(F F F F F&k k k k    8

 

 

 

" .2"' %    < .2"' %*  *  *  *  * Zd d d dN2L 2L 2L 2L 2Lj    zD!""())) r"   