
    aiI                    Z   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m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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'm(Z( ddlm)Z) ddddddddZ*e+jY                  e*d      Z- ej\                  de*      Z/d-dZ0d.d/dZ1	 	 d0	 	 	 	 	 	 	 	 	 	 	 	 	 d1dZ2d2dZ3d3dZ4d4d5dZ5d6dZ6ejn                  	 d7	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d8d       Z8	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d9dZ9ejn                  d:d        Z:d;d!Z;	 	 	 	 d<	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d=d"Z<	 	 	 	 d<	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d=d#Z=	 	 	 	 d<	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d=d$Z>d>d%Z?d?d&Z@d7d@d'ZAd-d(ZBeCd)k(  r eAe
j                  dd d*       d+d,gZEy)A    )annotationsN)IteratorMappingSequence)partial)AnyNoReturnTextIO   )ProjectBuilder_ctx)env)BuildBackendExceptionBuildExceptionFailedProcessError)ConfigSettingsDistributionStrPathSubprocessRunner)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     X/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/build/__main__.py_init_colorsr2   1   s`    RZZBJJ&MMhuvwJ	"**	$

(9(9(;KK
r0   c                f    t         | j                  |fi t        j                         |d       y )NT)fileflush)printformatr   get)fmtmsgr4   s      r1   _cprintr;   ;   s$    	*#**S
*GKKM
*TBr0   c                0    t        dt        |       |       y )Nz{yellow}WARNING{reset} {})r;   str)messagecategoryfilenamelinenor4   lines         r1   _showwarningrC   ?   s     'Wt<r0   c                     t        j                         j                  dz
  } | dk  rd} t        t        j
                  d|       d ddfd}|S )	Nr$   r   N     )subsequent_indentwidth)originc                  t         j                  dk\  r|a| j                         ^}}t        d |d      t        j
                         |D ]%  }t         |d      t        j
                         ' y |d   dk(  rF|d	   d
k(  rdnd}| j                         D ]&  }t        d ||      t        j
                         ( y y y )Nz{bold}{}{reset}z* )initial_indentr4   rF   r   
subprocessr   cmdz> z< z{dim}{}{reset})r   	verbosity
splitlinesr;   r,   stderrr6   )r>   rI   firstrestrB   rL   fills         r1   logz_make_logger.<locals>.logQ   s    >>R~!(!3!3!5)4d+KRUR\R\]  LD$tD9

KL l*)/e);#..0 jD,d4.W^a^h^hij +  r0   )r>   r=   rI   ztuple[str, ...] | NonereturnNone)shutilget_terminal_sizecolumnsr   textwraprU   )max_terminal_widthrV   rU   s     @r1   _make_loggerr^   J   sN    113;;a?Q8==D@RSD>B j Jr0   c                8   t         t        _        t        j                         dk(  r	 dd l}|j                          t                t        j                  j                  t                      t        j                  j                  |        y # t        $ r Y \w xY w)NWindowsr   )rC   r(   showwarningplatformsystemcoloramainitModuleNotFoundErrorr2   r   LOGGERr*   r^   	VERBOSITY)rP   rd   s     r1   
_setup_cliri   a   si    'HI%	MMO NKKOOLN#NNy! # 		s   B 	BBc                P    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} {}rM   )r;   r,   rR   
SystemExit)r:   codes     r1   _errorrm   r   s      "Ccjj9
T
r0   c                2    dj                  d | D              S )Nz -> c              3  `   K   | ]&  }|j                  d       d   j                          ( yw);r   N)	partitionstrip).0deps     r1   	<genexpr>z$_format_dep_chain.<locals>.<genexpr>~   s'     Js}}S)!,224Js   ,.)join)	dep_chains    r1   _format_dep_chainrx   }   s    ;;J	JJJr0   c              #    K   | rt        |      5 }t        t        j                  ||      }|rt        ||      } |       }	|j	                  |	j
                         |j	                  |	j                  ||             |	 d d d        y t        t        |      }|rt        ||      } |       }	|sD|	j                  ||      }
