
    l9i<                       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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&e'jQ                  e&d      Z) ejT                  de&      Z+d1dZ,d2d3dZ-	 	 d4	 	 	 	 	 	 	 	 	 	 	 	 	 d5dZ. ej^                         j`                  dz
  Z1e1d k  rdZ1 eejd                  de1      Z3ddd6dZ4d7d Z5d8d9d!Z6d:d"Z7	 	 	 	 	 	 	 	 	 	 	 	 d;d#Z8	 d<	 	 	 	 	 	 	 	 	 	 	 d=d$Z9	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d>d%Z:ejv                  d?d&       Z<d@d'Z=	 	 	 	 dA	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dBd(Z>	 	 	 	 dA	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dBd)Z?dCd*Z@dDdEd+ZAd1d,ZBeCd-k(  r eAe
j                  dd d.       d/d0gZEy)F    )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reset _styles)defaultc                 B   dt         j                  v rCdt         j                  v rt        j                  dd       t        j                  t               n1dt         j                  v st        j                  j                         ry t        j                  t               y )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isatty     W/var/www/html/leadgen/airagagent/rag_env/lib/python3.12/site-packages/build/__main__.py_init_colorsr/   /   s`    RZZBJJ&MMhuvwJ	"**	$

(9(9(;KK
r-   c                f    t         | j                  |fi t        j                         |d       y )NT)fileflush)printformatr   get)fmtmsgr1   s      r.   _cprintr8   9   s$    	*#**S
*GKKM
*TBr-   c                .    t        dt        |              y )Nz{yellow}WARNING{reset} {})r8   str)messagecategoryfilenamelinenor1   lines         r.   _showwarningr@   =   s     'W6r-   r!   N     )subsequent_indentwidth)originc               P   |G| j                         ^}}t        dt        |d             |D ]  }t        t        |d              y |d   dk(  rU|d   dk(  rd	nd
}|d   dk(  rt        j
                  nd }| j                         D ]  }t        dt        ||      |        y y )Nz{bold}{}{reset}z* )initial_indentrB   r   
subprocessr	   cmdz> z< stderrz{dim}{}{reset})r1   )
splitlinesr8   _fillr3   r)   rJ   )r;   rE   firstrestr?   rG   r1   s          r.   _logrO   P   s    ~ ++-!5t#DE 	4D%T23	4 
l	"!'e!3#AY(2szz&&( 	]D$eD&PW[\	] 
#r-   c                0   t         t        _        t        j                         dk(  r	 dd l}|j                          t                t        j                  j                  t               t        j                  j                  |        y # t        $ r Y Xw xY w)NWindowsr   )r@   r%   showwarningplatformsystemcoloramainitModuleNotFoundErrorr/   r   LOGGERr'   rO   	VERBOSITY)	verbosityrU   s     r.   
_setup_clir[   ^   sg    'HI%	MMO NKKOODNNy! # 		s   B	 		BBc                0    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} {})r8   
SystemExit)r7   codes     r.   _errorr_   o   s     "C(
T
r-   c                2    dj                  d | D              S )Nz -> c              3  `   K   | ]&  }|j                  d       d   j                          ( yw);r   N)	partitionstrip).0deps     r.   	<genexpr>z$_format_dep_chain.<locals>.<genexpr>{   s'     Js}}S)!,224Js   ,.)join)	dep_chains    r.   _format_dep_chainrj   z   s    ;;J	JJJr-   c                    t        |      5 }t        j                  ||       }|j                  |j                         |j                  |j                  ||xs i              |j                  |||xs i       cd d d        S # 1 sw Y   y xY w)N)	installer)r   r
   from_isolated_envinstallbuild_system_requiresget_requires_for_buildbuild)srcdiroutdirdistributionconfig_settingsrl   r   builders          r.   _build_in_isolated_envrw   ~   s     
