ó
'—^c           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m	 Z	 d d l
 m Z d d l m Z d d l m Z m Z m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d l m Z d d l m Z e rzd d l m Z m  Z  m! Z! m" Z" m# Z# m$ Z$ m% Z% d d l& m' Z' d d l( m) Z) e  e) g e* f Z+ e% e" e) e" e) f Z, n  e j- e. ƒ Z/ e j0 d e j1 ƒ d „ Z2 d „  Z3 d „  Z4 d „  Z5 d „  Z6 d „  Z7 d „  Z8 d „  Z9 d „  Z: d „  Z; d „  Z< d S(   s;   Orchestrator for building wheels from InstallRequirements.
iÿÿÿÿN(   t   Link(   t   build_wheel_pep517(   t   build_wheel_legacy(   t
   indent_log(   t
   ensure_dirt	   hash_filet   is_wheel_installed(   t   make_setuptools_clean_args(   t   call_subprocess(   t   TempDirectory(   t   MYPY_CHECK_RUNNING(   t   path_to_url(   t   vcs(   t   Anyt   Callablet   Iterablet   Listt   Optionalt   Patternt   Tuple(   t
   WheelCache(   t   InstallRequirements   ([a-z0-9_.]+)-([a-z0-9_.!+-]+)c         C   s   t  | j |  ƒ ƒ S(   sj   Determine whether the string looks like an egg_info.

    :param s: The string to parse. E.g. foo-2.1
    (   t   boolt   search(   t   st   _egg_info_re(    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_internal/wheel_builder.pyt   _contains_egg_info&   s    c         C   s–   |  j  r t S|  j r6 | r2 t j d |  j ƒ n  t S| r@ t S|  j rX t ƒ  rX t S|  j	 sk |  j
 ro t S| |  ƒ s’ t j d |  j ƒ t St S(   sB   Return whether an InstallRequirement should be built into a wheel.s(   Skipping %s, due to already being wheel.sC   Skipping wheel build for %s, due to binaries being disabled for it.(   t
   constraintt   Falset   is_wheelt   loggert   infot   namet   Truet
   use_pep517R   t   editablet
   source_dir(   t   reqt
   need_wheelt   check_binary_allowed(    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_internal/wheel_builder.pyt   _should_build0   s&    		
c         C   s   t  |  d t d t ƒS(   NR&   R'   (   R(   R!   t   _always_true(   R%   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_internal/wheel_builder.pyt   should_build_for_wheel_commandY   s    c         C   s   t  |  d t d | ƒS(   NR&   R'   (   R(   R   (   R%   R'   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_internal/wheel_builder.pyt    should_build_for_install_commandb   s    c         C   s·   t  |  d t ƒs t S|  j rŽ |  j j rŽ |  j s; t ‚ |  j sJ t ‚ t j	 |  j j
 ƒ } | sk t ‚ | j |  j j |  j ƒ rŠ t St S|  j j ƒ  \ } } t | ƒ r³ t St S(   sÍ   
    Return whether a built InstallRequirement can be stored in the persistent
    wheel cache, assuming the wheel cache is available, and _should_build()
    has determined a wheel needs to be built.
    R'   (   R+   R)   R   t   linkt   is_vcsR#   t   AssertionErrorR$   R   t   get_backend_for_schemet   schemet   is_immutable_rev_checkoutt   urlR!   t   splitextR   (   R%   t   vcs_backendt   baset   ext(    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_internal/wheel_builder.pyt   _should_cachel   s    	c         C   sL   t  | j ƒ } | r6 t |  ƒ r6 | j |  j ƒ } n | j |  j ƒ } | S(   sd   Return the persistent or temporary cache directory where the built
    wheel need to be stored.
    (   R   t	   cache_dirR7   t   get_path_for_linkR,   t   get_ephem_path_for_link(   R%   t   wheel_cachet   cache_availableR8   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_internal/wheel_builder.pyt   _get_cache_dir   s
    c         C   s   t  S(   N(   R!   (   t   _(    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_internal/wheel_builder.pyR)   Ÿ   s    c      	   C   sb   y t  | ƒ Wn* t k
 r: } t j d |  j | ƒ d SX|  j  t |  | | | ƒ SWd QXd S(   sa   Build one wheel.

    :return: The filename of the built wheel, or None if the build failed.
    s    Building wheel for %s failed: %sN(   R   t   OSErrorR   t   warningR    t   Nonet	   build_envt   _build_one_inside_env(   R%   t
   output_dirt   build_optionst   global_optionst   e(    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_internal/wheel_builder.pyt
   _build_one¤   s    
c         C   so  t  d d ƒ Z} |  j rQ t d |  j d |  j d |  j d | d | j ƒ } n9 t d |  j d |  j d	 |  j	 d
 | d | d | j ƒ } | d  k	 rHt j j | ƒ } t j j | | ƒ } y\ t | ƒ \ } }	 t j | | ƒ t j d |  j | |	 | j ƒ  ƒ t j d | ƒ | SWqHt k
 rD}
 t j d |  j |
 ƒ qHXn  |  j sat |  | ƒ n  d  SWd  QXd  S(   Nt   kindt   wheelR    t   backendt   metadata_directoryRE   t   tempdt   setup_py_pathR$   RF   s3   Created wheel for %s: filename=%s size=%d sha256=%ss   Stored in directory: %ss    Building wheel for %s failed: %s(   R	   R"   R   R    t   pep517_backendRL   t   pathR   RN   t   unpacked_source_directoryRA   t   ost   basenamet   joinR   t   shutilt   moveR   R   t	   hexdigestt	   ExceptionR@   t   _clean_one_legacy(   R%   RD   RE   RF   t   temp_dirt
   wheel_patht
   wheel_namet	   dest_patht
   wheel_hasht   lengthRG   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_internal/wheel_builder.pyRC   ¿   sB    									c         C   so   t  |  j d | ƒ} t j d |  j ƒ y t | d |  j ƒt SWn% t k
 rj t j	 d |  j ƒ t
 SXd  S(   NRF   s   Running setup.py clean for %st   cwds    Failed cleaning build dir for %s(   R   RN   R   R   R    R   R$   R!   RX   t   errorR   (   R%   RF   t
   clean_args(    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_internal/wheel_builder.pyRY   ð   s    		c   	   
   C   sX  |  s g  g  f St  j d d j d „  |  Dƒ ƒ ƒ t ƒ    g  g  } } x‹ |  D]ƒ } t | | ƒ } t | | | | ƒ } | rÇ t t | ƒ ƒ | _ | j j	 | _
 | j j s· t ‚ | j | ƒ qQ | j | ƒ qQ WWd QX| rt  j d d j g  | D] } | j ^ qú ƒ ƒ n  | rNt  j d d j g  | D] } | j ^ q2ƒ ƒ n  | | f S(   s˜   Build wheels.

    :return: The list of InstallRequirement that succeeded to build and
        the list of InstallRequirement that failed to build.
    s*   Building wheels for collected packages: %ss   , c         s   s   |  ] } | j  Vq d  S(   N(   R    (   t   .0R%   (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_internal/wheel_builder.pys	   <genexpr>  s    Ns   Successfully built %st    s   Failed to build %s(   R   R   RT   R   R=   RH   R    R   R,   t	   file_patht   local_file_pathR   R.   t   appendR    (	   t   requirementsR;   RE   RF   t   build_successest   build_failuresR%   R8   t
   wheel_file(    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_internal/wheel_builder.pyt   build   s4    

))(=   t   __doc__t   loggingt   os.pathRR   t   reRU   t   pip._internal.models.linkR    t$   pip._internal.operations.build.wheelR   t+   pip._internal.operations.build.wheel_legacyR   t   pip._internal.utils.loggingR   t   pip._internal.utils.miscR   R   R   t$   pip._internal.utils.setuptools_buildR   t   pip._internal.utils.subprocessR   t   pip._internal.utils.temp_dirR	   t   pip._internal.utils.typingR
   t   pip._internal.utils.urlsR   t   pip._internal.vcsR   t   typingR   R   R   R   R   R   R   t   pip._internal.cacheR   t   pip._internal.req.req_installR   R   t   BinaryAllowedPredicatet   BuildResultt	   getLoggert   __name__R   t   compilet   IR   R(   R*   R+   R7   R=   R)   RH   RC   RY   Rl   (    (    (    s8   /tmp/pip-build-eiI0Wo/pip/pip/_internal/wheel_builder.pyt   <module>   sB   4		)			
	#				1	