ó
Ð²Ebc           @   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.
iÿÿÿÿN(   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(    (    s5   /tmp/pip-build-UPPWic/pip/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(    (    s5   /tmp/pip-build-UPPWic/pip/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   (    (    s5   /tmp/pip-build-UPPWic/pip/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(    (    s5   /tmp/pip-build-UPPWic/pip/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'   (    (    s5   /tmp/pip-build-UPPWic/pip/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(   (    (    s5   /tmp/pip-build-UPPWic/pip/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(    (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_vendor/pep517/build.pyt   <module>   sB   		
						