
    ZjQ                       d dl mZ g d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Zd dlmZ d dlmZmZmZ d dlZd dlZd dlmZ d dlmZmZ d dlmZmZm Z  d dlm!Z! d	Z"e"rd d
l#m$Z$m%Z%m&Z& d dl'm(Z(m)Z)m*Z*m+Z+ ddddddddZ,e-.                    e,d          Z/ ej0        de,          Z1dbdZ2dcdddZ3	 	 dedfd)Z4dgd+Z5dhd-Z6didjd1Z7dkd4Z8ej9        	 dldmdE            Z:dndGZ;ej9        dodI            Z<dpdLZ=	 	 	 	 	 dqdrdRZ>	 	 	 	 	 dqdrdSZ?	 	 	 	 	 dqdrdTZ@dsdVZAdtdYZBdldud\ZCdbd]ZDeEd^k    r eCejF        d.d         d_           d`dagZGdS )v    )annotations)argparsezbuild._exceptionsz	build.env	functoolsjsonosplatformpyproject_hooksshutil
subprocesstempfiletextwrap	tracebacktypingwarningsN)partial)AnyNoReturnTextIO)ProjectBuilder_ctx)BuildBackendExceptionBuildExceptionFailedProcessError)DefaultIsolatedEnvF)IteratorMappingSequence)ConfigSettingsDistributionStrPathSubprocessRunnerz[91mz[92mz[93mz[1mz[2mz[4mz[0m)redgreenyellowbolddim	underlinereset _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)
r   environr   warnr*   set
_NO_COLORSsysstdoutisatty     K/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/build/__main__.py_init_colorsr=   J   s    RZBJ&&MhuvwwwwJ	"*	$	$
(9(9(;(;	$KK
r;   fmtstrmsgfileTextIO | Nonec                p    t           | j        |fi t                                          |d           d S )NT)rA   flush)printformatr*   get)r>   r@   rA   s      r<   _cprintrH   T   s9    	*#*S
*
*GKKMM
*
*TBBBBBBr;   messageWarning | strcategorytype[Warning]filenamelinenointline
str | Nonec                B    t          dt          |           |           d S )Nz{yellow}WARNING{reset} {})rH   r?   )rI   rK   rM   rN   rA   rP   s         r<   _showwarningrS   X   s#     'Wt<<<<<r;   _ctx.Loggerc                     t          j                    j        dz
  } | dk    rd} t          t          j        d|           d ddfd}|S )Nr1   r   N     )subsequent_indentwidthkindrI   r?   r[   tuple[str, ...] | Noner,   r-   c                  t           j        dk    rd|x  r~ dk    rxxd         dk    rl  |                                 ^}}t          d |d          t          j                   |D ](}t           |d	          t          j                   )d S  x  rS d
