
    .PhX:              
           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 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mZmZ ddlmZ erd d	lmZ  G d
 de          Zdeeef         deddfdZdedeeef         fdZ G d de          Z G d de          Z G d de          Z	 	 d!dee         dee         deeeef                  ddfdZ 	 	 d!dee         dee         deeeef                  ddfdZ!dededefdZ" G d d           Z#dS )"    N)contextmanager)abspath)join)STDOUT
check_callcheck_output)TYPE_CHECKINGAnyIteratorMappingOptionalSequence   )_in_proc_script_path)Protocolc            
       d    e Zd ZdZ	 	 ddee         dee         deeeef                  ddfdZdS )	SubprocessRunnerz%A protocol for the subprocess runner.Ncmdcwdextra_environreturnc                     d S N )selfr   r   r   s       U/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pyproject_hooks/_impl.py__call__zSubprocessRunner.__call__   s	     C    NN)	__name__
__module____qualname____doc__r   strr   r   r   r   r   r   r   r      sw        33
 "&9=		 	#	 #	 $GCH$56		
 	 	 	 	 	 	r   r   objpathr   c                     t          |dd          5 }t          j        | |fi | d d d            d S # 1 swxY w Y   d S )Nwutf-8encoding)openjsondump)r%   r&   kwargsfs       r   
write_jsonr1      s    	dC'	*	*	* $a	#q##F###$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $s   488c                     t          | d          5 }t          j        |          cd d d            S # 1 swxY w Y   d S )Nr)   r*   )r,   r-   load)r&   r0   s     r   	read_jsonr4   !   s    	dW	%	%	% y||                 s   377c                   p     e Zd ZdZ	 	 	 d	dedee         dee         deee                  ddf
 fdZ xZS )
BackendUnavailablezEWill be raised if the backend cannot be imported in the hook process.N	tracebackmessagebackend_namebackend_pathr   c                 x    || _         || _        || _        t                                          |pd           d S )NzError while importing backend)r9   r:   r7   super__init__)r   r7   r8   r9   r:   	__class__s        r   r=   zBackendUnavailable.__init__)   s@     )("C$CDDDDDr   NNN)	r    r!   r"   r#   r$   r   r   r=   __classcell__r>   s   @r   r6   r6   &   s        OO
 "&&*04E EE #E sm	E
 x}-E 
E E E E E E E E E Er   r6   c                   ,     e Zd ZdZdeddf fdZ xZS )HookMissingz>Will be raised on missing hooks (if a fallback can't be used).	hook_namer   Nc                 X    t                                          |           || _        d S r   )r<   r=   rD   )r   rD   r>   s     r   r=   zHookMissing.__init__:   s&    ###"r   )r    r!   r"   r#   r$   r=   r@   rA   s   @r   rC   rC   7   sQ        HH## #$ # # # # # # # # # #r   rC   c                   "    e Zd ZdZdeddfdZdS )UnsupportedOperationzDMay be raised by build_sdist if the backend indicates that it can't.r7   r   Nc                     || _         d S r   )r7   )r   r7   s     r   r=   zUnsupportedOperation.__init__B   s    "r   )r    r!   r"   r#   r$   r=   r   r   r   rG   rG   ?   s<        NN## #$ # # # # # #r   rG   r   r   r   c                     t           j                                        }|r|                    |           t	          | ||           dS )zwThe default method of calling the wrapper subprocess.

    This uses :func:`subprocess.check_call` under the hood.
    )r   envN)osenvironcopyupdater   r   r   r   rJ   s       r   default_subprocess_runnerrP   F   sJ     *//

C "

=!!!s%%%%%%r   c                     t           j                                        }|r|                    |           t	          | ||t
                     dS )zqCall the subprocess while suppressing output.

    This uses :func:`subprocess.check_output` under the hood.
    )r   rJ   stderrN)rK   rL   rM   rN   r   r   rO   s       r   quiet_subprocess_runnerrS   V   sL     *//

C "

