
    .Ph4                    :   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	m
Z
 d dlmZmZ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mZ dd	lmZmZmZmZ dd
l m!Z!m"Z"  edd          Z#ddgdZ$d&dZ%d'dZ&d(dZ'd)dZ(d*d$Z) G d% d          Z*dS )+    )annotationsN)Iterator)AnyMappingSequenceTypeVar   )_ctxenv)tomllib)BuildBackendExceptionBuildExceptionBuildSystemTableValidationErrorTypoWarning)ConfigSettingsDistributionStrPathSubprocessRunner)check_dependencyparse_wheel_filename_TProjectBuilderProjectBuilder)boundz 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)difflibSequenceMatcherratiowarningswarnr   )r   r   objs      N/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/build/_builder.py
_find_typor,   '   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)ospathisdirr   joinexists)r.   msgpyproject_tomlsetup_pys       r+   _validate_source_directoryr9   1   s    7==$$ "7
777S!!!W\\*.>??Nw||J
33H7>>.)) ""'..2J2J "j
jjjS!!!" " " "r-   r2   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)r2   fer6   s       r+   _read_pyproject_tomlrI   <   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r7   c                
   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          |          d|vr!t          |d           t          d         |d<   n,t	          |d         t                    sd}t          |          d|v rKt	          |d         t
                    rt          d	 |d         D                       s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     r+   	<genexpr>z,_parse_build_system_table.<locals>.<genexpr>X   sE       I I 
1cI I I I I Ir-   z&`requires` must be an array of stringsr   z `build-backend` must be a stringbackend-pathc              3  @   K   | ]}t          |t                    V  d S rL   rM   rO   s     r+   rR   z,_parse_build_system_table.<locals>.<genexpr>i   s,      RR!:a%%RRRRRRr-   z*`backend-path` must be an array of strings>   r   rS   r   zUnknown properties: z, )
r,   _DEFAULT_BACKENDdictr   rN   listallr   keysr4   )r7   build_system_tabler6   unknown_propss       r+   _parse_build_system_tabler\   J   s    ^++>>222n^<== +++%z2221-c222*:6== 3S I I$6z$BI I I F F 3 7-c222000%777 /?.O?++*?;SAA 30-c222+++).94@@ ,RR/A./QRRRRR , ;-c222&++--0]0]0]]M 3?TYY}%=%=??-c222r-   runnerr   r   env.IsolatedEnvc                     	 d
d fd	}|S )NcmdSequence[str]cwd
str | Noneextra_environMapping[str, str] | Noner    r!   c                L     | |i  j                     pi |pi            d S rL   )make_extra_environ)r`   rb   rd   r   r]   s      r+   _invoke_wrapped_runnerz7_wrap_subprocess_runner.<locals>._invoke_wrapped_runnerw   sA     	sCV3S355;VATRTVWWWWWr-   NN)r`   ra   rb   rc   rd   re   r    r!    )r]   r   rh   s   `` r+   _wrap_subprocess_runnerrk   v   s?    ^bX X X X X X X X
 "!r-   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/d0dZ	 d/d1dZ	 d/d2dZ	 	 d3d4d!Zd5d"Z	 d/d6d'Zej        d7d*            ZdS )8r   z#
    The PEP 517 consumer API.
    r.   r   python_executabler   r]   r   r    r!   c                   t           j                            |          | _        t	          |           || _        || _        t           j                            |d          }t          t          |                    | _
        | j
        d         | _        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.
        r0   r   rS   )backend_pathrm   r]   N)r1   r2   abspath_source_dirr9   _python_executable_runnerr4   r\   rI   _build_system_backendpyproject_hooksBuildBackendHookCallerget_hook)selfr.   rm   r]   pyproject_toml_paths        r+   __init__zProjectBuilder.__init__   s    . !#
 ; ;":..."3 gll:7GHH67KL_7`7`aa*?;$;M+//??"5<
 
 



r-   clstype[_TProjectBuilder]r   r^   r   c                D     | ||j         t          ||                    S )N)r.   rm   r]   )rm   rk   )r}   r   r.   r]   s       r+   from_isolated_envz ProjectBuilder.from_isolated_env   s3     s!!3*6377
 
 
 	