i	0 JC 223?G112G22<AVTVWX}}\6?3HbIJ J Js   A-BBc                    t        |       }|sH|j                  ||xs i       }|r0dj                  d |D              }t                t	        d|        |j                  |||xs i       S )Nr   c              3  \   K   | ]$  }|d    t        |dd       fD ]  }|sd|z     & yw)r   r	   Nz
	)rj   )re   depsrf   s      r.   rg   z(_build_in_current_env.<locals>.<genexpr>   s?     "}DPTUVPWYjkopqprksYtOu"}y|6C<"}<"}s   ,,zMissing dependencies:)r
   check_dependenciesrh   r8   r_   rq   )rr   rs   rt   ru   skip_dependency_checkrv   missingdependenciess           r.   _build_in_current_envr      sl     V$G ,,\?;PbQ77"}G"}}LI*<.9:==v/D"EEr-   c                B    | rt        |||||      S t        |||||      S N)rw   r   )	isolationrr   rs   rt   ru   r|   rl   s          r.   _buildr      s/     %fflOU^__$VV\?Tijjr-   c               #    K   	 d  y # t         t        f$ r} t        t        |              Y d } ~ y d } ~ wt        $ r} t        | j                  t        j                        rt                t        t        |              | j                  rRt        j                  | j                  d   | j                  d   | j                  d   d      }dj                  |      }nt        j                  d      }t        d|j                  d             t        t        |              Y d } ~ y d } ~ wt         $ rM} t        j                         j                  d      }t        d|       t        t        |              Y d } ~ y d } ~ ww xY ww)	Nr   r	   r!   )limitr   z
{dim}{}{reset}

)r   r   r_   r:   r   
isinstance	exceptionrH   CalledProcessErrorr8   exc_info	tracebackformat_exceptionrh   
format_excrd   	Exception)etb_linestbs      r.   _handle_build_errorr      s    ./ s1v  akk:#@#@AI3q6N:: 11

1

1

1	H "B%%b)B$bhhtn5s1v !!#))$/$b)s1vsL   F	 FE?1FE?C$D&!F&E?2AE:5F:E??Fc                    t        |       dk(  rd}t        |      t        |       dk(  r| d   S dj                  dj                  | d d       | d         S )Nr   zno elementsr	   z	{} and {}z, r   )len
IndexErrorr4   rh   )elementsr7   s     r.   _natural_language_listr      s_    
8}o	X!	{!!IIhsm$RL
 	
r-   c           
         g }|D ]A  }t        || |||||      }	|j                  t        j                  j	                  |	             C |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)
rr   rs   distributionsru   r   r|   rl   builtrt   outs
             r.   build_packager      sR    & E% ,YoOdfopRWW%%c*+, Lr-   c                   ddl m} d|v rd}t        |      t        || |d|||      }	t        j
                  j                  |	      }
t        j                  d      }g }|r|j                  j                  |	      5 }|j                  |       	 t        j                  dt        |       d       t        j
                  j                  ||
d	t!        d
              } |D ]A  }t        || |||||      }|j#                  t        j
                  j                  |             C 	 t%        j&                  |d       	 d	d	d	       |
g|S # t%        j&                  |d       w xY w# 1 sw Y   *xY w)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   rh   r   r   shutilrmtree)rr   rs   r   ru   r   r|   rl   r   r7   r   
sdist_name	sdist_outr   trt   r   s                   r.   build_package_via_sdistr      sO   & !-Mo9ffgH]_hiE!!%(J  (:;IE__!!%( 		=ALL#=9%;M%J$K;WXi<Ms9~o1NO$1 8L FFL/[pr{|CLL!1!1#!678 it<		=  it<		= 		=s%   =E'BE&E'E$$E''E0c                    t        t        j                  t        t        d            } t
        j                  dk\  rt        | d      } t        t        j                  t        j                  t        j                  d      j                         d      |       }t
        j                  dk\  rt        |dd	      } |       }|j                  d
t        dt        j                         d       |j                  ddddt         j"                   ddj%                  t         j&                         d       |j                  dddddd       |j                  dddd d!d"#       |j                  d$d%dd d&d'#       |j                  d(d)t        d*t        j(                   d+d,-       |j                  d.d/d0d12       |j+                         }|j                  d3d4d0d52       |j                  d6t,        j.                  d78       |j+                         }|j                  d9d:d;d<d=d>?       |j                  d@dAdBdCD       |S )Ez$
    Construct the main parser.
       )rD   )      T)colora  
                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    )descriptionformatter_class)suggest_on_errorr   rr   ?z0source directory (defaults to current directory))typenargsr   helpz	--versionz-Vversionzbuild z (,))actionr   z	--verbosez-vrZ   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-Cru   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   z--config-json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_STRING)r   r   r   )r   argparseRawDescriptionHelpFormattermin_max_terminal_widthr)   version_infoArgumentParsertextwrapindentdedentrd   add_argumentr:   r#   getcwdrq   __version__rh   __path__sepadd_mutually_exclusive_group_env
