
    Zj18                       d dl mZ ddej         dej         dej         dddd	d
ddg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ZddlmZmZ ddlmZ ddlmZmZmZmZ ddlmZmZ dZer.d dlmZmZm Z  e	j!        dk     rd dl"m#Z# nd dlm#Z# ddl$m%Z%m&Z&m'Z'm(Z( ddgdZ)d5d"Z*d6d%Z+d7d(Z,d8d*Z-d9d-Z.d:d2Z/ G d3 d4          Z0dS );    )annotations
contextlibdifflibz._compatz._exceptionsz._utilospyproject_hooks
subprocesssyswarningszipfileN)Any   )_ctxenv)tomllib)BuildBackendExceptionBuildExceptionBuildSystemTableValidationErrorTypoWarning)check_dependencyparse_wheel_filenameF)IteratorMappingSequence)      )Self)ConfigSettingsDistributionStrPathSubprocessRunnerz setuptools.build_meta:__legacy__zsetuptools >= 40.8.0)build-backendrequires
dictionaryMapping[str, str]expectedstrreturnNonec                    | D ]Q}t          j        d ||                                          dk    r#t          j        d| d| dt
          d           Rd S )Ng?zFound 'z#' in pyproject.toml, did you mean 'z'?   )
stacklevel)r   SequenceMatcherratior
   warnr   )r#   r%   objs      K/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/build/_builder.py
_find_typor1   >   sw      "4377==??3FFMN#NN(NNN        
source_dirr   c                   t           j                            |           sd|  d}t          |          t           j                            | d          }t           j                            | d          }t           j                            |          s4t           j                            |          sd|  d}t          |          d S d S )NzSource z is not a directorypyproject.tomlzsetup.pyzF does not appear to be a Python project: no pyproject.toml or setup.py)r   pathisdirr   joinexists)r3   msgpyproject_tomlsetup_pys       r0   _validate_source_directoryr=   H   s    7==$$ "7
777S!!!W\\*.>??Nw||J
33H7>>.)) ""'..2J2J "j
jjjS!!!" " " "r2   r6   Mapping[str, Any]c                   	 t          | d          5 }t          j        |                                                                          cd d d            S # 1 swxY w Y   d S # t
          $ r i cY S t          $ r'}|j         d|j         d}t          |          d d }~wt          j
        $ r}d|  d| d}t          |          d d }~ww xY w)Nrbz: 'z' zFailed to parse z:  )openr   loadsreaddecodeFileNotFoundErrorPermissionErrorstrerrorfilenamer   TOMLDecodeError)r6   fer:   s       r0   _read_pyproject_tomlrM   S   s<   
,$ 	4=!2!233	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4   			 , , ,..
...S!!t+" , , ,------S!!t+,sL   A$ 8A
A$ AA$ AA$ $C2	C;"BC/CCr;   c                d   d| vrt          | d           t          S t          | d                   }d|vr!t          |d           d}t          |          t	          |d         t
                    rt          d |d         D                       sd}t          |          |x r dk    rd! x\  t          d x\      nI    r" dk    rd! x\     d	}t          |             	 t          |d           t          d         |d<   |x r: dk    r4d! x.\  xt
          d x \   }  t          d |D                       r n)     r" dk    rd! x\     d}t          |             |                                h dz
  }|r'dd	                    |           }t          |          |S )Nzbuild-systemr"   z!`requires` is a required propertyc              3  @   K   | ]}t          |t                    V  d S N