|
r0dj                  d |
D              }t                t        d|        |	 y # 1 sw Y   y xY ww)N)	installerrunnerr   c              3  \   K   | ]$  }|d    t        |dd       fD ]  }|sd|z     & yw)r   r   Nz
	)rx   )rs   depsrt   s      r1   ru   z'_bootstrap_build_env.<locals>.<genexpr>   sG      '%)aJ[\`abac\dJe@f'9<jmFSL' 's   ,,zMissing dependencies:)r   r   r   from_isolated_envinstallbuild_system_requiresget_requires_for_buildcheck_dependenciesrv   r;   rm   )	isolationsrcdirdistributionconfig_settingsskip_dependency_checkrz   r|   r   make_builderbuildermissingdependenciess               r1   _bootstrap_build_envr      s      )4 	">#C#CS&QL&|FC"nG KK556KK66|_UVM	 	 ~v6"<?L.$00OG!ww '-4'   	.|n=>9	 	s   D	A2C=A:D	=DD	c           
         t        | |||||t        j                  dk  rt        j                  nd       5 }|j                  |||      cd d d        S # 1 sw Y   y xY w)Nr   )r   r   rP   pyproject_hooksquiet_subprocess_runnerbuild)r   r   outdirr   r   r   rz   r   s           r1   _buildr      sb     
37>>A3E//4
 	D 
}}\6?C	D 	D 	Ds   AA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$   rK   )limitr   z
{dim}{}{reset}

)r   r   rm   r=   r   
isinstance	exceptionrN   CalledProcessErrorr;   exc_info	tracebackformat_exceptionrv   
format_excrr   	Exception)etb_linestbs      r1   _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, rK   )len
IndexErrorr7   rv   )elementsr:   s     r1   _natural_language_listr      s_    
8}o	X!	{!!IIhsm$RL
 	
r0   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)
r   r   distributionsr   r   r   rz   builtr   outs
             r1   build_packager      sR    & E% ,YoOdfopRWW%%c*+, Lr0   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   rV   r   rv   r   r   rY   rmtree)r   r   r   r   r   r   rz   r   r:   r   
sdist_name	sdist_outr   tr   r   s                   r1   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           	        dd l }d
dd}t        || d||||      5 }	t        j                         5 }
t	        t
        j                  j                  |	j                  |
      d      d      5 }|j                  j                  |j                               \  }}d d d        d d d        d d d        t        t        j                  dd	             g S # 1 sw Y   <xY w# 1 sw Y   @xY w# 1 sw Y   DxY w)Nr   c                    t         j                  j                         }|r|j                  |       t	        j
                  | ||       y N)r&   r'   copyupdater   run_subprocess)rO   cwdextra_environr   s       r1   r   z'_build_metadata.<locals>.run_subprocess<  s3    jjooJJ}%Cc*r0   wheelr{   METADATArbFr$   )ensure_asciiindentNN)rO   zSequence[StrPath]r   
str | Noner   zMapping[str, str] | NonerW   rX   )packaging.metadatar   r   TemporaryDirectoryr   r&   r   rv   metadata_pathmetadataparse_emailreadr6   jsondumps)r   r   r   r   r   r   rz   	packagingr   r   tempdirmetadata_filevalid_metadata_s                 r1   _build_metadatar   1  s     + 	vw9NPYbp	

Q ##%	
Q *1GGLL..w7D	

Q %..::=;M;M;OP
Q 
Q 
Q 


>a@ I
Q 
Q 
Q 
Q 
Q 
Qs:   C+:C+-CC C+CCC(	$C++C4c                     G d dt         j                        } t         j                  }t        t         j                  ddj                         |      }t        j                  dk\  rt        |d      } |       }|j                  d	t        d
t        j                         d       |j                  d      }|j                  dddt         j                  d       |j                  ddddt        j                   ddj!                  t        j"                         d       |j%                         }|j                  ddd| dd        |j                  d!d"dd#dd$        |j                  d%      }|j                  d&d't        d(t        j&                   d)d*+       |j                  d,d-d.d/d0d12       |j                  d3d4d.d/d5d62       |j                  d7d8d9:       |j%                         }|j                  d;d<d=d>d?d@A       |j                  dBdCdDdEF       |j                  dG      }|j%                         }	|	j                  dHt(        j*                  dIJ       |	j                  dKdLd8dM:       |j                  dNdOd8dP:       |S )Qz$
    Construct the main parser.
    c                  V     e Zd Z	 	 d	 	 	 	 	 	 	 	 	 d fdZ	 d	 	 	 	 	 	 	 	 	 ddZ xZS )(main_parser.<locals>.NegativeCountActionc                .    t         |   ||d||       y )Nr   )option_stringsdestnargsr    help)super__init__)selfr   r   r    r   	__class__s        r1   r   z1main_parser.<locals>.NegativeCountAction.__init__Z  s&     G-  r0   c           	     b    t        || j                  t        || j                  d      dz
         y )Nr   r   )setattrr   getattr)r   parser	namespacevaluesoption_strings        r1   __call__z1main_parser.<locals>.NegativeCountAction.__call__i  s&     Ityy')TYY*JQ*NOr0   r   )
r   Sequence[str]r   r=   r    r   r   r   rW   rX   r   )
r   argparse.ArgumentParserr   objectr   zstr | Sequence[Any] | Noner   r   rW   rX   )__name__
__module____qualname__r   r   __classcell__)r   s   @r1   NegativeCountActionr   Y  s    
  #	)	 	 		
 	 	( )-	P+	P 	P /		P
 &	P 	Pr0   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-qrP   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  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-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  z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--skip-dependency-checkz-xz2do not check that build dependencies are installed)argparseActionRawDescriptionHelpFormatterr   ArgumentParserrstripr,   version_infoadd_argumentr=   r&   getcwdadd_argument_groupSUPPRESSr   __version__rv   __path__add_mutually_exclusive_groupsep_env
INSTALLERS)
r   r   make_parserr   global_groupverbosity_exclusive_groupbuild_groupconfig_exclusive_groupinstall_groupenv_exclusive_groups
             r1   main_parserr&  T  s   
Phoo P2 ::O 	 (K 7"kDA]F
		K   ,,-=>L!!.   **+2chhu~~.F-GqI	   !- I I K**" +  **! +  ++O<K7x?rs   J   <   y  
 )EEG''Y  ( 	 ''<  (  --.DEM'DDF$$@ % 
 $$S	 %  !A	   Mr0   c                    t        t        t        f          }| D ]Q  }|j                  d      \  }}}||vr|||<   "t	        ||   t
              s	||   g||<   ||   j                  |       S |S )N=)dictr=   r   rq   r   listr   )raw_config_settingsr   argsettingr   values         r1   _parse_config_settingsr/    s    38n&O" 3MM#.E/)',OG$og6=,;G,D+E(G$++E23 r0   c                   t               }|r||_        |j                  |       }t        |j                         t        t        t        f          }|j                  r<	 t        j                  |j                        }t        |t
              st        d       n!|j                  rt        |j                        }|j                   *t"        j$                  j'                  |j(                  d      n|j                   }|j*                  r|j,                  r|j/                  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>                  	      }t@        j                  d
k\  rJ|rHtC        |D 	cg c]'  }	 djD                  |	fi tF        jI                         ) c}	      }
tK        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
    )rP   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   rz   rK   z!{underline}{}{reset}{bold}{green}z){bold}{green}Successfully built {}{reset})&r&  prog
parse_argsri   rP   r)  r=   r   r  r   loadsr   rm   JSONDecodeErrorr   r/  r   r&   r   rv   r   r   r   errorr   r   r   r   r   no_isolationr   rz   r   r   r7   r   r8   r;   )cli_argsr2  r   argsr   r   r   r   r   artifactartifact_lists              r1   mainr<    s    ]FX&D(38n&O 	:"jj)9)9:Oot4gh
 
		01E1EF 37++2ERWW\\$++v.4;;F}}++FG	yA			T5G5GH/yI		 PKK++++"&"<"<nn
 >>RE2glm[c;4;;HVVmM ?OP P' ## 	:4QC899	:< nP Ps7   :H( 
AI ,I
I(I;IIII%c                 <    t        t        j                  dd         y )Nr   )r<  r,   argvr/   r0   r1   
entrypointr?  A  s    !"r0   __main__zpython -m buildr<  r&  )rW   rX   )r   r   N)r9   r=   r:   r=   r4   TextIO | NonerW   rX   r   )r>   zWarning | strr?   ztype[Warning]r@   r=   rA   intr4   rA  rB   r   rW   rX   )rW   z_ctx.Logger)rP   rB  rW   rX   )r   )r:   r=   rl   rB  rW   r	   )rw   r   rW   r=   r   )r   boolr   r   r   r   r   ConfigSettings | Noner   rC  rz   _env.Installerr|   zSubprocessRunner | NonerW   zIterator[ProjectBuilder])r   rC  r   r   r   r   r   r   r   rD  r   rC  rz   rE  rW   r=   )rW   zIterator[None])r   r   rW   r=   )NTFpip)r   r   r   r   r   zSequence[Distribution]r   rD  r   rC  r   rC  rz   rE  rW   	list[str])rW   r   )r+  rG  rW   zdict[str, Any])r8  r   r2  r   rW   rX   )F
__future__r   r  
contextlibcontextvarsr   r&   rb   rY   rN   r,   r   r\   r   r(   collections.abcr   r   r   	functoolsr   typingr   r	   r
   r   r   r   r   r   r   r  _exceptionsr   r   r   _typesr   r   r   r   r   _COLORSr)  fromkeysr+   
ContextVarr   r2   r;   rC   r^   ri   rm   rx   contextmanagerr   r   r   r   r   r   r   r&  r/  r<  r?  r   r>  __all__r/   r0   r1   <module>rU     sZ   #     	    
     7 7  ( (   "  R R K K #  ]]7B'
 !+
 
 G
<C === = 	=
 = = 
=.""K  '+&&& & +	&
  & & $& & &RDDD D 	D
 +D  D D 	D*  8

" .2"' % * +	
     < .2"' %* * *  **  +	* 
 *   *  *  * b .2"' %    *  +	 
         FaH 6Pr z!"() r0   