INSTALLERS)r   make_parserparser	env_groupconfig_groups        r.   main_parserr   !  s    hBB#NacfJghO
7"!/>OOOO eg!
( (-K0 7"kDM]F
		?   **+2chhu~~.F-GqI	   !   J   <   7xuE   !A	   335IS	   @  
 668L[   	 8    Mr-   c                H   t               }|r||_        |j                  |       }t        |j                         i }|j
                  r<	 t        j                  |j
                        }t        |t              st        d       nl|j                  r`|j                  D ]Q  }|j                  d      \  }}}	||vr|	||<   "t        ||   t              s	||   g||<   ||   j                  |	       S |j                   *t"        j$                  j'                  |j(                  d      n|j                   }
|j*                  }|rt,        }n	t.        }dg}t1               5   ||j(                  |
|||j2                   |j4                  |j6                        }t9        |D cg c]'  } dj:                  |fi t<        j?                         ) c}      }tA        d	|       ddd       y# t        j                  $ r}t        d|        Y d}~d}~ww xY wc c}w # 1 sw Y   yxY w)
z
    Parse the CLI arguments and invoke the build process.

    :param cli_args: CLI arguments
    :param prog: Program name to show in help text
    )rZ   zN--config-json must contain a JSON object (dict), not a list or primitive valuezInvalid JSON in --config-json: N=distr   z!{underline}{}{reset}{bold}{green}z){bold}{green}Successfully built {}{reset})!r   prog
parse_argsr[   rZ   r   jsonloadsr   dictr_   JSONDecodeErrorru   rc   listr   rs   r#   r   rh   rr   r   r   r   r   no_isolationr|   rl   r   r4   r   r5   r8   )cli_argsr   r   argsru   r   argsetting_valuers   r   
build_callr   artifactartifact_lists                   r.   mainr     s    ]FX&D(O 	:"jj)9)9:Oot4gh
 
		'' 	7C #c 2GQo-+0(!/'":DA0?0H/IOG,(//6	7 37++2ERWW\\$++v.4;;F(,(:(:M"
,
 			 LKK!!!&&NN
 /chiW_7077RGKKMRi
 	;]KL L3 ## 	:4QC899	:H jL Ls7   
:G$ AH,H
H$H7HHHH!c                 <    t        t        j                  dd         y )Nr	   )r   r)   argvr,   r-   r.   
entrypointr     s    !"r-   __main__zpython -m buildr   r   )returnNone)r   r   N)r6   r:   r7   r:   r1   TextIO | Noner   r   )NN)r;   zWarning | strr<   ztype[Warning]r=   r:   r>   intr1   r   r?   
str | Noner   r   )r;   r:   rE   ztuple[str, ...] | Noner   r   )rZ   r  r   r   )r	   )r7   r:   r^   r  r   r   )ri   Sequence[str]r   r:   )rr   r   rs   r   rt   r   ru   ConfigSettings | Nonerl   _env.Installerr   r:   )F)rr   r   rs   r   rt   r   ru   r  r|   boolr   r:   )r   r  rr   r   rs   r   rt   r   ru   r  r|   r  rl   r  r   r:   )r   zIterator[None])r   r  r   r:   )NTFpip)rr   r   rs   r   r   zSequence[Distribution]ru   r  r   r  r|   r  rl   r  r   r  )r   zargparse.ArgumentParserr   )r   r  r   r  r   r   )F
__future__r   r   
contextlibcontextvarsr   r#   rS   r   rH   r)   r   r   r   r%   collections.abcr   r   	functoolsr   typingr   r   rq   r   r
   r   r   r   _exceptionsr   r   r   _typesr   r   r   r   _COLORSr   fromkeysr(   
ContextVarr   r/   r8   r@   get_terminal_sizecolumnsr   fillrL   rO   r[   r_   rj   rw   r   r   contextmanagerr   r   r   r   r   r   r   __name__r   __all__r,   r-   r.   <module>r     sU   #     	    
     .  #  "  R R 9 9 #  ]]7B'
 !+
 
 G
<C 777 7 	7
 7 7 
7 /f..0881< ! 	=PQ <@ ]""KJJJ J +	J
 J 	J* #(FFF F +	F
  F 	F&kkk k 	k
 +k  k k 	k  8

" .2"' % * +	
     < .2"' %* * *  **  +	* 
 *   *  *  * Zxv<L~ z!"() r-   