=!!!#3v666666r   source_tree	requestedc                    t           j                            |          rt          d          t           j                            |           }t           j                            t           j                            ||                    }t           j                            |          }t           j                            |          }t           j                            ||g          |k    rt          d          |S )zNormalise and check a backend path.

    Ensure that the requested backend path is specified as a relative path,
    and resolves to a location under the given source tree.

    Return an absolute version of the requested path.
    zpaths must be relativez paths must be inside source tree)	rK   r&   isabs
ValueErrorr   normpathr   normcasecommonprefix)rT   rU   
abs_sourceabs_requestednorm_sourcenorm_requesteds         r   norm_and_checkr`   f   s     
w}}Y 31222--JG$$RW\\*i%H%HIIM '"":..KW%%m44N	w[.9::kII;<<<r   c                      e Zd ZdZ	 	 	 ddededeee                  ded         dee         d	dfd
Zeddd	e	d         fd            Z
d	ee         fdZ	 ddeeeef                  d	ee         fdZ	 	 d dedeeeef                  ded	efdZ	 	 d!dedeeeef                  dee         d	efdZ	 ddeeeef                  d	ee         fdZ	 	 d dedeeeef                  ded	ee         fdZ	 	 d!dedeeeef                  dee         d	efdZ	 ddeeeef                  d	ee         fdZ	 ddedeeeef                  d	efdZdedeeef         d	efdZdS )"BuildBackendHookCallerzAA wrapper to call the build backend hooks for a source directory.N
source_dirbuild_backendr:   runnerr   python_executabler   c                      |t           }t          |           _        | _        |r fd|D             }| _        | _        |st          j        }| _        dS )a  
        :param source_dir: The source directory to invoke the build backend for
        :param build_backend: The build backend spec
        :param backend_path: Additional path entries for the build backend spec
        :param runner: The :ref:`subprocess runner <Subprocess Runners>` to use
        :param python_executable:
            The Python executable used to invoke the build backend
        Nc                 :    g | ]}t          j        |          S r   )r`   rc   ).0pr   s     r   
