
    d/                    >   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mZ d dlZd dlmZmZmZmZmZmZ d dlmZ ddd	d
ddddZd eD             ZdRdZ e            Z dSdTdZ!	 	 dUdVd$Z"dWd%Z#dXdYd)Z$ G d* d+e          Z% G d, d-e          Z&dZd0Z'd[d8Z(	 d\d]d<Z)d^d>Z*ej+        d_d@            Z,d`dBZ-	 	 	 dadbdFZ.	 	 	 dadbdGZ/dcdIZ0dddedLZ1dWdMZ2e3dNk    r e1ej4        d&d         dO           dPdQgZ5dS )f    )annotationsN)IteratorSequence)NoReturnTextIO)BuildBackendExceptionBuildExceptionConfigSettingsTypeFailedProcessErrorPathTypeProjectBuilder)IsolatedEnvBuilderz[91mz[92mz[93mz[1mz[2mz[4mz[0m)redgreenyellowbolddim	underlineresetc                    i | ]}|d S )  ).0colors     R/home/feoh/.local/pipx/venvs/poetry/lib/python3.11/site-packages/build/__main__.py
<dictcomp>r   $   s    ---EeR---    returndict[str, str]c                     dt           j        v r)dt           j        v rt          j        d           t          S dt           j        v st
          j                                        rt          S t          S )NNO_COLORFORCE_COLORzLBoth NO_COLOR and FORCE_COLOR environment variables are set, disabling color)	osenvironwarningswarn
_NO_COLORSsysstdoutisatty_COLORSr   r   r   _init_colorsr,   '   s^    RZBJ&&Mhiii	"*	$	$
(9(9(;(;	$r   r   fmtstrmsgNonec                J    t           | j        |fi t          d           d S )NT)flush)printformat_STYLES)r-   r/   s     r   _cprintr6   4   s/    	*#*S
$
$G
$
$D111111r   messageWarning | strcategorytype[Warning]filenamelinenointfileTextIO | Noneline
str | Nonec                @    t          dt          |                      d S )Nz{yellow}WARNING{reset} {})r6   r.   )r7   r9   r;   r<   r>   r@   s         r   _showwarningrC   8   s!     'W66666r   c                     t           t          _        t          j                    dk    r,	 dd l} |                                  d S # t          $ r Y d S w xY wd S )NWindowsr   )rC   r%   showwarningplatformsystemcoloramainitModuleNotFoundError)rI   s    r   
_setup_clirL   C   sf    'HI%%	OOOMMOOOOO" 	 	 	DD	 &%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} {})r6   
SystemExit)r/   rN   s     r   _errorrQ   O   s#     "C(((
T

r   c                  &    e Zd Zedd            ZdS )_ProjectBuilderr7   r.   r   r0   c                &    t          d|            d S Nz{bold}* {}{reset}r6   r7   s    r   logz_ProjectBuilder.log[       #W-----r   Nr7   r.   r   r0   __name__
__module____qualname__staticmethodrX   r   r   r   rS   rS   Z   2        . . . \. . .r   rS   c                  &    e Zd Zedd            ZdS )_IsolatedEnvBuilderr7   r.   r   r0   c                &    t          d|            d S rU   rV   rW   s    r   rX   z_IsolatedEnvBuilder.loga   rY   r   NrZ   r[   r   r   r   rb   rb   `   r`   r   rb   	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>g   s?      JJs}}S))!,2244JJJJJJr   )join)rd   s    r   _format_dep_chainrn   f   s#    ;;JJ	JJJJJJr   builderr   outdirr   distributionconfig_settingsConfigSettingsType | Nonec                8   t                      5 }|j        | _        |j        | _        |                    | j                   |                    |                     |                     |                     |||pi           cd d d            S # 1 swxY w Y   d S N)rb   
executablepython_executablescripts_dirinstallbuild_system_requiresget_requires_for_buildbuild)ro   rp   rq   rr   envs        r   _build_in_isolated_envr~   j   s     
		 J#$'N!!oG1222G22<@@AAA}}\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                    |sV|                      |          }|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   rM   Nz
	)rn   )r   depsrk   s      r   rl   z(_build_in_current_env.<locals>.<genexpr>   s[      "}"}DPTUVPWYjkopqprprksYtYtOu"}"}y|"}6C<"}"}"}"}"}"}"}r   zMissing dependencies:)check_dependenciesrm   r6   rQ   r|   )ro   rp   rq   rr   r   missingdependenciess          r   _build_in_current_envr   w   s     ! ;,,\:: 	;77"}"}G"}"}"}}}LIII9<99:::==v/D"EEEr   	isolationc                P    | rt          ||||          S t          |||||          S ru   )r~   r   )r   ro   rp   rq   rr   r   s         r   _buildr      s8      l%gv|_UUU$WflOUjkkkr   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w xY w)	Nr   rM      )limitr   
{dim}{}{reset}

)r	   r   rQ   r.   r   
isinstance	exception
subprocessCalledProcessErrorr6   exc_info	tracebackformat_exceptionrm   
format_excrj   )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!s   
 E=E