isinstancer&   .0is     r0   	<genexpr>z,_parse_build_system_table.<locals>.<genexpr>o   sE       G G 
1cG G G G G Gr2   z&`requires` must be an array of stringsr   r!    z `build-backend` must be a stringbackend-pathc              3  @   K   | ]}t          |t                    V  d S rP   rQ   rS   s     r0   rV   z,_parse_build_system_table.<locals>.<genexpr>   s-      <f<fTUZ3=O=O<f<f<f<f<f<fr2   z*`backend-path` must be an array of strings>   r"   rX   r!   zUnknown properties: z, )r!   )rX   )
r1   _DEFAULT_BACKENDdictr   rR   listallr&   keysr8   )r;   build_system_tabler:   backend_pathunknown_propss        r0   _parse_build_system_tablerb   a   s    ^++>>222n^<== +++%z2221-c222(4d;; 33 G G$6z$BG G G D D 3 7-c222
%%%%%%%%%%%%suuuuuuuu &%%!!!!!!!!!!!qqq4C1#666 "!! )?;;; 3C?2S/
5555555555554dffffffff<f<fYe<f<f<f9f9fff 6555           aaa>C1#666 !   '++--0]0]0]]M 3?TYY}%=%=??-c222r2   backend_pathsSequence[str]c                    |D ]V}t           j                            | |          }t           j                            |          sd|d}t	          |          Wd S )Nz`backend-path` entry z% does not exist or is not a directory)r   r6   r8   r7   r   )r3   rc   r6   resolvedr:   s        r0   _validate_backend_pathrg      si     7 77<<
D11w}}X&& 	7W$WWWC1#666	77 7r2   runnerr    r   env.IsolatedEnvc                     	 d
d fd	}|S )Ncmdrd   cwd
str | Noneextra_environMapping[str, str] | Noner'   r(   c                L     | |i  j                     pi |pi            d S rP   )make_extra_environ)rk   rl   rn   r   rh   s      r0   _invoke_wrapped_runnerz7_wrap_subprocess_runner.<locals>._invoke_wrapped_runner   sA     	sCV3S355;VATRTVWWWWWr2   NN)rk   rd   rl   rm   rn   ro   r'   r(   rW   )rh   r   rr   s   `` r0   _wrap_subprocess_runnerrt      s?    ^bX X X X X X X X
 "!r2   c                  
   e Zd ZdZej        ej        fd)d
