ó
'—^c           @   st  d  d l  Z  d  d l m Z d  d l Z d  d l m Z m Z m Z d  d l	 Z	 d  d l
 m Z m Z m Z d  d l Z d  d l m Z d d l m Z e e e e ƒ ƒ d ƒ Z e d	 „  ƒ Z d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d d d „ Z d d d „ Z d „  Z d e f d „  ƒ  YZ  d e  j! f d „  ƒ  YZ" d S(   iÿÿÿÿN(   t   contextmanager(   t   dirnamet   abspatht   join(   t
   check_callt   check_outputt   STDOUT(   t   mkdtempi   (   t   compats   _in_process.pyc          c   s'   t  ƒ  }  z	 |  VWd  t j |  ƒ Xd  S(   N(   R   t   shutilt   rmtree(   t   td(    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyt   tempdir   s    		t   BackendUnavailablec           B   s   e  Z d  Z d „  Z RS(   sE   Will be raised if the backend cannot be imported in the hook process.c         C   s   | |  _  d  S(   N(   t	   traceback(   t   selfR   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyt   __init__   s    (   t   __name__t
   __module__t   __doc__R   (    (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyR      s   t   BackendInvalidc           B   s   e  Z d  Z d „  Z RS(   s)   Will be raised if the backend is invalid.c         C   s   | |  _  | |  _ | |  _ d  S(   N(   t   backend_namet   backend_patht   message(   R   R   R   R   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyR       s    		(   R   R   R   R   (    (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyR      s   t   HookMissingc           B   s   e  Z d  Z d „  Z RS(   s    Will be raised on missing hooks.c         C   s#   t  t |  ƒ j | ƒ | |  _ d  S(   N(   t   superR   R   t	   hook_name(   R   R   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyR   (   s    (   R   R   R   R   (    (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyR   &   s   t   UnsupportedOperationc           B   s   e  Z d  Z d „  Z RS(   sD   May be raised by build_sdist if the backend indicates that it can't.c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyR   /   s    (   R   R   R   R   (    (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyR   -   s   c         C   s?   t  j j ƒ  } | r% | j | ƒ n  t |  d | d | ƒd S(   s5   The default method of calling the wrapper subprocess.t   cwdt   envN(   t   ost   environt   copyt   updateR   (   t   cmdR   t   extra_environR   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyt   default_subprocess_runner3   s    c         C   sE   t  j j ƒ  } | r% | j | ƒ n  t |  d | d | d t ƒd S(   sD   A method of calling the wrapper subprocess while suppressing output.R   R   t   stderrN(   R   R   R    R!   R   R   (   R"   R   R#   R   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyt   quiet_subprocess_runner<   s    c         C   s©   t  j j | ƒ r! t d ƒ ‚ n  t  j j |  ƒ } t  j j t  j j | | ƒ ƒ } t  j j | ƒ } t  j j | ƒ } t  j j | | g ƒ | k r¥ t d ƒ ‚ n  | S(   sè   Normalise 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.
    s   paths must be relatives    paths must be inside source tree(	   R   t   patht   isabst
   ValueErrorR   t   normpathR   t   normcaset   commonprefix(   t   source_treet	   requestedt
   abs_sourcet   abs_requestedt   norm_sourcet   norm_requested(    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyt   norm_and_checkE   s    !t   Pep517HookCallerc           B   sw   e  Z d  Z d	 d	 d „ Z e d „  ƒ Z d	 d „ Z d	 e d „ Z	 d	 d	 d „ Z
 d	 d „ Z d	 d „ Z d „  Z RS(
   se  A wrapper around a source directory to be built with a PEP 517 backend.

    source_dir : The path to the source directory, containing pyproject.toml.
    build_backend : The build backend spec, as per PEP 517, from
        pyproject.toml.
    backend_path : The backend path, as per PEP 517, from pyproject.toml.
    runner : A callable that invokes the wrapper subprocess.

    The 'runner', if provided, must expect the following:
        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.
    c         C   sq   | d  k r t } n  t | ƒ |  _ | |  _ | r[ g  | D] } t |  j | ƒ ^ q: } n  | |  _ | |  _ d  S(   N(   t   NoneR$   R   t
   source_dirt   build_backendR3   R   t   _subprocess_runner(   R   R6   R7   R   t   runnert   p(    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyR   n   s    		(	c         c   s$   |  j  } | |  _  d V| |  _  d S(   s\   A context manager for temporarily overriding the default subprocess
        runner.
        N(   R8   (   R   R9   t   prev(    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyt   subprocess_runnerƒ   s    		c         C   s   |  j  d i | d 6ƒ S(   sG  Identify packages required for building a wheel

        Returns a list of dependency specifications, e.g.:
            ["wheel >= 0.25", "setuptools"]

        This does not include requirements specified in pyproject.toml.
        It returns the result of calling the equivalently named hook in a
        subprocess.
        t   get_requires_for_build_wheelt   config_settings(   t
   _call_hook(   R   R>   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyR=      s    
c         C   s+   |  j  d i t | ƒ d 6| d 6| d 6ƒ S(   sq  Prepare a *.dist-info folder with metadata for this project.

        Returns the name of the newly created folder.

        If the build backend defines a hook with this name, it will be called
        in a subprocess. If not, the backend will be asked to build a wheel,
        and the dist-info extracted from that (unless _allow_fallback is
        False).
        t    prepare_metadata_for_build_wheelt   metadata_directoryR>   t   _allow_fallback(   R?   R   (   R   RA   R>   RB   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyR@   ›   s    c         C   sF   | d k	 r t | ƒ } n  |  j d i t | ƒ d 6| d 6| d 6ƒ S(   sv  Build a wheel from this project.

        Returns the name of the newly created file.

        In general, this will call the 'build_wheel' hook in the backend.
        However, if that was previously called by
        'prepare_metadata_for_build_wheel', and the same metadata_directory is
        used, the previously built wheel will be copied to wheel_directory.
        t   build_wheelt   wheel_directoryR>   RA   N(   R5   R   R?   (   R   RD   R>   RA   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyRC   ­   s    c         C   s   |  j  d i | d 6ƒ S(   s<  Identify packages required for building a wheel

        Returns a list of dependency specifications, e.g.:
            ["setuptools >= 26"]

        This does not include requirements specified in pyproject.toml.
        It returns the result of calling the equivalently named hook in a
        subprocess.
        t   get_requires_for_build_sdistR>   (   R?   (   R   R>   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyRE   Á   s    
c         C   s$   |  j  d i t | ƒ d 6| d 6ƒ S(   s£   Build an sdist from this project.

        Returns the name of the newly created file.

        This calls the 'build_sdist' backend hook in a subprocess.
        t   build_sdistt   sdist_directoryR>   (   R?   R   (   R   RG   R>   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyRF   Ï   s    c   	      C   sÒ  t  j d d k r( |  j j d ƒ } n	 |  j } i | d 6} |  j r” t j j |  j ƒ } t  j d d k r‡ | j t  j ƒ  ƒ } n  | | d <n  t	 ƒ  /} i | d 6} t
 j | t | d ƒ d d ƒ|  j t  j t | | g d	 |  j d
 | ƒt
 j t | d ƒ ƒ } | j d ƒ r9t | j d d ƒ ƒ ‚ n  | j d ƒ rct | j d d ƒ ƒ ‚ n  | j d ƒ r¢t d |  j d |  j d | j d d ƒ ƒ ‚ n  | j d ƒ rÀt | ƒ ‚ n  | d SWd  QXd  S(   Ni    i   t   ASCIIt   PEP517_BUILD_BACKENDt   PEP517_BACKEND_PATHt   kwargss
   input.jsont   indentR   R#   s   output.jsont   unsupportedR   t    t
   no_backendt   backend_invalidR   R   R   t   backend_errort   hook_missingt
   return_val(   t   syst   version_infoR7   t   encodeR   R   t   pathsepR   t   getfilesystemencodingR   R   t
   write_jsont   pjoinR8   t
   executablet   _in_proc_scriptR6   t	   read_jsont   getR   R   R   R   (	   R   R   RK   R7   R#   R   R   t
   hook_inputt   data(    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyR?   Û   s<    					N(   R   R   R   R5   R   R    R<   R=   t   TrueR@   RC   RE   RF   R?   (    (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyR4   ]   s   
t   LoggerWrapperc           B   sA   e  Z d  Z d „  Z d „  Z e d „  ƒ Z d „  Z d „  Z RS(   sd   
    Read messages from a pipe and redirect them
    to a logger (see python's logging module).
    c         C   sf   t  j j |  ƒ t |  _ | |  _ | |  _ t j ƒ  \ |  _	 |  _
 t j |  j	 ƒ |  _ |  j ƒ  d  S(   N(   t	   threadingt   ThreadR   Ra   t   daemont   loggert   levelR   t   pipet   fd_readt   fd_writet   fdopent   readert   start(   R   Rf   Rg   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyR     s    			c         C   s   |  j  S(   N(   Rj   (   R   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyt   fileno  s    c         C   s   |  j  t j ƒ r |  d  S|  S(   Niÿÿÿÿ(   t   endswithR   t   linesep(   t   msg(    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyt   remove_newline!  s    c         C   s.   x' |  j  D] } |  j |  j | ƒ ƒ q
 Wd  S(   N(   Rl   t   _writeRr   (   R   t   line(    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyt   run%  s    c         C   s   |  j  j |  j | ƒ d  S(   N(   Rf   t   logRg   (   R   R   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyRs   )  s    (	   R   R   R   R   Rn   t   staticmethodRr   Ru   Rs   (    (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyRb     s   			(#   Rc   t
   contextlibR    R   t   os.pathR   R   R   RZ   R	   t
   subprocessR   R   R   RT   t   tempfileR   RN   R   t   __file__R\   R   t	   ExceptionR   R   R   R   R5   R$   R&   R3   t   objectR4   Rd   Rb   (    (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_vendor/pep517/wrappers.pyt   <module>   s&   				®