C2EEelementsc                    t          |           dk    rt          d          t          |           dk    r| d         S d                    d                    | d d                   | d                   S )Nr   zno elementsrM   z	{} and {}z, r   )len
IndexErrorr4   rm   )r   s    r   _natural_language_listr      sr    
8}}'''	X!		{!!IIhssm$$RL
 
 	
r   Tsrcdirdistributionsc           	         g }t          |           }|D ]H}t          ||||||          }	|                    t          j                            |	                     I|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
    )rS   r   appendr#   pathbasename)
r   rp   r   rr   r   r   builtro   rq   outs
             r   build_packager      sg    $ Ef%%G% , ,YPeffRW%%c**++++Lr   c                >   d|v rt          d          t          |           }t          |||d||          }t          j                            |          }t          j        d          }	g }
t          j	        |          5 }|
                    |	           	 t          t          j                            |	|dt          d                                        }|r&|                    dt          |           d           |D ]H}t          ||||||          }|
                    t          j                            |                     I	 t!          j        |	d	
           n# t!          j        |	d	
           w xY w	 ddd           n# 1 swxY w Y   |g|
z   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
    sdistz=Only binary distributions are allowed but sdist was specifiedzbuild-via-sdist-)prefixNz.tar.gzz	Building z from sdistT)ignore_errors)
ValueErrorrS   r   r#   r   r   tempfilemkdtemptarfileopen
extractallrm   r   rX   r   r   shutilrmtree)r   rp   r   rr   r   r   ro   r   
sdist_name	sdist_outr   trq   r   s                 r   build_package_via_sdistr      s   $ -XYYYf%%G9gvwI^__E!!%((J (:;;;IE	e		 
9	Y	9%bgll9jIZCPYNN?IZ>[&\&\]]G \Z(>}(M(MZZZ[[[ - 4 4YXmnnRW--c2233334 M)488888FM)4888888
9 
9 
9 
9 
9 
9 
9 
9 
9 
9 
9 
9 
9 
9 
9 <%s+   FB6E&F&E>>FFFargparse.ArgumentParserc                    t          j        t          j        t          j        d                                          d          t           j                  } |                     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t          dt          j         d           |                     dddd           |                     d d!dd"           |                     d#d$d%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    )descriptionformatter_classr   ?z0source directory (defaults to current directory))typenargsdefaulthelpz	--versionz-Vversionzbuild z (,))actionr   z--sdistz-s
store_truez;build a source distribution (disables the default behavior))r   r   z--wheelz-wz-build a wheel (disables the default behavior)z--outdirz-oz&output directory (defaults to {srcdir}zdist))r   r   z--skip-dependency-checkz-xz2do not check that build dependencies are installedz--no-isolationz-nz1do not isolate the build in a virtual environmentz--config-settingz-Cr   zpass options to the backend.  options which begin with a hyphen must be in the form of "--config-setting=--opt(=value)" or "-C--opt(=value)")argparseArgumentParsertextwrapindentdedentrj   RawTextHelpFormatteradd_argumentr.   r#   getcwdr|   __version__rm   __path__sep)parsers    r   main_parserr      s    $OO  egg!
 
$ !5'  F* 	?     I*IIchhu~.F.FIII	     J	     <	     EEEE	     !A	     @	     @	     Mr   cli_argsprogc           	     "   t                       t                      }|r||_        |                    |           }g }i }|j        ro|j        D ]g}|                    d          \  }}}	||vr|	||<   %t          ||         t                    s||         g||<   ||                             |	           h|j	        r|                    d           |j
        r|                    d           |j        %t          j                            |j        d          n|j        }
|rt           }n
t"          }dg}	 t%                      5   ||j        |
|||j         |j                  }t+          d |D                       }t-          d|           ddd           dS # 1 swxY w Y   dS # t.          $ r]}t1          j                                        d          }t-          d	|           t7          t9          |                     Y d}~dS d}~ww 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
    =r   wheelNdistc                4    g | ]} d j         |fi t          S )z!{underline}{}{reset}{bold}{green})r4   r5   )r   artifacts     r   
<listcomp>zmain.<locals>.<listcomp>{  s0    gggU];4;HPPPPgggr   z){bold}{green}Successfully built {}{reset}r   r   )rL   r   r   
parse_argsconfig_settingri   r   listr   r   r   rp   r#   r   rm   r   r   r   r   no_isolationr   r   r6   	Exceptionr   r   rj   rQ   r.   )r   r   r   argsr   rr   argsetting_valuerp   
build_callr   artifact_listr   r   s                   r   mainr   M  s    LLL]]F X&&DMO 	7& 	7 	7C #c 2 2GQo--+0((!/'":DAA J0?0H/IOG,(//6666z &W%%%z &W%%% 37+2ERW\\$+v...4;F ""

,
 	 "" 	P 	PJV]OIZEZ\`\v E 3ggafggg M ?OOO	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P    !##))$//$b)))s1vvs>   5F' A
FF' FF' !F"F' '
H1AH		Hc                 H    t          t          j        dd                     d S )NrM   )r   r(   argvr   r   r   
entrypointr     s     !""r   __main__zpython -m buildr   r   )r   r   )r   r   )r-   r.   r/   r.   r   r0   )NN)r7   r8   r9   r:   r;   r.   r<   r=   r>   r?   r@   rA   r   r0   )r   r0   )rM   )r/   r.   rN   r=   r   r   )rd   re   r   r.   )
ro   r   rp   r   rq   r.   rr   rs   r   r.   )F)ro   r   rp   r   rq   r.   rr   rs   r   r   r   r.   )r   r   ro   r   rp   r   rq   r.   rr   rs   r   r   r   r.   )r   r   )r   re   r   r.   )NTF)r   r   rp   r   r   re   rr   rs   r   r   r   r   r   re   )r   r   ru   )r   re   r   rA   r   r0   )6
__future__r   r   
contextlibr#   rG   r   r   r(   r   r   r   r   r%   collections.abcr   r   typingr   r   r|   r   r	   r
   r   r   r   	build.envr   r+   r'   r,   r5   r6   rC   rL   rQ   rS   rb   rn   r~   r   r   contextmanagerr   r   r   r   r   r   r   r\   r   __all__r   r   r   <module>r      s   # " " " " "      				       



         . . . . . . . . # # # # # # # #  y y y y y y y y y y y y y y y y ( ( ( ( ( (   .-W---
    ,..2 2 2 2 2 7 7 7 7 7	 	 	 	    . . . . .n . . .. . . . ., . . .K K K K
J 
J 
J 
J$ #(F F F F F"l l l l    0	
 	
 	
 	
  26"'    < 26"''  '  '  '  ' TK K K K\4 4 4 4 4n    zD!""())) r   