Ze	ej        fd*d            Z
ed+d            Zed+d            Zed,d            Z	 d-d.dZ	 d-d/dZ	 d-d0dZ	 	 d1d2dZd3d Z	 d-d4d%Zej        d5d(            ZdS )6ProjectBuilderz#
    The PEP 517 consumer API.
    r3   r   python_executabler&   rh   r    r'   r(   c                $   t           j                            |          | _        t	          |           || _        || _        t           j                            |d          }t          t          |                    | _
        | j
        d         | _        | j
                            d          x}rt          | j        |           t          j        | j        | j        | j
                            d          | j        | j                  | _        dS )aA  
        :param source_dir: The source directory
        :param python_executable: The python executable where the backend lives
        :param runner: Runner for backend subprocesses

        The ``runner``, if provided, must accept the following arguments:

        - ``cmd``: a list of strings representing the command and arguments to
          execute, as would be passed to e.g. 'subprocess.check_call'.
        - ``cwd``: a string representing the working directory that must be
          used for the subprocess. Corresponds to the provided source_dir.
        - ``extra_environ``: a dict mapping environment variable names to values
          which must be set for the subprocess execution.

        The default runner simply calls the backend hooks in a subprocess, writing backend output
        to stdout/stderr.
        r5   r!   rX   )r`   rw   rh   N)r   r6   abspath_source_dirr=   _python_executable_runnerr8   rb   rM   _build_system_backendgetrg   r   BuildBackendHookCaller_hook)selfr3   rw   rh   pyproject_toml_pathrc   s         r0   __init__zProjectBuilder.__init__   s    . !#
 ; ;":..."3 gll:7GHH67KL_7`7`aa*?; .22>BBB= 	D"4#3]CCC$;M+//??"5<
 
 



r2   r   ri   r   c                D     | ||j         t          ||                    S )N)r3   rw   rh   )rw   rt   )clsr   r3   rh   s       r0   from_isolated_envz ProjectBuilder.from_isolated_env   s3     s!!3*6377
 
 
 	
r2   c                    | j         S )zProject source directory.)rz   r   s    r0   r3   zProjectBuilder.source_dir   s     r2   c                    | j         S )zC
        The Python executable used to invoke the backend.
        )r{   r   s    r0   rw   z ProjectBuilder.python_executable   s    
 &&r2   set[str]c                6    t          | j        d                   S )z
        The dependencies defined in the ``pyproject.toml``'s
        ``build-system.requires`` field or the default build dependencies
        if ``pyproject.toml`` is missing or ``build-system`` is undefined.
        r"   )setr}   r   s    r0   build_system_requiresz$ProjectBuilder.build_system_requires   s     4%j1222r2   Ndistributionr   config_settingsConfigSettings | Nonec                    t          j        d| dd           d| }t          | j        |          }|                     |          5  t           ||                    cddd           S # 1 swxY w Y   dS )a@  
        Return the dependencies defined by the backend in addition to
        :attr:`build_system_requires` for a given distribution.

        :param distribution: Distribution to get the dependencies of
            (``sdist`` or ``wheel``)
        :param config_settings: Config settings for the build backend
        zGetting build dependencies for ...stepkindget_requires_for_build_N)r   loggetattrr   _handle_backendr   )r   r   r   	hook_nameget_requiress        r0   get_requires_for_buildz%ProjectBuilder.get_requires_for_build   s     	D<DDD9UUUU<l<<	tz955!!),, 	6 	6||O4455	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6s   
A//A36A3set[tuple[str, ...]]c                v    |                      ||                              | j                  }d |D             S )a  
        Return the dependencies which are not satisfied from the combined set of
        :attr:`build_system_requires` and :meth:`get_requires_for_build` for a given
        distribution.

        :param distribution: Distribution to check (``sdist`` or ``wheel``)
        :param config_settings: Config settings for the build backend
        :returns: Set of variable-length unmet dependency tuples
        c                6    h | ]}t          |          D ]}|S rW   )r   )rT   dus      r0   	<setcomp>z4ProjectBuilder.check_dependencies.<locals>.<setcomp>  s.    EEEa1A!1D1DEEAEEEEr2   )r   unionr   )r   r   r   dependenciess       r0   check_dependenciesz!ProjectBuilder.check_dependencies	  s?     22<QQWWX\XrssEE<EEEEr2   output_directoryrm   c                    t          j        d| dd           	 |                     d| ||d          S # t          $ r+}t	          |j        t          j                  rY d}~dS  d}~ww xY w)	aR  
        Prepare metadata for a distribution.

        :param distribution: Distribution to build (must be ``wheel``)
        :param output_directory: Directory to put the prepared metadata in
        :param config_settings: Config settings for the build backend
        :returns: The full path to the prepared metadata directory
        zGetting metadata for r   r   r   prepare_metadata_for_build_F)_allow_fallbackN)r   r   _call_backendr   rR   	exceptionr   HookMissing)r   r   r   r   r   s        r0   preparezProjectBuilder.prepare  s     	::::KKKK
	%%<l<<  %	 &    % 	 	 	)-/JKK ttttt	s   8 
A-A('A((A-metadata_directoryc                l    t          j        d| dd           |i nd|i} | j        d| ||fi |S )a  
        Build a distribution.

        :param distribution: Distribution to build (``sdist`` or ``wheel``)
        :param output_directory: Directory to put the built distribution in
        :param config_settings: Config settings for the build backend
        :param metadata_directory: If provided, should be the return value of a
            previous ``prepare`` call on the same ``distribution`` kind
        :returns: The full path to the built distribution
        z	Building r   r   r   Nr   build_)r   r   r   )r   r   r   r   r   kwargss         r0   buildzProjectBuilder.build5  sd    " 	.\...Y????)18LN`7a!t!"9<"9"9;K_gg`fgggr2   c                   |                      d|          }||S |                     d|          }t          t          j                            |                    }|sd}t          |          |d          d|d          d}| dt          j        |          5 }|	                    |fd	|
                                D                        ddd           n# 1 swxY w Y   t          j                            ||          S )
a  
        Generate the metadata directory of a distribution and return its path.

        If the backend does not support the ``prepare_metadata_for_build_wheel``
        hook, a wheel will be built and the metadata will be extracted from it.

        :param output_directory: Directory to put the metadata distribution in
        :returns: The path of the metadata directory
        wheelNzInvalid wheelr   -versionz
