
    dJ                    f   U d Z ddlmZ d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 ddlmZmZ ddlmZmZmZmZmZmZmZmZmZ ddlZded	<   d
ed<   e
j         dk    rddl!m"Z" ddl!m#Z$ n%	 ddl%m"Z" ddl%m#Z$ n# e&$ r ddl'm(Z" ddl'm#Z$ Y nw xY weee)         ee)         eee)e)f                  gdf         Z*ee)ee)ee)         f         f         Z+ee)df         Z,eeee-         e-ej.        f         ed         f         Z/ ej0        d          Z1dddgdZ2 ej3        e4          Z5 G d de6          Z7 G d de6          Z8 G d de7          Z9 G d de6          Z: G d d e;          Z<d<d%Z=d& e>            fd=d.Z?d>d2Z@d?d6ZA G d7 d8          ZBg d9ZCd@d;ZDdS )Az2
build - A simple, correct PEP 517 build frontend
    )annotationsz0.10.0N)OrderedDict)IteratorSet)	AnyCallableMappingMutableMappingOptionalSequenceTupleTypeUnionztype[Exception]TOMLDecodeErrorz)Callable[[str], MutableMapping[str, Any]]
toml_loads)      )r   )loads)TomlDecodeErrorzos.PathLike[str]NNNzv(?P<distribution>.+)-(?P<version>.+)(-(?P<build_tag>.+))?-(?P<python_tag>.+)-(?P<abi_tag>.+)-(?P<platform_tag>.+)\.whlz setuptools.build_meta:__legacy__zsetuptools >= 40.8.0wheel)build-backendrequiresc                      e Zd ZdZdS )BuildExceptionz5
    Exception raised by :class:`ProjectBuilder`
    N__name__
__module____qualname____doc__     R/home/feoh/.local/pipx/venvs/poetry/lib/python3.11/site-packages/build/__init__.pyr   r   D              r"   r   c                  0     e Zd ZdZ	 dd fdZddZ xZS )BuildBackendExceptionz9
    Exception raised when a backend operation fails
    Nr   	exception	Exceptiondescription
str | Noneexc_info_ExcInfoTypereturnNonec                r    t                                                       || _        || _        || _        d S N)super__init__r'   r+   _description)selfr'   r)   r+   	__class__s       r#   r2   zBuildBackendException.__init__O   s7     	" 'r"   strc                2    | j         r| j         S d| j        S )NzBackend operation failed: )r3   r'   r4   s    r#   __str__zBuildBackendException.__str__W   s&     	%$$>DN>>>r"   )Nr   )r'   r(   r)   r*   r+   r,   r-   r.   r-   r6   r   r   r   r    r2   r9   __classcell__r5   s   @r#   r&   r&   J   sg         
 ^p( ( ( ( ( ( (? ? ? ? ? ? ? ?r"   r&   c                      e Zd ZdZddZdS )BuildSystemTableValidationErrorzZ
    Exception raised when the ``[build-system]`` table in pyproject.toml is invalid.
    r-   r6   c                "    d| j         d          S )Nz5Failed to validate `build-system` in pyproject.toml: r   )argsr8   s    r#   r9   z'BuildSystemTableValidationError.__str__b   s    UtyQR|UUUr"   Nr:   )r   r   r   r    r9   r!   r"   r#   r?   r?   ]   s8         V V V V V Vr"   r?   c                  ,     e Zd ZdZd
 fdZdd	Z xZS )FailedProcessErrorzG
    Exception raised when an setup or prepration operation fails.
    r'   subprocess.CalledProcessErrorr)   r6   r-   r.   c                d    t                                                       || _        || _        d S r0   )r1   r2   r'   r3   )r4   r'   r)   r5   s      r#   r2   zFailedProcessError.__init__k   s.    "'r"   c                   d                     | j        j                  }| j         d| d| j        j         }dD ]L}t          | j        |          }|r3|d| dz  }|t          j        |                                d          z  }M|S )N z
  Command 'z' failed with return code )stdoutstderrz
  z:
z    )	joinr'   cmdr3   
returncodegetattrtextwrapindentdecode)r4   rK   r)   stream_namestreams        r#   r9   zFailedProcessError.__str__p   s    hht~)***ssssX\XfXqss/ 	H 	HKT^[99F H6k6666xv}}GGGr"   )r'   rD   r)   r6   r-   r.   r:   r;   r=   s   @r#   rC   rC   f   s[         ( ( ( ( ( (
       r"   rC   c                      e Zd ZdZdS )TypoWarningz6
    Warning raised when a possible typo is found
    Nr   r!   r"   r#   rT   rT   {   r$   r"   rT   srcdirPathTyper-   r.   c                   t           j                            |           st          d|  d          t           j                            | d          }t           j                            | d          }t           j                            |          s2t           j                            |          st          d|  d          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   rJ   exists)rU   pyproject_tomlsetup_pys      r#   _validate_source_directoryr_      s    7==   DBvBBBCCCW\\&*:;;Nw||FJ//H7>>.)) w"'..2J2J wuvuuuvvvw w w wr"   r!   