r-   c                    | j         S )zProject source directory.)rq   rz   s    r+   r.   zProjectBuilder.source_dir   s     r-   c                    | j         S )zC
        The Python executable used to invoke the backend.
        )rr   r   s    r+   rm   z ProjectBuilder.python_executable   s    
 &&r-   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   )setrt   r   s    r+   build_system_requiresz$ProjectBuilder.build_system_requires   s     4%j1222r-   Ndistributionr   config_settingsConfigSettings | Nonec                    t          j        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 ...get_requires_for_build_N)r
   loggetattrry   _handle_backendr   )rz   r   r   	hook_nameget_requiress        r+   get_requires_for_buildz%ProjectBuilder.get_requires_for_build   s     	D<DDDEEE<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--A14A1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 rj   )r   )rP   dus      r+   	<setcomp>z4ProjectBuilder.check_dependencies.<locals>.<setcomp>   s.    EEEa1A!1D1DEEAEEEEr-   )r   unionr   )rz   r   r   dependenciess       r+   check_dependenciesz!ProjectBuilder.check_dependencies   s?     22<QQWWX\XrssEE<EEEEr-   output_directoryrc   c                    t          j        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   prepare_metadata_for_build_F)_allow_fallbackN)r
   r   _call_backendr   rN   	exceptionrv   HookMissing)rz   r   r   r   r   s        r+   preparezProjectBuilder.prepare   s     	::::;;;
	%%<l<<  %	 &    % 	 	 	)-/JKK ttttt	s   6 
A+ A&%A&&A+metadata_directoryc                h    t          j        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   Nr   build_)r
   r   r   )rz   r   r   r   r   kwargss         r+   buildzProjectBuilder.build  s_    " 	.\...///)18LN`7a!t!"9<"9"9;K_gg`fgggr-   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 rL   )
startswith)rP   membermember_prefixs     r+   rR   z/ProjectBuilder.metadata_path.<locals>.<genexpr>?  s6      WWFf6G6G6V6VWWWWWWWr-   )r   r   r   r1   r2   basename
ValueErrorzipfileZipFile
extractallnamelistr4   )	rz   r   metadatar   matchr6   distinfowr   s	           @r+   metadata_pathzProjectBuilder.metadata_path%  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        |           | 	                    |          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 directory)r1   r2   rp   r   ry   r5   r3   r   makedirsr   r4   )rz   r   r   r   r   callbackr6   r   s           r+   r   zProjectBuilder._call_backendC  s4    ((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   2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)	rv   BackendUnavailabler   ru   sysr   
subprocessCalledProcessError	Exception)rz   r   r   s      r+   r   zProjectBuilder._handle_backendV  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 )r.   r   rm   r   r]   r   r    r!   )
r}   r~   r   r^   r.   r   r]   r   r    r   )r    r   )r    r   rL   )r   r   r   r   r    r   )r   r   r   r   r    r   )r   r   r   r   r   r   r    rc   ri   )
r   r   r   r   r   r   r   rc   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   
executablerv   default_subprocess_runnerr|   classmethodr   propertyr.   rm   r   r   r   r   r   r   r   
contextlibcontextmanagerr   rj   r-   r+   r   r      s         "%#2#L	(
 (
 (
 (
 (
T 
 $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r-   )r   r   r   r   r    r!   )r.   r   r    r!   )r2   r   r    r:   )r7   r:   r    r:   )r]   r   r   r^   r    r   )+
__future__r   r   r%   r1   r   r   r(   r   collections.abcr   typingr   r   r   r   rv    r
   r   _compatr   _exceptionsr   r   r   r   _typesr   r   r   r   _utilr   r   r   rU   r,   r9   rI   r\   rk   r   rj   r-   r+   <module>r      s!   # " " " " "      				     



   $ $ $ $ $ $ 2 2 2 2 2 2 2 2 2 2 2 2                              L K K K K K K K K K K K 9 9 9 9 9 9 9 9 7-5EFFF  8'(     " " " ", , , ,) ) ) )X" " " "dV dV dV dV dV dV dV dV dV dVr-   