.dist-info/c              3  F   K   | ]}|                               |V  d S rP   )
startswith)rT   membermember_prefixs     r0   rV   z/ProjectBuilder.metadata_path.<locals>.<genexpr>e  s6      WWFf6G6G6V6VWWWWWWWr2   )r   r   r   r   r6   basename
ValueErrorr   ZipFile
extractallnamelistr8   )	r   r   metadatar   matchr:   distinfowr   s	           @r0   metadata_pathzProjectBuilder.metadata_pathK  sN    <<)9::O 

7$455$RW%5%5e%<%<== 	"!CS//!N+JJeI.>JJJ#_U## 	qLL WWWWajjllWWW  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 w||,h777s   5CC#&C#r   outdirr   r   c                   t           j                            |          }t          | j        |          }t           j                            |          r5t           j                            |          sd| d}t          |          nt          j        |d           | 	                    |          5   |||fi |}d d d            n# 1 swxY w Y   t           j        
                    ||          S )NzBuild path 'z' exists and is not a directoryT)exist_ok)r   r6   ry   r   r   r9   r7   r   makedirsr   r8   )r   r   r   r   r   callbackr:   r   s           r0   r   zProjectBuilder._call_backendi  s9    ((4:y117>>&!! 	/7==(( *LVLLL$S)))* K....!!),, 	H 	H$HV_GGGGH	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H w||FH---s   4CCChookIterator[None]c              #  F  K   	 d V  d S # t           j        $ r1}t          |d| j         dt	          j                              d d }~wt          j        $ r}t          |d|           d d }~wt          $ r(}t          |t	          j                              d d }~ww xY w)Nz	Backend 'z' is not available.z0Backend subprocess exited when trying to invoke )exc_info)	r   BackendUnavailabler   r~   r	   r   r   CalledProcessError	Exception)r   r   r   s      r0   r   zProjectBuilder._handle_backend|  s      	VEEEEE1 	 	 	'>DM>>>  	
 , 	x 	x 	x'	3lfj3l3lmmsww 	V 	V 	V'	CLNNKKKQUU	Vs,   
 B ,AB A++B 8#BB )r3   r   rw   r&   rh   r    r'   r(   )r   ri   r3   r   rh   r    r'   r   )r'   r&   )r'   r   rP   )r   r   r   r   r'   r   )r   r   r   r   r'   r   )r   r   r   r   r   r   r'   rm   rs   )
r   r   r   r   r   r   r   rm   r'   r&   )r   r   r'   r&   )
r   r&   r   r   r   r   r   r   r'   r&   )r   r&   r'   r   )__name__
__module____qualname____doc__r	   
executabler   default_subprocess_runnerr   classmethodr   propertyr3   rw   r   r   r   r   r   r   r   r   contextmanagerr   rW   r2   r0   rv   rv      s         "%#2#L	+
 +
 +
 +
 +
Z 
 $3#L	

 

 

 

 [

       X  ' ' ' X' 3 3 3 X3 266 6 6 6 6. 26F F F F F* 26	    > 26)-h h h h h,8 8 8 8> Y]. . . . .& V V V V V Vr2   rv   )r#   r$   r%   r&   r'   r(   )r3   r   r'   r(   )r6   r   r'   r>   )r;   r>   r'   r>   )r3   r&   rc   rd   r'   r(   )rh   r    r   ri   r'   r    )1
__future__r   __spec__parent__lazy_modules__r   r   r   r   r	   r
   r   typingr   r    r   r   _compatr   _exceptionsr   r   r   r   _utilr   r   TYPE_CHECKINGcollections.abcr   r   r   version_infotyping_extensionsr   _typesr   r   r   r    rZ   r1   r=   rM   rb   rg   rt   rv   rW   r2   r0   <module>r      s   # " " " " "    $$$	       				     



                                      : 9 9 9 9 9 9 9  P;;;;;;;;;;
'!!*******OOOOOOOOOOOO 8'(     " " " ", , , ,, , , ,^7 7 7 7" " " "hV hV hV hV hV hV hV hV hV hVr2   