k    rM\  dk    rFdk    rB |                                 D ])}t          d |d          t          j                   *d S    r^ d
k    rX\  dk    rQxdk    rn	xdk    rn nB |                                 D ])}t          d |d          t          j                   *d S  	 t           | d	          t          j                   d S d S )N   r   stepz{bold}{}{reset}z* )initial_indentrA   rW   r1   r   cmdz{dim}{}{reset}z> r8   stderrz< )r   	verbosity
splitlinesrH   r7   rd   rE   )rI   r[   firstrestrP   fills        r<   logz_make_logger.<locals>.logj   s   >R!\\\\\\\\\fffff%,%7%7%9%9NUT-ttE$/O/O/OVYV`aaaa $ P Pdd4===CJOOOOOP P "
 +*******lllEEEE ' 2 2 4 4 d d 0$$tD2Q2Q2QX[Xbcccccd d + 9888888lllHHHHHxxxxxxxx ' 2 2 4 4 d d 0$$tD2Q2Q2QX[Xbcccccd d 9 $$wt<<<3:NNNNNN  r;   )rI   r?   r[   r\   r,   r-   )r
   get_terminal_sizecolumnsr   r   ri   )max_terminal_widthrj   ri   s     @r<   _make_loggerrn   c   s|    133;a?Q8=D@RSSSD<@ O O O O O O O O" Jr;   re   c                Z   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   )rS   r   showwarningr   systemcoloramainitModuleNotFoundErrorr=   r   LOGGERr5   rn   	VERBOSITY)re   rs   s     r<   
_setup_clirx   ~   s    'HI%%	OOOMMOOOO" 	 	 	D	 NNNKOOLNN###Ny!!!!!s   A 
AAr_   coder   c                X    t          d| t          j                   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} {}rb   )rH   r7   rd   
SystemExit)r@   ry   s     r<   _errorr|      s*     "Ccj9999
T

r;   	dep_chaintuple[str, ...]c                @    d                     d | D                       S )Nz -> c              3  p   K   | ]1}|                     d           d                                         V  2dS );r   N)	partitionstrip).0deps     r<   	<genexpr>z$_format_dep_chain.<locals>.<genexpr>   s?      JJs}}S))!,2244JJJJJJr;   )join)r}   s    r<   _format_dep_chainr      s#    ;;JJ	JJJJJJr;   	isolationboolsrcdirr    distributionr   config_settingsConfigSettings | Noneskip_dependency_checkdependency_constraints_txtos.PathLike[str] | None	installer_env.InstallerrunnerSubprocessRunner | NoneIterator[ProjectBuilder]c              #  .  K   | r t          |          5 }t          t          j        ||          }	|rt          |	|          }	 |	            }
|j        }|r_t          |d          5 }t          |t          t          t          j	        |                              }d d d            n# 1 swxY w Y    ||
j
        d            ||
                    ||                     |
V  d d d            d S # 1 swxY w Y   d S t          t          |          }	|rt          |	|          }	 |	            }
|sW|
                    ||          }|r?d                    d	 |D                       }t                       t          d
|            |
V  d S )N)r   r   zutf-8)encoding)constraintsT)_freshr)   c              3  :   K   | ]}d t          |          z   V  dS )z
	N)r   )r   depss     r<   r   z'_bootstrap_build_env.<locals>.<genexpr>   s0      &\&\Dv0A$0G0G'G&\&\&\&\&\&\r;   zMissing dependencies:)r   r   r   from_isolated_envinstallopenr5   mapr?   r   build_system_requiresget_requires_for_buildcheck_dependenciesr   rH   r|   )r   r   r   r   r   r   r   r   envmake_builderbuilderr   dependency_constraints_filemissingdependenciess                  r<   _bootstrap_build_envr      sW        )444 	">#CS&QQL D&|FCCC"lnnGkG) m4wGGG mKf%g3s39Ni?j?j;k;klllGm m m m m m m m m m m m m m m GG1$????GG22<QQRRRMMM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	& ~v66 	@"<???L,..$ 	?00OOG ?!ww&\&\T[&\&\&\\\			=|==>>>s6   AC9)7B, C9,B0	0C93B0	48C99C= C=outdirc                    t          | ||||||t          j        dk     rt          j        nd           5 }|                    |||          cd d d            S # 1 swxY w Y   d S )Nr   )r   r   re   r	   quiet_subprocess_runnerbuild)	r   r   r   r   r   r   r   r   r   s	            r<   _buildr      s     
"37>A3E3E//4	
 	
 
D 
}}\6?CC
D 
D 
D 
D 
D 
D 
D 
D 
D 
D 
D 
D 
D 
D 
D 
D 
D 
Ds   AAA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_   r1   r^   )limitr)   z
{dim}{}{reset}

)r   r   r|   r?   r   
isinstance	exceptionr   CalledProcessErrorrH   exc_infor   format_exceptionr   
format_excr   	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,elementsSequence[str]c                    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
IndexErrorrF   r   )r   r@   s     r<   _natural_language_listr      su    
8}}oo
8}}{		(3B3-    r;   TpipdistributionsSequence[Distribution]	list[str]c                    g }|D ]J}	t          || ||	||||          }
|                    t          j                            |
                     K|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)r   r   r   r   r   r   r   r   builtr   outs              r<   build_packager     sk    ( E% , ,!&	
 	
 	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d	
           t          j                            ||dt!          d                              } |D ]J}t          || ||||||          }|                    t          j                            |                     K	 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 sdist)r`   rZ   Nz.tar.gzT)ignore_errors)_compatr   
