
j^c           @   sg  d  Z  d d l Z d d l Z d d l Z d d l m Z d d l Z d d l m Z d d l	 m
 Z
 d d l m Z m Z d d l m Z e j e  Z d	   Z d
   Z d   Z d   Z d d d  Z e j   Z e j d d d e j d d d d d e e j d d d d d e e j d d d d d   Z e d k rce e j    n  d S(   s%   Build a project using PEP 517 hooks.
iN(   t   tomli   (   t   BuildEnvironment(   t   Pep517HookCaller(   t   tempdirt   mkdir_p(   t   FileNotFoundErrorc         C   sM   d d h } | t  |   k sI d j d | t  |    } t |   n  d S(   s7   
    Ensure build system has the requisite fields.
    t   requiress   build-backends"   Missing required fields: {missing}t   missingN(   t   sett   formatt
   ValueError(   t   systemt   requiredt   message(    (    s)   site-packages/pip/_vendor/pep517/build.pyt   validate_system   s
    	c         C   sA   t  j j |  d  } t |   } t j |  } Wd QX| d S(   sC   
    Load the build system from a source dir (pyproject.toml).
    s   pyproject.tomlNs   build-system(   t   ost   patht   joint   openR    t   load(   t
   source_dirt	   pyprojectt   ft   pyproject_data(    (    s)   site-packages/pip/_vendor/pep517/build.pyt   load_system   s    c         C   sZ   y t  |   } Wn t t f k
 r/ i  } n X| j d d  | j d d d g  | S(   s   
    Given a source dir, attempt to get a build system backend
    and requirements from pyproject.toml. Fallback to
    setuptools but only if the file was not found or a build
    system was not indicated.
    s   build-backends    setuptools.build_meta:__legacy__R   t
   setuptoolst   wheel(   R   R   t   KeyErrort
   setdefault(   R   R   (    (    s)   site-packages/pip/_vendor/pep517/build.pyt   compat_system'   s    
c      
   C   s   d j  t     } t |  |  } | i   } t j d |  | j |  t j d  t    } t j d | |  d j  t     } t |  |  }	 |	 | i   }
 t j j	 | |
  } t
 j | t j j	 | t j j |
    Wd  QXd  S(   Ns   get_requires_for_build_{dist}s   Got build requires: %ss$   Installed dynamic build dependenciess   Trying to build %s in %ss   build_{dist}(   R	   t   localst   getattrt   logt   infot   pip_installR   R   R   R   t   shutilt   movet   basename(   t   hookst   envt   distt   destt   get_requires_namet   get_requirest   reqst   tdt
   build_namet   buildt   filenamet   source(    (    s)   site-packages/pip/_vendor/pep517/build.pyt	   _do_build:   s    c      	   C   s   | p t  |   } t j j |  | p' d  } t |  t |  t |  | d | j d   } t   + } | j	 | d  t
 | | | |  Wd  QXd  S(   NR(   s   build-backends   backend-pathR   (   R   R   R   R   R   R   R   t   getR   R"   R2   (   R   R(   R)   R   R&   R'   (    (    s)   site-packages/pip/_vendor/pep517/build.pyR/   L   s    

R   t   helps%   A directory containing pyproject.tomls   --binarys   -bt   actiont
   store_truet   defaults   --sources   -ss	   --out-dirs   -os>   Destination in which to save the builds relative to source dirc         C   sx   t  t d  |  j s |  j r" d n d  |  j s8 |  j r> d n d  f   } x$ | D] } t |  j | |  j  qT Wd  S(   Nt   sdistR   (   t   listt   filtert   NoneR1   t   binaryR/   R   t   out_dir(   t   argst   distsR(   (    (    s)   site-packages/pip/_vendor/pep517/build.pyt   mainp   s
    	(t   __main__(   t   __doc__t   argparset   loggingR   t   pip._vendorR    R#   t   envbuildR   t   wrappersR   t   dirtoolsR   R   t   compatR   t	   getLoggert   __name__R    R   R   R   R2   R;   R/   t   ArgumentParsert   parsert   add_argumentt   FalseR@   t
   parse_args(    (    (    s)   site-packages/pip/_vendor/pep517/build.pyt   <module>   sB   		
						