
     d.                        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 d Zd	 Z G d
 de          Z G d de          Z G d de          Z G d de          ZddZddZd Z G d d          ZdS )    N)contextmanager)abspath)join)STDOUT
check_callcheck_output   )_in_proc_script_pathc                     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)objpathkwargsfs       jC:\Users\ChattiNader\Documents\MyHotelMatch\api\dev\Lib\site-packages\pip/_vendor/pyproject_hooks/_impl.py
write_jsonr      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   r   s     r   	read_jsonr      s    	dW	%	%	% y||                 s   377c                       e Zd ZdZd ZdS )BackendUnavailablezEWill be raised if the backend cannot be imported in the hook process.c                     || _         d S N	tracebackselfr!   s     r   __init__zBackendUnavailable.__init__       "    N__name__
__module____qualname____doc__r$    r&   r   r   r      s)        OO# # # # #r&   r   c                   "     e Zd ZdZ fdZ xZS )BackendInvalidz)Will be raised if the backend is invalid.c                 f    t                                          |           || _        || _        d S r   )superr$   backend_namebackend_path)r#   r1   r2   message	__class__s       r   r$   zBackendInvalid.__init__   s1    !!!((r&   r(   r)   r*   r+   r$   __classcell__r4   s   @r   r.   r.      s>        33) ) ) ) ) ) ) ) )r&   r.   c                   "     e Zd ZdZ fdZ xZS )HookMissingz>Will be raised on missing hooks (if a fallback can't be used).c                 X    t                                          |           || _        d S r   )r0   r$   	hook_name)r#   r;   r4   s     r   r$   zHookMissing.__init__'   s&    ###"r&   r5   r7   s   @r   r9   r9   %   s>        HH# # # # # # # # #r&   r9   c                       e Zd ZdZd ZdS )UnsupportedOperationzDMay be raised by build_sdist if the backend indicates that it can't.c                     || _         d S r   r    r"   s     r   r$   zUnsupportedOperation.__init__.   r%   r&   Nr'   r,   r&   r   r=   r=   ,   s)        NN# # # # #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.
    )cwdenvN)osenvironcopyupdater   cmdr@   extra_environrA   s       r   default_subprocess_runnerrI   2   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@   rA   stderrN)rB   rC   rD   rE   r   r   rF   s       r   quiet_subprocess_runnerrL   >   sL    
 *//

C "

=!!!#3v666666r&   c                    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)	rB   r   isabs
ValueErrorr   normpathr   normcasecommonprefix)source_tree	requested
abs_sourceabs_requestednorm_sourcenorm_requesteds         r   norm_and_checkrY   J   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Zed             Zd ZddZ	 	 ddZ		 	 dd	Z
dd
Z	 	 ddZ	 	 ddZddZddZd ZdS )BuildBackendHookCallerzFA wrapper to call the build backend hooks for a source directory.
    Nc                      |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,   )rY   