ValueErrorr   r   r   r   r   mkdtempTarFiler   
extractallr   rj   r   r   r   r   r
   rmtree)r   r   r   r   r   r   r   r   r   r@   r   
sdist_name	sdist_outr   tr   r   s                    r<   build_package_via_sdistr   0  s	   ( !     -Moo667O=RTnpy E !!%((J (:;;;IE =_!!%(( 	=ALL###=W%;M%J%JWWW^ghhhhi<Ms9~~o<M1NOO$1 8 8L !$'-2!	 	C LL!1!1#!6!677778 it<<<<<it<<<<<<%	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=& s+   FB*EFE66FF
F
c           
     $   dd l }ddd
}	t          || d|||||	          5 }
t          j                    5 }t	          t
          j                            |
                    |          d          d          5 }|j	        
                    |                                          \  }}d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          t          j        |dd                     g S )Nr   rc   Sequence[StrPath]cwdrQ   extra_environMapping[str, str] | Noner,   r-   c                    t           j                                        }|r|                    |           t	          j        | ||           d S N)r   r3   copyupdater   run_subprocess)rc   r   r   r   s       r<   r   z'_build_metadata.<locals>.run_subprocessu  sH    joo 	&JJ}%%%Cc*****r;   wheelr   METADATArbFr1   )ensure_asciiindentNN)rc   r   r   rQ   r   r   r,   r-   )packaging.metadatar   r   TemporaryDirectoryr   r   r   r   metadata_pathmetadataparse_emailreadrE   r   dumps)r   r   r   r   r   r   r   r   	packagingr   r   tempdirmetadata_filevalid_metadata_s                  r<   _build_metadatar   i  s     + + + + + 	!&!		
 		
 		
Q #%%Q *1GLL..w77DD	
 	
Q %.::=;M;M;O;OPP#Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q$ 