req_stringr6   ancestral_req_stringstuple[str, ...]parent_extrasSet[str]Iterator[tuple[str, ...]]c              #  f  	K   ddl }t          j        dk    rddlm} nddl}|j                            |           	t          	          }||v rdS 	j	        r?t          d                              |          }t          	fd|D                       rdS 	 |                    	j                  }	j        r+	j                            |j        d          s
||fz   V  dS |j        r*|j        D ]$}t'          |||fz   	j                  E d{V  #dS dS # |j        $ r ||fz   V  Y dS w xY w)z
    Verify that a dependency and all of its dependencies are met.

    :param req_string: Requirement string
    :param parent_extras: Extras (eg. "test" in myproject[test])
    :yields: Unmet dependencies
    r   Nr      ) c              3  T   K   | ]"}j                             d |i           V  #dS )extra)environmentN)markerevaluate).0ereqs     r#   	<genexpr>z#check_dependency.<locals>.<genexpr>   s=      QQQ3:&&GQ<&@@@QQQQQQr"   T)prereleases)packaging.requirementssysversion_infoimportlib.metadatametadataimportlib_metadatarequirementsRequirementr6   rm   	frozensetunionalldistributionname	specifiercontainsversionr   check_dependencyextrasPackageNotFoundError)
r`   ra   rc   	packagingry   normalised_req_stringr   distother_req_stringrq   s
            @r#   r   r      s      "!!!
6!!7777777!!!!

 
,
,Z
8
8CHH  555
z 5!!''66 QQQQ&QQQQQ 	 F|!..sx88
 = 	|!7!7RV!7!W!W 	|'+@*BBBBBBB] 	|$(M | | +,<>SWlVn>npspz{{{{{{{{{{	| 	|| | 2 ? ? ?#'<&>>>>>>>>?s   D D0/D0
dictionaryMapping[str, str]expectedc                    | D ]O}t          j        d ||                                          dk    r!t          j        d| d| dt
                     Pd S )Ng?zFound 'z#' in pyproject.toml, did you mean 'z'?)difflibSequenceMatcherratiowarningswarnrT   )r   r   objs      r#   
_find_typor      so      "4377==??3FFMN#NN(NNN   r"   r]   Mapping[str, Any]dict[str, Any]c                   d| vrt          | d           t          S t          | d                   }d|vrt          |d           t          d          t	          |d         t
                    rt          d |d         D                       st          d          d|vr!t          |d           t          d         |d<   n*t	          |d         t                    st          d          d|v rIt	          |d         t
                    rt          d	 |d         D                       st          d
          |                                h dz
  }|r%t          dd	                    |                     |S )Nzbuild-systemr   z!`requires` is a required propertyc              3  @   K   | ]}t          |t                    V  d S r0   
isinstancer6   ro   is     r#   rr   z,_parse_build_system_table.<locals>.<genexpr>   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 r0   r   r   s     r#   rr   z,_parse_build_system_table.<locals>.<genexpr>   s,      RR!:a%%RRRRRRr"   z*`backend-path` must be an array of strings>   r   r   r   zUnknown properties: z, )
r   _DEFAULT_BACKENDdictr?   r   listr~   r6   keysrJ   )r]   build_system_tableunknown_propss      r#   _parse_build_system_tabler      s    ^++>>222n^<== +++%z222-.QRRR*:6== XS I I$6z$BI I I F F X ..VWWW000%777 /?.O?++*?;SAA R-.PQQQ+++).94@@ ,RR/A./QRRRRR , ..Z[[[&++--0]0]0]]M a-._TYY}E]E]._._```r"   c                  `   e Zd ZdZej        dej        fd1dZd2d3dZ	e
d4d            Ze
d4d            Zej        d5d            Ze
d6d            Zej        d7d            Ze
d8d            Zd9d:dZd9d;d!Z	 d9d<d#Z	 	 d2d=d%Zd>d&Z	 d9d?d+Zej        d@d.            ZedAd0            ZdS )BProjectBuilderz#
    The PEP 517 consumer API.
    NrU   rV   python_executabler6   scripts_dirr*   runner
