ó
Ð²Ebc           @   s  d  Z  d d l Z d d l 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 m Z d d l 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 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+ d d l, m- Z- e' ròd d l. m/ Z/ m0 Z0 m1 Z1 m2 Z2 m3 Z3 m4 Z4 d d l5 m6 Z6 d d l7 m8 Z8 e0 e8 g e9 f Z: e4 e2 e8 e2 e8 f Z; n  e j< e= ƒ Z> e j? d e j@ ƒ ZA d „  ZB d „  ZC d „  ZD d „  ZE d „  ZF d „  ZG d „  ZH d „  ZI d  „  ZJ d! „  ZK d" „  ZL d# „  ZM d$ „  ZN d S(%   s;   Orchestrator for building wheels from InstallRequirements.
iÿÿÿÿN(   t   canonicalize_namet   canonicalize_version(   t   InvalidVersiont   Version(   t   Distribution(   t   InvalidWheelFilenamet   UnsupportedWheel(   t   Link(   t   Wheel(   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$   pkg_resources_distribution_for_wheel(   t   vcs(   t   Anyt   Callablet   Iterablet   Listt   Optionalt   Tuple(   t
   WheelCache(   t   InstallRequirements   ([a-z0-9_.]+)-([a-z0-9_.!+-]+)c         C   s   t  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   _egg_info_ret   search(   t   s(    (    s8   /tmp/pip-build-UPPWic/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 sS |  j rW t S| |  ƒ sz t j d |  j ƒ t S|  j	 r¥ t
 ƒ  r¥ 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.sO   Using legacy 'setup.py install' for %s, since package 'wheel' is not installed.(   t
   constraintt   Falset   is_wheelt   loggert   infot   namet   Truet   editablet
   source_dirt
   use_pep517R   (   t   reqt
   need_wheelt   check_binary_allowed(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/wheel_builder.pyt   _should_build4   s,    		

c         C   s   t  |  d t d t ƒS(   NR.   R/   (   R0   R)   t   _always_true(   R-   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/wheel_builder.pyt   should_build_for_wheel_commanda   s    c         C   s   t  |  d t d | ƒS(   NR.   R/   (   R0   R$   (   R-   R/   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/wheel_builder.pyt    should_build_for_install_commandj   s    c         C   sÇ   |  j  s |  j r t S|  j r |  j j r |  j  s< t ‚ |  j sK t ‚ t j |  j j ƒ } | sl t ‚ | j	 |  j j
 |  j ƒ r‹ t St S|  j sž t ‚ |  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$   t   linkt   is_vcst   AssertionErrorR   t   get_backend_for_schemet   schemet   is_immutable_rev_checkoutt   urlR)   t   splitextR"   (   R-   t   vcs_backendt   baset   ext(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/wheel_builder.pyt   _should_cachet   s    	c         C   s[   t  | j ƒ } |  j s t ‚ | rE t |  ƒ rE | 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_dirR4   R6   R?   t   get_path_for_linkt   get_ephem_path_for_link(   R-   t   wheel_cachet   cache_availableR@   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/wheel_builder.pyt   _get_cache_dir•   s    c         C   s   t  S(   N(   R)   (   t   _(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/wheel_builder.pyR1   ¦   s    c         C   sž   x‹ |  j  |  j ƒ D]w } | j ƒ  j d ƒ r | j d d ƒ d j ƒ  } y t | ƒ SWqŠ t k
 r† d j | ƒ } t	 | ƒ ‚ qŠ Xq q Wt	 d ƒ ‚ d  S(   Ns   metadata-version:t   :i   iÿÿÿÿs   Invalid Metadata-Version: {}s   Missing Metadata-Version(
   t   get_metadata_linest   PKG_INFOt   lowert
   startswitht   splitt   stripR   R   t   formatR   (   t   distt   linet   valuet   msg(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/wheel_builder.pyt   _get_metadata_version«   s    c         C   s  t  |  j ƒ } t t j j | ƒ ƒ } t  | j ƒ | k rZ t d j | | j ƒ ƒ ‚ n  t j	 | d t
 ƒ } t | | | ƒ } Wd  QXt | j ƒ t | j ƒ k rÉ t d j | j | j ƒ ƒ ‚ n  t | ƒ t d ƒ k rt | j t ƒ rt d j | j ƒ ƒ ‚ n  d  S(   Ns7   Wheel has unexpected file name: expected {!r}, got {!r}t
   allowZip64s   1.2s6   Metadata 1.2 mandates PEP 440 version, but {!r} is not(   R    R(   R   t   ost   patht   basenameR   RN   t   zipfilet   ZipFileR)   R   R   t   versionRS   R   t
   isinstancet   parsed_versionR   (   R-   t
   wheel_patht   canonical_namet   wt   zfRO   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/wheel_builder.pyt   _verify_one¸   s$    c      	   C   s·   y t  | ƒ Wn* t k
 r: } t j d |  j | ƒ d SX|  j  t |  | | | ƒ } Wd QX| r³ | r³ y t |  | ƒ Wq³ t	 t
 f k
 r¯ } t j d |  j | ƒ d SXn  | S(   sa   Build one wheel.

    :return: The filename of the built wheel, or None if the build failed.
    s    Building wheel for %s failed: %sNs!   Built wheel for %s is invalid: %s(   R   t   OSErrorR&   t   warningR(   t   Nonet	   build_envt   _build_one_inside_envRa   R   R   (   R-   t
   output_dirt   verifyt   build_optionst   global_optionst   eR]   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/wheel_builder.pyt
   _build_oneÒ   s"    
c         C   s  t  d d ƒ x} |  j s! t ‚ |  j ro |  j s9 t ‚ t d |  j d |  j d |  j d | d | j ƒ } n9 t d |  j d |  j	 d	 |  j
 d
 | d | d | j ƒ } | d  k	 rft j j | ƒ } t j j | | ƒ } y\ t | ƒ \ } }	 t j | | ƒ t j d |  j | |	 | j ƒ  ƒ t j d | ƒ | SWqft k
 rb}
 t j d |  j |
 ƒ qfXn  |  j st |  | ƒ n  d  SWd  QXd  S(   Nt   kindt   wheelR(   t   backendt   metadata_directoryRi   t   tempdt   setup_py_pathR+   Rj   s3   Created wheel for %s: filename=%s size=%d sha256=%ss   Stored in directory: %ss    Building wheel for %s failed: %s(   R   R(   R6   R,   Rp   R	   t   pep517_backendRV   R
   Rr   t   unpacked_source_directoryRd   RU   RW   t   joinR   t   shutilt   moveR&   R'   t	   hexdigestt	   ExceptionRc   t   _clean_one_legacy(   R-   Rg   Ri   Rj   t   temp_dirR]   t
   wheel_namet	   dest_patht
   wheel_hasht   lengthRk   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/wheel_builder.pyRf   õ   sF    									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(   NRj   s   Running setup.py clean for %st   cwds    Failed cleaning build dir for %s(   R   Rr   R&   R'   R(   R   R+   R)   Ry   t   errorR$   (   R-   Rj   t
   clean_args(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/wheel_builder.pyRz   (  s    		c   
      C   s[  |  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  | rQt  j d d j g  | D] } | j ^ q5ƒ ƒ 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-UPPWic/pip/pip/_internal/wheel_builder.pys	   <genexpr>K  s    Ns   Successfully built %st    s   Failed to build %s(   R&   R'   Ru   R   RE   Rl   R   R   R4   t	   file_patht   local_file_pathR%   R6   t   appendR(   (
   t   requirementsRC   Rh   Ri   Rj   t   build_successest   build_failuresR-   R@   t
   wheel_file(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/wheel_builder.pyt   build8  s4    

))(O   t   __doc__t   loggingt   os.pathRU   t   reRv   RX   t   pip._vendor.packaging.utilsR    R   t   pip._vendor.packaging.versionR   R   t   pip._vendor.pkg_resourcesR   t   pip._internal.exceptionsR   R   t   pip._internal.models.linkR   t   pip._internal.models.wheelR   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.utils.wheelR   t   pip._internal.vcsR   t   typingR   R   R   R   R   R   t   pip._internal.cacheR   t   pip._internal.req.req_installR   R   t   BinaryAllowedPredicatet   BuildResultt	   getLoggert   __name__R&   t   compilet
   IGNORECASER   R"   R0   R2   R3   R?   RE   R1   RS   Ra   Rl   Rf   Rz   RŒ   (    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/wheel_builder.pyt   <module>   sV   .			-			
	!					#	3	