>a@@@   IsY   C!AC
70B3'C
3B77C
:B7;C
>C!
C	C!C	C!!C%(C%argparse.ArgumentParserc                     G d dt           j                  } t          t           j        dd                                t           j                  }t          j        dk    rt          |d          } |            }|                    d	t          d
t          j                    d           |                    d          }|                    dd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(t          j         d)d*+           |                    d,d-d.d/d0d12           |                    d3d4d.d/d5d62           |                    d7d8d9:           |                                }|                    d;d<d=d>d?d@A           |                    dBdCdD+           |                    dE          }|                                }|                    dFt(          j        dGH           |                    dIdJd8dK:           |                    dLdMd*+           |                    dNdOd8dP:           |S )Qz$
    Construct the main parser.
    c                  2     e Zd Z	 	 dd fdZ	 dddZ xZS )(main_parser.<locals>.NegativeCountActionNoption_stringsr   destr?   r+   r   helprQ   r,   r-   c                T    t                                          ||d||           d S )Nr   )r  r  nargsr+   r  )super__init__)selfr  r  r+   r  	__class__s        r<   r  z1main_parser.<locals>.NegativeCountAction.__init__  s?     GG-      r;   parserr   	namespaceobjectvaluesstr | Sequence[Any] | Noneoption_stringc           	     `    t          || j        t          || j        d          dz
             d S )Nr   r_   )setattrr  getattr)r  r
  r  r  r  s        r<   __call__z1main_parser.<locals>.NegativeCountAction.__call__  s1     Ity')TY*J*JQ*NOOOOOr;   r   )
r  r   r  r?   r+   r   r  rQ   r,   r-   r   )
r
  r   r  r  r  r  r  rQ   r,   r-   )__name__
__module____qualname__r  r  __classcell__)r	  s   @r<   NegativeCountActionr     sq        
  #	 	 	 	 	 	 	( )-	P 	P 	P 	P 	P 	P 	P 	P 	Pr;   r  Fa:      A simple, correct Python build frontend.

    By default, a source distribution (sdist) is built from the project root
    and a binary distribution (wheel) is built from the sdist.
    If this is undesirable, you can pass `--sdist` and/or `--wheel`
    to build distributions independently of each other.
    )add_helpdescriptionformatter_class)      T)suggest_on_errorr   ?z<source directory (defaults to the current working directory))typer  r+   r  zglobal optionsz-hz--helpr  zshow this help message and exit)actionr+   r  z	--versionz-Vversionzbuild z (,))r!  r"  z--quietz-qre   r   zreduce verbosity)r  r!  r+   r  z	--verbosez-vcountzincrease verbosityzbuild optionsz--outdirz-oz&output directory (defaults to {srcdir}z3dist).  Cannot be used together with ``--metadata``PATH)r  metavarz--sdistz-sr   append_constr   z;build a source distribution (disables the default behavior))r  r!  constr  z--wheelz-wr   z-build a wheel (disables the default behavior)z
--metadata
store_truezjprint out a wheel's metadata in JSON format. Cannot be used in conjunction with ``--sdist`` or ``--wheel``)r!  r  z--config-settingz-Cr   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; use ``--config-setting=--my-setting -C--my-other-setting`` insteadzKEY[=VALUE])r  r!  r  r'  z--config-jsonzsettings to pass to the backend as a JSON object. This is an alternative to ``--config-setting`` that allows complex nested structures. Cannot be used together with ``--config-setting``JSON_STRINGzinstallation optionsz--installerz1Python package installer to use (defaults to pip))choicesr  z--no-isolationz-nzdisable building the project in an isolated virtual environment. Build dependencies must be installed separately when this option is usedz--dependency-constraints-txtzQconstrain build dependencies using a constraints.txt when installing dependenciesz--skip-dependency-checkz-xz2do not check that build dependencies are installed)r   Actionr   ArgumentParserrstripRawDescriptionHelpFormatterr7   version_infoadd_argumentr?   r   getcwdadd_argument_groupSUPPRESSr   __version__r   __path__add_mutually_exclusive_groupsep_env
INSTALLERS)	r  make_parserr
  global_groupverbosity_exclusive_groupbuild_groupconfig_exclusive_groupinstall_groupenv_exclusive_groups	            r<   main_parserrC    s   
P P P P Pho P P P2  	 !<  K 7""kDAAA[]]F
	K     ,,-=>>L!.     I*IIchhu~.F.FIII	     !- I I K K**" +    **! +    ++O<<Kssss	     J     <     y    
 )EEGG''Y  ( 	 	 	 ''<  (    --.DEEM'DDFF$$@ %   
 $$S	 %    &`    
 !A	     Mr;   raw_config_settingsdict[str, Any]c                   t          t          t          f                     }| D ]g}|                    d          \  }}}||vr|||<   %t	          ||         t
                    s||         g||<   ||                             |           h|S )N=)dictr?   r   r   r   listr   )rD  r   argsettingr   values         r<   _parse_config_settingsrM  9  s    38n&&O" 3 3MM#..E/))',OG$$og6== F,;G,D+E(G$++E2222r;   cli_argsprogc           
     b   t                      }|r||_        |                    |           }t          |j                   t          t          t          f                     }|j        rm	 t          j
        |j                  }t          |t
                    st          d           nI# t          j        $ r}t          d|            Y d}~n#d}~ww xY w|j        rt          |j                  }|j        %t"          j                            |j        d          n|j        }|j        r|j        r|                    d           nY|j        rt1          t2          dg          }n:|j        rt1          t4          |j                  }nt1          t6          dg          }t9                      5   ||j        |||j         |j        |j        |j         	          }tB          j        d
