ó
Ð²Ebc           @   sQ  d  Z  d d l Z d d l Z d d l Z d d l m Z m Z d d l m	 Z	 m
 Z d d l Z d d l m 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 e j e ƒ Z d „  Z d „  Z d „  Z d d „ Z! i d d 6d d 6d d 6d d 6Z" d „  Z# e d k rMe! ƒ  n  d S(   sH   Check a project and backend by attempting to build using PEP 517 hooks.
iÿÿÿÿN(   t   isfilet   join(   t   TomlDecodeErrort   load(   t   CalledProcessError(   t   mkdtempi   (   t   enable_colourful_output(   t   BuildEnvironment(   t   Pep517HookCallerc      	   C   sö  t  ƒ  ç} y | j | ƒ t j d ƒ Wn t k
 rK t j d ƒ t SXy# |  j i  ƒ } t j d | ƒ Wn% t k
 r– t j d d t	 ƒt SXy | j | ƒ t j d ƒ Wn t k
 rÖ t j d ƒ t SXt
 ƒ  } t j d | ƒ zç y& |  j | i  ƒ } t j d	 | ƒ Wn% t k
 r@t j d
 d t	 ƒt SX| j d ƒ sdt j d | ƒ t St | | ƒ } t | ƒ r’t j d | ƒ n t j d | ƒ t St j | ƒ rÅt j d ƒ n t j d ƒ t SWd  t j | ƒ Xt	 SWd  QXd  S(   Ns#   Installed static build dependenciess+   Failed to install static build dependenciess   Got build requires: %ss'   Failure in get_requires_for_build_sdistt   exc_infos$   Installed dynamic build dependenciess,   Failed to install dynamic build dependenciess   Trying to build sdist in %ss   build_sdist returned %rs   Failure in build_sdists   .tar.gzs*   Filename %s doesn't have .tar.gz extensions   Output file %s existss   Output file %s does not exists   Output file is a tar files   Output file is not a tar file(   R   t   pip_installt   logt   infoR   t   errort   Falset   get_requires_for_build_sdistt	   Exceptiont   TrueR   t   build_sdistt   endswitht   pjoinR    t   tarfilet
   is_tarfilet   shutilt   rmtree(   t   hookst   build_sys_requirest   envt   reqst   tdt   filenamet   path(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_vendor/pep517/check.pyt   check_build_sdist   sV    	
c      	   C   sö  t  ƒ  ç} y | j | ƒ t j d ƒ Wn t k
 rK t j d ƒ t SXy# |  j i  ƒ } t j d | ƒ Wn% t k
 r– t j d d t	 ƒt SXy | j | ƒ t j d ƒ Wn t k
 rÖ t j d ƒ t SXt
 ƒ  } t j d | ƒ zç y& |  j | i  ƒ } t j d	 | ƒ Wn% t k
 r@t j d
 d t	 ƒt SX| j d ƒ sdt j d | ƒ t St | | ƒ } t | ƒ r’t j d | ƒ n t j d | ƒ t St j | ƒ rÅt j d ƒ n t j d ƒ t SWd  t j | ƒ Xt	 SWd  QXd  S(   Ns#   Installed static build dependenciess+   Failed to install static build dependenciess   Got build requires: %ss'   Failure in get_requires_for_build_sdistR	   s$   Installed dynamic build dependenciess,   Failed to install dynamic build dependenciess   Trying to build wheel in %ss   build_wheel returned %rs   Failure in build_wheels   .whls'   Filename %s doesn't have .whl extensions   Output file %s existss   Output file %s does not exists   Output file is a zip files   Output file is not a zip file(   R   R
   R   R   R   R   R   t   get_requires_for_build_wheelR   R   R   t   build_wheelR   R   R    t   zipfilet
   is_zipfileR   R   (   R   R   R   R   R   R   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_vendor/pep517/check.pyt   check_build_wheelO   sT    	c         C   s)  t  |  d ƒ } t | ƒ r+ t j d ƒ n t j d ƒ t Sy_ t | ƒ  } t | ƒ } Wd  QX| d } | d } | d } | j d ƒ } t j d ƒ Wn+ t	 t
 f k
 rÈ t j d	 d
 t ƒt SXt |  | | ƒ } t | | ƒ }	 t | | ƒ }
 |	 st j d ƒ n  |
 s%t j d ƒ n  |	 S(   Ns   pyproject.tomls   Found pyproject.tomls   Missing pyproject.tomls   build-systemt   requiress   build-backends   backend-paths   Loaded pyproject.tomls   Invalid pyproject.tomlR	   s%   Sdist checks failed; scroll up to sees   Wheel checks failed(   R   R    R   R   R   R   t   opent	   toml_loadt   getR   t   KeyErrorR   R   R    R%   t   warning(   t
   source_dirt	   pyprojectt   ft   pyproject_datat   buildsysR&   t   backendt   backend_pathR   t   sdist_okt   wheel_ok(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_vendor/pep517/check.pyt   check‡   s0    


c         C   sz   t  j ƒ  } | j d d d ƒ| j |  ƒ } t ƒ  t | j ƒ } | r[ t d d ƒ GHn t d d ƒ GHt j	 d ƒ d  S(	   NR,   t   helps%   A directory containing pyproject.tomls   Checks passedt   greens   Checks failedt   redi   (
   t   argparset   ArgumentParsert   add_argumentt
   parse_argsR   R5   R,   t   ansit   syst   exit(   t   argvt   apt   argst   ok(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_vendor/pep517/check.pyt   main©   s    s   [0mt   resets   [1mt   bolds   [31mR8   s   [32mR7   c         C   sF   t  j d k r8 t j j ƒ  r8 t | t |  ƒ t d St |  ƒ Sd  S(   Nt   ntRE   (   t   ost   nameR>   t   stdoutt   isattyt
   ansi_codest   str(   t   st   attr(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_vendor/pep517/check.pyR=   Ã   s    t   __main__($   t   __doc__R9   t   loggingRH   t   os.pathR    R   R   t   pip._vendor.tomlR   R   R(   R   t
   subprocessR   R>   R   t   tempfileR   R#   t   colorlogR   t   envbuildR   t   wrappersR   t	   getLoggert   __name__R   R    R%   R5   t   NoneRD   RL   R=   (    (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_vendor/pep517/check.pyt   <module>   s6   	9	8	"
	