source_dir).0pr#   s     r   
<listcomp>z3BuildBackendHookCaller.__init__.<locals>.<listcomp>|   s2       78t22  r&   )	rI   r   r^   build_backendr2   _subprocess_runnersys
executablepython_executable)r#   r^   rb   r2   runnerrf   s   `     r   r$   zBuildBackendHookCaller.__init__f   s      >.F!*--* 	   <H  L )"(  	/ #!2r&   c              #   V   K   | j         }|| _         	 dV  || _         dS # || _         w xY w)a,  A context manager for temporarily overriding the default
        :ref:`subprocess runner <Subprocess Runners>`.

        .. code-block:: python

            hook_caller = BuildBackendHookCaller(...)
            with hook_caller.subprocess_runner(quiet_subprocess_runner):
                ...
        N)rc   )r#   rg   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   rl   z*BuildBackendHookCaller._supported_features   s    4b999r&   c                 2    |                      dd|i          S )a6  Get additional dependencies required for building a wheel.

        :returns: A list of :pep:`dependency specifiers <508>`.
        :rtype: list[str]

        .. admonition:: Fallback

            If the build backend does not defined a hook with this name, an
            empty list will be returned.
        get_requires_for_build_wheelconfig_settingsrm   r#   rq   s     r   rp   z3BuildBackendHookCaller.get_requires_for_build_wheel   s(     =@
   	r&   Tc                 P    |                      dt          |          ||d          S )a  Prepare a ``*.dist-info`` folder with metadata for this project.

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

        .. 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metadata_directoryrq   _allow_fallbackrn   r   r#   rv   rq   rw   s       r   rt   z7BuildBackendHookCaller.prepare_metadata_for_build_wheel   s;      A")*<"="=..D
 D
   	r&   c                 r    |t          |          }|                     dt          |          ||d          S )a  Build a wheel from this project.

        :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wheel_directoryrq   rv   r   rn   r#   r}   rq   rv   s       r   r{   z"BuildBackendHookCaller.build_wheel   sL     )!();!<!<}&77."4/
 /
   	r&   c                 2    |                      dd|i          S )a@  Get additional dependencies required for building an editable wheel.

        :returns: A list of :pep:`dependency specifiers <508>`.
        :rtype: list[str]

        .. admonition:: Fallback

            If the build backend does not defined a hook with this name, an
            empty list will be returned.
        get_requires_for_build_editablerq   rm   rr   s     r   r   z6BuildBackendHookCaller.get_requires_for_build_editable   s(     @C
   	r&   c                 P    |                      dt          |          ||d          S )a  Prepare a ``*.dist-info`` folder with metadata for this project.

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

        .. 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_editableru   rx   ry   s       r   r   z:BuildBackendHookCaller.prepare_metadata_for_build_editable   s;      D")*<"="=..G
 G
   	r&   c                 r    |t          |          }|                     dt          |          ||d          S )a  Build an editable wheel from this project.

        :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      )!();!<!</&77."42
 2
   	r&   c                 2    |                      dd|i          S )zGet additional dependencies required for building an sdist.

        :returns: A list of :pep:`dependency specifiers <508>`.
        :rtype: list[str]
        get_requires_for_build_sdistrq   rm   rr   s     r   r   z3BuildBackendHookCaller.get_requires_for_build_sdist  s(     =@
   	r&   c                 N    |                      dt          |          |d          S )zBuild an sdist from this project.

        :returns:
            The name of the newly created sdist within ``wheel_directory``.
        build_sdist)sdist_directoryrq   rx   )r#   r   rq   s      r   r   z"BuildBackendHookCaller.build_sdist  s4     }&77./
 /
   	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          r#t%          |	                    d
d                    |	                    d          r0t'          | j         | j        |	                    dd                    |	                    d          r$t)          |	                    d          p|          |	d         cd d d            S # 1 swxY w Y   d S )NPEP517_BUILD_BACKENDPEP517_BACKEND_PATHr   z
input.json   )indent)r@   rH   zoutput.jsonunsupportedr!    
no_backendbackend_invalidbackend_error)r1   r2   r3   hook_missingmissing_hook_name
return_val)rb   r2   rB   pathsepr   tempfileTemporaryDirectoryr   pjoinr
   rf   rc   r   strr^   r   getr=   r   r.   r9   )
r#   r;   r   rH   r2   td
hook_inputscriptpythondatas
             r   rn   z!BuildBackendHookCaller._call_hook)  s   /1CD 	@:??4+<==L3?M/0(** 	&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%% D(+r)B)BCCCxx)** $!%!3!%!2 HH_b99   
 xx'' N!$((+>"?"?"L9MMM%5	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&s8   3G9 ACG9C	G9C	DG99G= G=)NNNr   )NTNN)r(   r)   r*   r+   r$   r   rj   rl   rp   rt   r{   r   r   r   r   r   rn   r,   r&   r   r[   r[   b   s6         "3 3 3 3> + + ^+": : :     7;    . 48#   .     7;    . 48#   0   	 	 	 	!& !& !& !& !&r&   r[   r   )r   rB   rd   r   
contextlibr   os.pathr   r   r   
subprocessr   r   r   _in_processr
   r   r   	Exceptionr   r.   r9   r=   rI   rL   rY   r[   r,   r&   r   <module>r      s    				 



  % % % % % %       ! ! ! ! ! ! 7 7 7 7 7 7 7 7 7 7 - - - - - -$ $ $
  
# # # # # # # #) ) ) ) )Y ) ) )# # # # #) # # ## # # # #9 # # #	& 	& 	& 	&	7 	7 	7 	7  0h& h& h& h& h& h& h& h& h& h&r&   