RunnerTyper-   r.   c                   t           j                            |          | _        t	          |           t           j                            |d          }	 t          |d          5 }t          |                                	                                          }ddd           n# 1 swxY w Y   na# t          $ r i }Y nSt          $ r$}t          |j         d|j         d          d}~wt          $ r}t          d| d| d          d}~ww xY wt!          |          | _        | j        d	         | _        || _        || _        t+          j        | j        | j        | j                            d
          || j                  | _        dS )a  
        :param srcdir: The source directory
        :param scripts_dir: The location of the scripts dir (defaults to the folder where the python executable lives)
        :param python_executable: The python executable where the backend lives
        :param runner: An alternative 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 srcdir.
        - 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.
        rX   rbNz: 'z' zFailed to parse z: rG   r   r   )backend_pathr   r   )rY   rZ   abspath_srcdirr_   rJ   openr   readrP   FileNotFoundErrorPermissionErrorr   strerrorfilenamer   r   _build_system_backend_scripts_dir_hook_runnerpyproject_hooksBuildBackendHookCallerrU   get_runner_hook)	r4   rU   r   r   r   	spec_filefspecrp   s	            r#   r2   zProjectBuilder.__init__   s   2 GOOF33"6***GLL)9::		Gi&& 5!!!&&((//"3"3445 5 5 5 5 5 5 5 5 5 5 5 5 5 5  	 	 	DDD 	C 	C 	C AJ!A!A1:!A!A!ABBB 	G 	G 	G !EI!E!E!E!E!EFFF	G 7t<<*?;'"$;KM+//??/<
 
 



sN   B1 %4B%B1 %B))B1 ,B)-B1 1D?	DC''D4D

DrK   Sequence[str]cwdextra_environMapping[str, str] | Nonec                   | j         t                      }d |t          | j                   <   dt          j        v rL|                    d t          j        d                             t          j                  D                        |i nt          |          }t          j        	                    |          |d<   | 
                    |||           d S )NPATHc              3     K   | ]}|d fV  	d S r0   r!   r   s     r#   rr   z)ProjectBuilder._runner.<locals>.<genexpr>+  s&      UU1aYUUUUUUr"   )r   r   r6   rY   environupdatesplitpathsepr   rJ   r   )r4   rK   r   r   pathss        r#   r   zProjectBuilder._runner%  s    '%0]]E+/E#d&''(##UU
60B0H0H0T0TUUUUUU"/"7BBT-=P=PM$&JOOE$:$:M&!#sM22222r"   c                    | j         S )zProject source directory.)r   r8   s    r#   rU   zProjectBuilder.srcdir0  s     |r"   c                    | j         j        }|S )zC
        The Python executable used to invoke the backend.
        r   r   )r4   exes     r#   r   z ProjectBuilder.python_executable5  s     :/
r"   valuec                    || j         _        d S r0   r   r4   r   s     r#   r   z ProjectBuilder.python_executable>  s    ',
$$$r"   c                    | j         S )zT
        The folder where the scripts are stored for the python executable.
        r   r8   s    r#   r   zProjectBuilder.scripts_dirB  s    
   r"   c                    || _         d S r0   r   r   s     r#   r   zProjectBuilder.scripts_dirI  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   )setr   r8   s    r#   build_system_requiresz$ProjectBuilder.build_system_requiresM  s     4%j1222r"   r   config_settingsConfigSettingsType | Nonec                    |                      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)logrM   r   _handle_backendr   )r4   r   r   	hook_nameget_requiress        r#   get_requires_for_buildz%ProjectBuilder.get_requires_for_buildV  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..A25A2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 r!   )r   )ro   dus      r#   	<setcomp>z4ProjectBuilder.check_dependencies.<locals>.<setcomp>q  s.    EEEa1A!1D1DEEAEEEEr"   )r   r}   r   )r4   r   r   dependenciess       r#   check_dependenciesz!ProjectBuilder.check_dependenciesf  s?     22<QQWWX\XrssEE<EEEEr"   output_directoryc                    |                      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   _call_backendr&   r   r'   r   HookMissing)r4   r   r   r   r'   s        r#   preparezProjectBuilder.prepares  s     	::::;;;
	%%<l<<  %	 &    % 	 	 	)-/JKK ttttt	s   7 
A,A'&A''A,metadata_directoryc                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   )r4   r   r   r   r   kwargss         r#   buildzProjectBuilder.build  sa    " 	.\...///)18LN`7a!t!"9<"9"9;K_gg`fgggr"   c                &   |                      d|          }||S |                     d|          }t                              t          j                            |                    }|st          d          |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
        r   NzInvalid wheelr   -r   z
