
    h.                         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y)    N)contextmanager)abspath)join)STDOUT
check_callcheck_output   )_in_proc_script_pathc                 x    t        |dd      5 }t        j                  | |fi | d d d        y # 1 sw Y   y xY w)Nwutf-8encoding)openjsondump)objpathkwargsfs       JD:\EasyAligner\venv\Lib\site-packages\pip/_vendor/pyproject_hooks/_impl.py
write_jsonr      s/    	dC'	*a		#q#F# 
+	*	*s   09c                 r    t        | d      5 }t        j                  |      cd d d        S # 1 sw Y   y xY w)Nr   r   )r   r   load)r   r   s     r   	read_jsonr      s*    	dW	%yy| 	%	%s   -6c                       e Zd ZdZd Zy)BackendUnavailablezEWill be raised if the backend cannot be imported in the hook process.c                     || _         y N	tracebackselfr!   s     r   __init__zBackendUnavailable.__init__   	    "    N__name__
__module____qualname____doc__r$    r&   r   r   r      s
    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                 @    t         |   |       || _        || _        y r   )superr$   backend_namebackend_path)r#   r1   r2   message	__class__s       r   r$   zBackendInvalid.__init__   s     !((r&   r(   r)   r*   r+   r$   __classcell__r4   s   @r   r.   r.      s    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                 2    t         |   |       || _        y r   )r0   r$   	hook_name)r#   r;   r4   s     r   r$   zHookMissing.__init__'   s    #"r&   r5   r7   s   @r   r9   r9   %   s    H# #r&   r9   c                       e Zd ZdZd Zy)UnsupportedOperationzDMay be raised by build_sdist if the backend indicates that it can't.c                     || _         y r   r    r"   s     r   r$   zUnsupportedOperation.__init__.   r%   r&   Nr'   r,   r&   r   r=   r=   ,   s
    N#r&   r=   c                     t         j                  j                         }|r|j                  |       t	        | ||       y)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   s/    
 **//
C

=!s%r&   c                     t         j                  j                         }|r|j                  |       t	        | ||t
               y)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   >   s1    
 **//
C

=!#3v6r&   c                    t         j                  j                  |      rt        d      t         j                  j	                  |       }t         j                  j                  t         j                  j                  ||            }t         j                  j                  |      }t         j                  j                  |      }t         j                  j                  ||g      |k7  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     
ww}}Y122-JGG$$RWW\\*i%HIM ''"":.KWW%%m4N	ww[.9:k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y)BuildBackendHookCallerzFA wrapper to call the build backend hooks for a source directory.
    Nc                     |t         }t        |      | _        || _        |r#|D cg c]  }t	        | j                  |       }}|| _        || _        |st        j                  }|| _	        yc c}w )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
        N)
rI   r   
source_dirbuild_backendrY   r2   _subprocess_runnersys
executablepython_executable)r#   r]   r^   r2   runnerrb   ps          r   r$   zBuildBackendHookCaller.__init__f   sx      >.F!*-*<H<Hqt2L   )"(  #!2s   A-c              #   b   K   | j                   }|| _         	 d || _         y# || _         w xY w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)r_   )r#   rc   prevs      r   subprocess_runnerz(BuildBackendHookCaller.subprocess_runner   s3      &&"(	+&*D#dD#s   /# /	,/c                 &    | j                  di       S )z>Return the list of optional features supported by the backend._supported_features
_call_hook)r#   s    r   ri   z*BuildBackendHookCaller._supported_features   s    4b99r&   c                 *    | j                  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_settingsrj   r#   rn   s     r   rm   z3BuildBackendHookCaller.get_requires_for_build_wheel   s#     =@
  	r&   c                 @    | j                  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_directoryrn   _allow_fallbackrk   r   r#   rs   rn   rt   s       r   rq   z7BuildBackendHookCaller.prepare_metadata_for_build_wheel   s-      A")*<"=..D
  	r&   c                 Z    |t        |      }| j                  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.
        build_wheelwheel_directoryrn   rs   r   rk   r#   rz   rn   rs   s       r   rx   z"BuildBackendHookCaller.build_wheel   s<     )!();!<}&7."4/
  	r&   c                 *    | j                  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_editablern   rj   ro   s     r   r~   z6BuildBackendHookCaller.get_requires_for_build_editable   s#     @C
  	r&   c                 @    | j                  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_editablerr   ru   rv   s       r   r   z:BuildBackendHookCaller.prepare_metadata_for_build_editable   s-      D")*<"=..G
  	r&   c                 Z    |t        |      }| j                  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.
        build_editablery   r{   r|   s       r   r   z%BuildBackendHookCaller.build_editable   s=      )!();!</&7."42
  	r&   c                 *    | j                  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_sdistrn   rj   ro   s     r   r   z3BuildBackendHookCaller.get_requires_for_build_sdist  s#     =@
  	r&   c                 >    | j                  dt        |      |d      S )zBuild an sdist from this project.

        :returns:
            The name of the newly created sdist within ``wheel_directory``.
        build_sdist)sdist_directoryrn   ru   )r#   r   rn   s      r   r   z"BuildBackendHookCaller.build_sdist  s'     }&7./
  	r&   c           
         d| j                   i}| j                  r.t        j                  j	                  | j                        }||d<   t        j                         5 }d|i}t        |t        |d      d       t               5 }| j                  }| j                  |t        t        |            ||g| j                  |       d d d        t        t        |d            }	|	j!                  d	      rt#        |	j!                  d
d            |	j!                  d      rt%        |	j!                  d
d            |	j!                  d      r2t'        | j                   | j                  |	j!                  dd            |	j!                  d      rt)        |	j!                  d      xs |      |	d   cd d d        S # 1 sw Y   xY w# 1 sw Y   y xY w)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)r^   r2   rB   pathsepr   tempfileTemporaryDirectoryr   pjoinr
   rb   r_   r   strr]   r   getr=   r   r.   r9   )
r#   r;   r   rH   r2   td
hook_inputscriptpythondatas
             r   rk   z!BuildBackendHookCaller._call_hook)  s   /1C1CD::??4+<+<=L3?M/0((*b"F+Jz5\#:1E &'6//''WS[19bA"/ (  ( U2}56Dxx&*488K+DEExx%(+r)BCCxx)*$!%!3!3!%!2!2 HH_b9 
 xx'!$((+>"?"L9MM%5	& 	&
 (' +*s&   'GAF:C+G:G	?GG)NNNr   )NTNN)r(   r)   r*   r+   r$   r   rg   ri   rm   rq   rx   r~   r   r   r   r   rk   r,   r&   r   r[   r[   b   s}     "3> + +":  7; . 48#.  7; . 48#0	!&r&   r[   r   )r   rB   r`   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      sx     	 
  %  ! 7 7 -$

# #)Y )#) ##9 #	&	70h& h&r&   