k    r+|r)tE          d |D                       }	tG          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
    )re   zN--config-json must contain a JSON object (dict), not a list or primitive valuezInvalid JSON in --config-json: Ndistz/--metadata: not allowed with --sdist or --wheelr   )r   )r   r   r   r   r   r^   c                X    g | ]'} d j         |fi t                                          (S )z!{underline}{}{reset}{bold}{green})rF   r*   rG   )r   artifacts     r<   
<listcomp>zmain.<locals>.<listcomp>~  s8    mmm[c;4;HVVVVmmmr;   z){bold}{green}Successfully built {}{reset})$rC  rO  
parse_argsrx   re   rH  r?   r   config_jsonr   loadsr   r|   JSONDecodeErrorr   rM  r   r   r   r   r   r   r   errorr   r   r   r   r   no_isolationr   r   r   r   r   rH   )
rN  rO  r
  argsr   r   r   r   r   artifact_lists
             r<   mainr]  I  s    ]]F X&&D((((38n&&O  
G	:"j)9::Oot44 ighhh# 	: 	: 	:8Q8899999999	: 
	 G01EFF 37+2ERW\\$+v...4;F} J+ JFGGGG	 JyAAA		 JT5GHHH/yIII			 P PK+++"&"<'+'Fn
 
 
 >RE2mmglmmm M ?OOOP P P P P P P P P P P P P P P P P Ps+   *=B( (C7CC/A(H$$H(+H(c                 H    t          t          j        dd                     d S )Nr_   )r]  r7   argvr:   r;   r<   
entrypointr`    s     !""r;   __main__zpython -m buildr]  rC  )r,   r-   )r)   r)   N)r>   r?   r@   r?   rA   rB   r,   r-   r   )rI   rJ   rK   rL   rM   r?   rN   rO   rA   rB   rP   rQ   r,   r-   )r,   rT   )re   rO   r,   r-   )r_   )r@   r?   ry   rO   r,   r   )r}   r~   r,   r?   r   )r   r   r   r    r   r   r   r   r   r   r   r   r   r   r   r   r,   r   )r   r   r   r    r   r    r   r   r   r   r   r   r   r   r   r   r,   r?   )r,   r   )r   r   r,   r?   )NTFNr   )r   r    r   r    r   r   r   r   r   r   r   r   r   r   r   r   r,   r   )r,   r   )rD  r   r,   rE  )rN  r   rO  rQ   r,   r-   )H
__future__r   __lazy_modules__r   
contextlibcontextvarsr   r   r   r
   r   r7   r   r   r   r   r   r   r   r   r   r   r	   r   	build.envr   r:  r   r   build._exceptionsr   r   r   r   TYPE_CHECKINGcollections.abcr   r   r   build._typesr   r   r    r!   _COLORSrH  fromkeysr6   
ContextVarr*   r=   rH   rS   rn   rx   r|   r   contextmanagerr   r   r   r   r   r   r   rC  rM  r]  r`  r  r_  __all__r:   r;   r<   <module>rp     s9   # " " " " "   $           				       



              ( ( ( ( ( ( ( ( ( (            & & & & & & & & W W W W W W W W W W ( ( ( ( ( (  U;;;;;;;;;;TTTTTTTTTTTT   ]]7B''
 !+
 G
<
<
<   C C C C C = = = = =   6" " " ""    K K K K  '+* * * * *ZD D D D.    8	 	 	 	  .2"':> %! ! ! ! !P .2"':> %6  6  6  6  6 z .2"':> %( ( ( ( (Vb b b bJ    7P 7P 7P 7P 7Pt    zD!""())) r;   