.dist-info/c              3  F   K   | ]}|                               |V  d S r0   )
startswith)ro   membermember_prefixs     r#   rr   z/ProjectBuilder.metadata_path.<locals>.<genexpr>  s6      WWFf6G6G6V6VWWWWWWWr"   )r   r   _WHEEL_NAME_REGEXmatchrY   rZ   basename
ValueErrorzipfileZipFile
extractallnamelistrJ   )r4   r   rx   r   r  distinfowr  s          @r#   metadata_pathzProjectBuilder.metadata_path  sQ    <<)9::O 

7$455!''(8(8(?(?@@ 	._---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                            |          r3t           j                            |          st          d| d          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)rY   rZ   r   rM   r   r\   r[   r   makedirsr   rJ   )r4   r   r  r   r   callbackr  s          r#   r   zProjectBuilder._call_backend  s2    ((4:y117>>&!! 	 7==(( ]$%[F%[%[%[\\\] 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   0CCChookIterator[None]c              #  @  K   	 d V  d S # t           j        $ r0}t          |d| j         dt	          j                              d }~wt          j        $ r}t          |d|           d }~wt          $ r'}t          |t	          j                              d }~ww xY w)Nz	Backend 'z' is not available.z0Backend subprocess exited when trying to invoke )r+   )	r   BackendUnavailabler&   r   ru   r+   
subprocessCalledProcessErrorr(   )r4   r  r'   s      r#   r   zProjectBuilder._handle_backend  s      	LEEEEE1 	 	 	'>DM>>>  
 , 	 	 	'TdTT    	L 	L 	L'	CLNNKKKK	Ls,   
 B+ABA))B6"BBmessagec                    t           j        dk    r)t                              t          j        | d           dS t                              t          j        |            dS )z
        Log a message.

        The default implementation uses the logging module but this function can be
        overridden by users to have a different implementation.

        :param message: Message to output
        rg      )
stacklevelN)ru   rv   _loggerr   loggingINFO)r  s    r#   r   zProjectBuilder.log  sN     v%%KKg!K<<<<<KKg.....r"   )
rU   rV   r   r6   r   r*   r   r   r-   r.   )NN)rK   r   r   r*   r   r   r-   r.   r:   )r   r6   r-   r.   )r-   r*   )r   r*   r-   r.   )r-   r   r0   )r   r6   r   r   r-   r   )r   r6   r   r   r-   r   )r   r6   r   rV   r   r   r-   r*   )
r   r6   r   rV   r   r   r   r*   r-   r6   )r   rV   r-   r6   )
r   r6   r  rV   r   r   r   r   r-   r6   )r  r6   r-   r  )r  r6   r-   r.   )r   r   r   r    ru   
executabler   default_subprocess_runnerr2   r   propertyrU   r   setterr   r   r   r   r   r   r  r   
contextlibcontextmanagerr   staticmethodr   r!   r"   r#   r   r      s"         "%"&,F2
 2
 2
 2
 2
h	3 	3 	3 	3 	3    X    X - - - - ! ! ! X! " " " " 3 3 3 X36 6 6 6 6 F F F F F ko    8 6:)-h h h h h*8 8 8 8< ^b. . . . .$ L L L L  / / / \/ / /r"   r   )
__version__r?   r&   r   ConfigSettingsTyperC   r   r   rT   r   	list[str]c                     t           S r0   )__all__r!   r"   r#   __dir__r+    s    Nr"   )rU   rV   r-   r.   )r`   r6   ra   rb   rc   rd   r-   re   )r   r   r   r6   r-   r.   )r]   r   r-   r   )r-   r(  )Er    
__future__r   r&  r#  r   r  rY   rer  ru   rN   typesr   r  collectionsr   collections.abcr   r   typingr   r   r	   r
   r   r   r   r   r   r   __annotations__rv   tomllibr   r   r   tomliModuleNotFoundErrortomlr   r6   r   r'  rV   BaseExceptionTracebackTyper,   compiler  r   	getLoggerr   r  r(   r   r&   r?   rC   WarningrT   r_   r|   r   r   r   r   r*  r+  r!   r"   r#   <module>r<     sL     # " " " " "        				 				     



     # # # # # # ) ) ) ) ) ) ) ) a a a a a a a a a a a a a a a a a a a a a a     !       5 5 5 5w''''''+++++++-))))))------- - - -;;;;;;,,,,,,,,-
 x}hsmXgc3h>O5PQSWWX
S%Xc](:";;< (()U4.u?RRSUZ[kUllm BJ2   8'1   '
H
%
%    Y   ? ? ? ? ?I ? ? ?&V V V V Vn V V V       *    '   w w w w ?A\e\e\g\g/| /| /| /| /|d   $ $ $ $NA/ A/ A/ A/ A/ A/ A/ A/H       s   B B$#B$