<listcomp>z3BuildBackendHookCaller.__init__.<locals>.<listcomp>   s%    UUU1N4?A>>UUUr   )	rP   r   rc   rd   r:   _subprocess_runnersys
executablerf   )r   rc   rd   r:   re   rf   s   `     r   r=   zBuildBackendHookCaller.__init__   sv      >.F!*--* 	VUUUUUUUL("(  	/ #!2r   c              #   V   K   | j         }|| _         	 dV  || _         dS # || _         w xY w)ay  A context manager for temporarily overriding the default
        :ref:`subprocess runner <Subprocess Runners>`.

        :param runner: The new subprocess runner to use within the context.

        .. code-block:: python

            hook_caller = BuildBackendHookCaller(...)
            with hook_caller.subprocess_runner(quiet_subprocess_runner):
                ...
        N)rl   )r   re   prevs      r   subprocess_runnerz(BuildBackendHookCaller.subprocess_runner   sH       &"(	+EEE&*D###dD#****s    	(c                 .    |                      di           S )z>Return the list of optional features supported by the backend._supported_features
_call_hook)r   s    r   rs   z*BuildBackendHookCaller._supported_features   s    4b999r   config_settingsc                 2    |                      dd|i          S )am  Get additional dependencies required for building a wheel.

        :param config_settings: The configuration settings for the build backend
        :returns: A list of :pep:`dependency specifiers <508>`.

        .. admonition:: Fallback

            If the build backend does not defined a hook with this name, an
            empty list will be returned.
        get_requires_for_build_wheelrv   rt   r   rv   s     r   rx   z3BuildBackendHookCaller.get_requires_for_build_wheel   s%     *->,P
 
 	
r   Tmetadata_directory_allow_fallbackc                 P    |                      dt          |          ||d          S )aS  Prepare a ``*.dist-info`` folder with metadata for this project.

        :param metadata_directory: The directory to write the metadata to
        :param config_settings: The configuration settings for the build backend
        :param _allow_fallback:
            Whether to allow the fallback to building a wheel and extracting
            the metadata from it. Should be passed as a keyword argument only.

        :returns: Name of the newly created subfolder within
                  ``metadata_directory``, containing the metadata.

        .. admonition:: Fallback

            If the build backend does not define a hook with this name and
            ``_allow_fallback`` is truthy, the backend will be asked to build a
            wheel via the ``build_wheel`` hook and the dist-info extracted from
            that will be returned.
         prepare_metadata_for_build_wheelrz   rv   r{   ru   r   r   rz   rv   r{   s       r   r}   z7BuildBackendHookCaller.prepare_metadata_for_build_wheel   s9    0 .&-.@&A&A#2#2 
 
 	
r   wheel_directoryc                 r    |t          |          }|                     dt          |          ||d          S )a  Build a wheel from this project.

        :param wheel_directory: The directory to write the wheel to
        :param config_settings: The configuration settings for the build backend
        :param metadata_directory: The directory to reuse existing metadata from
        :returns:
            The name of the newly created wheel within ``wheel_directory``.

        .. admonition:: Interaction with fallback

            If the ``build_wheel`` hook was called in the fallback for
            :meth:`prepare_metadata_for_build_wheel`, the build backend would
            not be invoked. Instead, the previously built wheel will be copied
            to ``wheel_directory`` and the name of that file will be returned.
        Nbuild_wheelr   rv   rz   r   ru   r   r   rv   rz   s       r   r   z"BuildBackendHookCaller.build_wheel   sM    * )!();!<!<#*?#;#;#2&8 
 
 	
r   c                 2    |                      dd|i          S )aw  Get additional dependencies required for building an editable wheel.

        :param config_settings: The configuration settings for the build backend
        :returns: A list of :pep:`dependency specifiers <508>`.

        .. admonition:: Fallback

            If the build backend does not defined a hook with this name, an
            empty list will be returned.
        get_requires_for_build_editablerv   rt   ry   s     r   r   z6BuildBackendHookCaller.get_requires_for_build_editable	  s%     -0A?/S
 
 	
r   c                 P    |                      dt          |          ||d          S )aU  Prepare a ``*.dist-info`` folder with metadata for this project.

        :param metadata_directory: The directory to write the metadata to
        :param config_settings: The configuration settings for the build backend
        :param _allow_fallback:
            Whether to allow the fallback to building a wheel and extracting
            the metadata from it. Should be passed as a keyword argument only.
        :returns: Name of the newly created subfolder within
                  ``metadata_directory``, containing the metadata.

        .. admonition:: Fallback

            If the build backend does not define a hook with this name and
            ``_allow_fallback`` is truthy, the backend will be asked to build a
            wheel via the ``build_editable`` hook and the dist-info
            extracted from that will be returned.
        #prepare_metadata_for_build_editabler~   r   r   s       r   r   z:BuildBackendHookCaller.prepare_metadata_for_build_editable  s9    . 1&-.@&A&A#2#2 
 
 	
r   c                 r    |t          |          }|                     dt          |          ||d          S )a  Build an editable wheel from this project.

        :param wheel_directory: The directory to write the wheel to
        :param config_settings: The configuration settings for the build backend
        :param metadata_directory: The directory to reuse existing metadata from
        :returns:
            The name of the newly created wheel within ``wheel_directory``.

        .. admonition:: Interaction with fallback

            If the ``build_editable`` hook was called in the fallback for
            :meth:`prepare_metadata_for_build_editable`, the build backend
            would not be invoked. Instead, the previously built wheel will be
            copied to ``wheel_directory`` and the name of that file will be
            returned.
        Nbuild_editabler   r   r   s       r   r   z%BuildBackendHookCaller.build_editable;  sM    , )!();!<!<#*?#;#;#2&8 
 
 	
r   c                 2    |                      dd|i          S )zGet additional dependencies required for building an sdist.

        :returns: A list of :pep:`dependency specifiers <508>`.
        get_requires_for_build_sdistrv   rt   ry   s     r   r   z3BuildBackendHookCaller.get_requires_for_build_sdist\  s%     *->,P
 
 	
r   sdist_directoryc                 N    |                      dt          |          |d          S )zBuild an sdist from this project.

        :returns:
            The name of the newly created sdist within ``wheel_directory``.
        build_sdist)r   rv   r   )r   r   rv   s      r   r   z"BuildBackendHookCaller.build_sdisth  s5     #*?#;#;#2 
 
 	
r   rD   r/   c           
         d| j         i}| j        r)t          j                            | j                  }||d<   t          j                    5 }d|i}t          |t          |d          d           t                      5 }| j
        }|                     |t          t          |                    ||g| j        |           d d d            n# 1 swxY w Y   t          t          |d                    }	|	                    d	          r#t#          |	                    d
d                    |	                    d          rEt%          |	                    d
d          |	                    dd          | j         | j                  |	                    d          r$t'          |	                    d          p|          |	d         cd d d            S # 1 swxY w Y   d S )N_PYPROJECT_HOOKS_BUILD_BACKEND_PYPROJECT_HOOKS_BACKEND_PATHr/   z
input.json   )indent)r   r   zoutput.jsonunsupportedr7    
no_backendbackend_error)r8   r9   r:   hook_missingmissing_hook_name
return_val)rd   r:   rK   pathsepr   tempfileTemporaryDirectoryr1   pjoinr   rf   rl   r   r$   rc   r4   getrG   r6   rC   )
r   rD   r/   r   r:   td
hook_inputscriptpythondatas
             r   ru   z!BuildBackendHookCaller._call_hookz  s^   94;MN 	J:??4+<==L=IM9:(** 	&b"F+Jz5\#:#:1EEEE &'' 6/''WS[[119bA"/ (                  U2}5566Dxx&& F*488K+D+DEEExx%% (HH["-- HH_b99!%!3!%!2	    xx'' N!$((+>"?"?"L9MMM%3	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&s8   3G ACGC	GC	C2GGGr?   r   )NTr   )r    r!   r"   r#   r$   r   r   r=   r   r   rq   rs   r   r
   rx   boolr}   r   r   r   r   r   r   ru   r   r   r   rb   rb   ~   s       KK 15/3+/3 33 3 x}-	3
 +,3 $C=3 
3 3 3 3: +(: +x~ + + + ^+&:Xc] : : : : 8<
 
!'#s("34
 
#
 
 
 
* 8< $	
 

 "'#s("34
 	

 

 
 
 
H 8<,0	
 

 "'#s("34
 %SM	

 

 
 
 
D 8<
 
!'#s("34
 
#
 
 
 
* 8< $	
 

 "'#s("34
 	

 
#
 
 
 
F 8<,0	
 

 "'#s("34
 %SM	

 

 
 
 
F 8<

 

!'#s("34

 
#

 

 

 

 8<
 

 "'#s("34
 
	
 
 
 
$ &C  &c1B  &s  &  &  &  &  &  &r   rb   r   )$r-   rK   rm   r   
contextlibr   os.pathr   r   r   
subprocessr   r   r   typingr	   r
   r   r   r   r   _in_processr   r   r   r$   r1   r4   	Exceptionr6   rC   rG   rP   rS   r`   rb   r   r   r   <module>r      s    				 



  % % % % % %       ! ! ! ! ! ! 7 7 7 7 7 7 7 7 7 7 L L L L L L L L L L L L L L L L - - - - - - 	 	 	 	 	8 	 	 	$GCH% $S $t $ $ $ $
C GCH-    
E E E E E E E E"# # # # #) # # ## # # # #9 # # # 15& &	#&	#& GCH-.& 
	& & & &$ 157 7	#7	#7 GCH-.7 
	7 7 7 7       0\& \& \& \& \& \& \& \& \& \&r   