ó
Å1@]c           @   sÿ   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
 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 d d „ Z d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   contextmanagerN(   t   dirnamet   abspatht   join(   t
   check_call(   t   mkdtempi   (   t   compats   _in_process.pyc          c   s'   t  ƒ  }  z	 |  VWd  t j |  ƒ Xd  S(   N(   R   t   shutilt   rmtree(   t   td(    (    s:   lib/python2.7/site-packages/pip/_vendor/pep517/wrappers.pyt   tempdir   s    		t   BackendUnavailablec           B   s   e  Z d  Z RS(   sE   Will be raised if the backend cannot be imported in the hook process.(   t   __name__t
   __module__t   __doc__(    (    (    s:   lib/python2.7/site-packages/pip/_vendor/pep517/wrappers.pyR      s   t   UnsupportedOperationc           B   s   e  Z d  Z RS(   sD   May be raised by build_sdist if the backend indicates that it can't.(   R   R   R   (    (    (    s:   lib/python2.7/site-packages/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   (    (    s:   lib/python2.7/site-packages/pip/_vendor/pep517/wrappers.pyt   default_subprocess_runner   s    t   Pep517HookCallerc           B   sn   e  Z d  Z d „  Z e d „  ƒ Z d	 d „ Z d	 d „ Z d	 d	 d „ Z	 d	 d „ Z
 d	 d „ Z d „  Z RS(
   sæ   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.
    backend : The build backend spec, as per PEP 517, from pyproject.toml.
    c         C   s%   t  | ƒ |  _ | |  _ t |  _ d  S(   N(   R   t
   source_dirt   build_backendR   t   _subprocess_runner(   t   selfR   R   (    (    s:   lib/python2.7/site-packages/pip/_vendor/pep517/wrappers.pyt   __init__.   s    	c         c   s$   |  j  } | |  _  d  V| |  _  d  S(   N(   R   (   R   t   runnert   prev(    (    s:   lib/python2.7/site-packages/pip/_vendor/pep517/wrappers.pyt   subprocess_runner5   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#   (    (    s:   lib/python2.7/site-packages/pip/_vendor/pep517/wrappers.pyR"   <   s    
c         C   s$   |  j  d i t | ƒ d 6| d 6ƒ S(   sG  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.
        t    prepare_metadata_for_build_wheelt   metadata_directoryR#   (   R$   R   (   R   R&   R#   (    (    s:   lib/python2.7/site-packages/pip/_vendor/pep517/wrappers.pyR%   J   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#   R&   N(   t   NoneR   R$   (   R   R(   R#   R&   (    (    s:   lib/python2.7/site-packages/pip/_vendor/pep517/wrappers.pyR'   Y   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#   (    (    s:   lib/python2.7/site-packages/pip/_vendor/pep517/wrappers.pyR*   m   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   R,   R#   (    (    s:   lib/python2.7/site-packages/pip/_vendor/pep517/wrappers.pyR+   {   s    c         C   sï   t  j d d k r( |  j j d ƒ } n	 |  j } t ƒ  ¯ } t j i | d 6t | d ƒ d d ƒ|  j t  j	 t
 | | g d |  j d i | d	 6ƒt j t | d
 ƒ ƒ } | j d ƒ rÅ t ‚ n  | j d ƒ rİ t ‚ n  | d SWd  QXd  S(   Ni    i   t   ASCIIt   kwargss
   input.jsont   indentR   R   t   PEP517_BUILD_BACKENDs   output.jsont   unsupportedt
   no_backendt
   return_val(   t   syst   version_infoR   t   encodeR
   R   t
   write_jsont   pjoinR   t
   executablet   _in_proc_scriptR   t	   read_jsont   getR   R   (   R   t	   hook_nameR.   R   R	   t   data(    (    s:   lib/python2.7/site-packages/pip/_vendor/pep517/wrappers.pyR$   ‡   s     				N(   R   R   R   R   R    R!   R)   R"   R%   R'   R*   R+   R$   (    (    (    s:   lib/python2.7/site-packages/pip/_vendor/pep517/wrappers.pyR   (   s   	(   t
   contextlibR    R   t   os.pathR   R   R   R8   R   t
   subprocessR   R4   t   tempfileR   t    R   t   __file__R:   R
   t	   ExceptionR   R   R)   R   t   objectR   (    (    (    s:   lib/python2.7/site-packages/pip/_vendor/pep517/wrappers.pyt   <module>   s   		