ó
^†êWc           @   sQ  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
 m Z m Z m Z m Z d d l m Z m Z d d l m Z d	 „  Z d d l Z d
 e f d „  ƒ  YZ d „  Z e d „ Z e e d „ Z d „  Z d „  Z d d „ Z d d e e e d „ Z d „  Z  d „  Z! d „  Z" d „  Z# d S(   s   
Wheel command-line utility.
iÿÿÿÿN(   t   iglobi   (   t
   signatures(   t   urlsafe_b64decodet   urlsafe_b64encodet   nativet   binaryt   matches_requirement(   t	   WheelFilet   VerifyingZipFile(   t   get_install_commandc         C   s=   y d d  l  } Wn& t k
 r8 t d j |  ƒ ƒ ‚ n Xd  S(   Niÿÿÿÿs/   '{0}' needs pkg_resources (part of setuptools).(   t   pkg_resourcest   ImportErrort   RuntimeErrort   format(   t   nameR
   (    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt   require_pkgresources   s    t
   WheelErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyR      s    c          C   sh   y5 d d l  m }  d d  l } | j ƒ  j s4 t ‚ Wn# t t f k
 rZ t d ƒ ‚ n X|  j | f S(   Ni   (   t   keysiÿÿÿÿsQ   Install wheel[signatures] (requires keyring, keyrings.alt, pyxdg) for signatures.(	   R   R   t   keyringt   get_keyringt   priorityt   AssertionErrorR   R   t	   WheelKeys(   R   R   (    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyR      s    c   
      C   s%  |  ƒ  \ } } t  j ƒ  } | ƒ  j ƒ  } | j ƒ  } t t | j ƒ ƒ } t t | j ƒ ƒ } | j ƒ  } | j	 d | | ƒ t
 j j d j | ƒ ƒ t
 j j d j | ƒ ƒ | j d | ƒ }	 |	 | k rÞ t d ƒ ‚ n  t
 j j d j | ƒ ƒ | j d | ƒ | j d | ƒ | j ƒ  d S(   s#   Generate a public/private key pair.t   wheels$   Created Ed25519 keypair with vk={0}
s	   in {0!r}
s1   Keyring is broken. Could not retrieve secret key.s.   Trusting {0} to sign and verify all packages.
t   +N(   R   t   get_ed25519llt   loadt   crypto_sign_keypairR   R   t   vkt   skR   t   set_passwordt   syst   stdoutt   writeR   t   get_passwordR   t
   add_signert   trustt   save(
   R   R   R   t	   ed25519llt   wkt   keypairR   R   t   krt   sk2(    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt   keygen%   s"    c         C   s”  | ƒ  \ } } t  j ƒ  } t |  d t ƒ} | ƒ  j ƒ  } | j j d ƒ } | j | ƒ d }	 t j	 j
 d j | |	 d ƒ ƒ |	 d }
 | j ƒ  } | j d |
 ƒ } | j t t |
 ƒ ƒ t t | ƒ ƒ ƒ } | j d } | j d } | | j j ƒ  k rt d	 ƒ ‚ n  | j j | ƒ } i d
 t t t j | ƒ j ƒ  ƒ ƒ d 6} t  j | | ƒ } | j j | t j | d t ƒƒ | j j ƒ  d S(   s   Sign a wheelt   appendR   i    s   Signing {0} with {1}
i   R   s   /RECORDs   /RECORD.jwss   Wheel is already signed.s   sha256=t   hasht	   sort_keysN(    R   R   R   t   TrueR   t   parsed_filenamet   groupt   signersR!   R"   R#   R   R   R$   t   KeypairR   R   t   distinfo_namet   zipfilet   namelistR   t   readR   R   t   hashlibt   sha256t   digestt   signt   writestrt   jsont   dumpst   close(   t	   wheelfilet   replaceR   R   R   R(   t   wfR)   R   t	   sign_withR   R+   R   R*   t   record_namet   sig_namet   record_datat   payloadt   sig(    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyR=   >   s*     
,"c         C   sd   t  |  d ƒ } | j ƒ  } t | ƒ o: | d j j d ƒ sL t d ƒ ‚ n  | j ƒ  | j ƒ  d S(   s$  
    Remove RECORD.jws from a wheel by truncating the zip file.

    RECORD.jws must be at the end of the archive. The zip file must be an
    ordinary archive, with the compressed files and the directory in the same
    order, and without any non-zip content after the truncation point.
    t   aiÿÿÿÿs   /RECORD.jwss'   RECORD.jws not found at end of archive.N(   R   t   infolistt   lent   filenamet   endswithR   t   popRA   (   RB   t   vzft   info(    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt   unsign\   s    "
c         C   s’   t  |  ƒ } | j d } t j t | j j | ƒ j ƒ  ƒ ƒ } t j	 | ƒ } t
 j j d ƒ t
 j j t j | d d ƒƒ t
 j j d ƒ d S(   sÌ   Verify a wheel.

    The signature will be verified for internal consistency ONLY and printed.
    Wheel's own unpack/install commands verify the manifest against the
    signature and file contents.
    s   /RECORD.jwss&   Signatures are internally consistent.
t   indenti   s   
N(   R   R6   R?   t   loadsR   R7   t   openR9   R   t   verifyR!   t   stderrR#   R"   R@   (   RB   RD   RG   RJ   t   verified(    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyRW   k   s    't   .c         C   sh   t  |  ƒ } | j j d ƒ } t j j | | ƒ } t j j d | ƒ | j	 j
 | ƒ | j	 j ƒ  d S(   s  Unpack a wheel.

    Wheel content will be unpacked to {dest}/{name}-{ver}, where {name}
    is the package name and {ver} its version.

    :param wheelfile: The path to the wheel.
    :param dest: Destination directory (default to current directory).
    t   namevers   Unpacking to: %s
N(   R   R2   R3   t   ost   patht   joinR!   RX   R#   R7   t
   extractallRA   (   RB   t   destRD   R[   t   destination(    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt   unpackz   s    	c         C   s”  | sB t  j d ƒ } | r0 | j t  j ƒ } qB t  j j g } n  g  } xn | D]f } x] t  j | ƒ D]L }	 |	 j d ƒ re t t  j j	 | |	 ƒ ƒ }
 |
 j
 r± | j |
 ƒ q± qe qe WqO W| r;t  j j | ƒ sxB | D]7 } t  j j	 | | ƒ } t  j j | ƒ rØ | } PqØ qØ Wn  t | ƒ  } |  j | ƒ Wd QXn  g  } xÓ |  D]Ë } | j d ƒ rÓt  j j | ƒ r¸t | ƒ }
 |
 j
 sŠ| rš| j |
 ƒ qÍd j | ƒ } t | ƒ ‚ qHt d j | ƒ ƒ ‚ qHn  t | | ƒ } | s t d j | ƒ ƒ ‚ n  | j t | ƒ ƒ qHW| r0t j j d ƒ n  | r:d SxS | D]K }
 | rot j j d j |
 j ƒ ƒ qAn  |
 j d	 | ƒ |
 j j ƒ  qAWd S(
   s¶  Install wheels.

    :param requirements: A list of requirements or wheel files to install.
    :param requirements_file: A file containing requirements to install.
    :param wheel_dirs: A list of directories to search for wheels.
    :param force: Install a wheel file even if it is not compatible.
    :param list_files: Only list the files to install, don't install them.
    :param dry_run: Do everything but the actual install.
    t	   WHEELPATHs   .whlNsB   {0} is not compatible with this Python. --force to install anyway.s   No such wheel file: {}s   No match for requirement {}s   Installing:
s       {0}
t   force(   R\   t   getenvt   splitt   pathsepR]   t   curdirt   listdirRO   R   R^   t
   compatibleR.   t   existsRV   t   extendR   R   R   t   maxR!   R"   R#   RN   t   installR7   RA   (   t   requirementst   requirements_filet
   wheel_dirsRd   t
   list_filest   dry_runt	   wheelpatht
   all_wheelst   dt   wRD   R   t   fdt
   to_installt   reqt   msgt   matches(    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyRn   Š   s^    		c         C   s¥   y  d d l  m } d d l } Wn t k
 r? t d ƒ ‚ n Xx^ |  D]V } | j | ƒ } t | ƒ } | j | j ƒ } d g | _ | j	 ƒ  | j
 | ƒ qG Wd S(   sQ   
    Regenerate the entry_points console_scripts for the named distribution.
    iÿÿÿÿ(   t   easy_installNs)   'wheel install_scripts' needs setuptools.R   (   t   setuptools.commandR}   R
   R   R   t   get_distributionR	   t   distributiont   argst   finalize_optionst   install_egg_scripts(   t   distributionsR}   R
   t   distt   pkg_resources_distRn   t   command(    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt   install_scriptsß   s    
c         C   sÖ   t  d ƒ d d l m } d d l m } x¥ |  D] } x” t | ƒ D]† } t j j | ƒ d d k ro | } n | } | r¤ t j	 j
 d j | ƒ ƒ t j	 j ƒ  n  | | | ƒ | rD t j	 j
 d ƒ qD qD Wq1 Wd  S(	   Ns   wheel converti   (   t   bdist_wininst2wheel(   t	   egg2wheeli   s   .eggs   {0}... s   OK
(   R   t   wininst2wheelR‰   RŠ   R    R\   R]   t   splitextR!   R"   R#   R   t   flush(   t
   installerst   dest_dirt   verboseR‰   RŠ   t   patt	   installert   conv(    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt   convertñ   s    
	c             sd  t  j ƒ  ‰  ˆ  j d d ƒ }  d „  } |  j d d d ƒ} | j d | ƒ d „  } |  j d d d	 ƒ} | j d
 d d ƒ| j d | ƒ d „  } |  j d d t j ƒ} | j d
 d d ƒ| j d | ƒ d „  } |  j d d t j ƒ} | j d
 d d ƒ| j d | ƒ d „  }	 |  j d d d ƒ}
 |
 j d d d d d d ƒ|
 j d
 d d ƒ|
 j d |	 ƒ d „  } |  j d d d ƒ} | j d d d d d ƒ| j d d t	 d  d! d d" ƒ| j d# d d  d$ d% d& d d' ƒ| j d( d) d d* ƒ| j d+ d, d t	 d% d- d  d! d d. ƒ| j d | ƒ d/ „  } |  j d0 d d1 ƒ} | j d2 d d d d3 ƒ| j d | ƒ d4 „  } |  j d5 d d6 ƒ} | j d7 d d d d8 ƒ| j d9 d d t
 j j d d: ƒ| j d; d< d  d! ƒ| j d | ƒ d= „  } |  j d> d d? ƒ} | j d | ƒ ‡  f d@ †  } |  j d d dA ƒ} | j d | ƒ ˆ  S(B   Nt   helpt   commandsc         S   s   t  ƒ  d  S(   N(   R-   (   R   (    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt   keygen_f	  s    R-   s   Generate signing keyt   funcc         S   s   t  |  j ƒ d  S(   N(   R=   RB   (   R   (    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt   sign_f  s    R=   s
   Sign wheelRB   s
   Wheel filec         S   s   t  |  j ƒ d  S(   N(   RS   RB   (   R   (    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt   unsign_f  s    RS   c         S   s   t  |  j ƒ d  S(   N(   RW   RB   (   R   (    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt   verify_f  s    RW   c         S   s   t  |  j |  j ƒ d  S(   N(   Rb   RB   R`   (   R   (    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt   unpack_f   s    Rb   s   Unpack wheels   --dests   -ds   Destination directoryt   defaultRZ   c         S   s)   t  |  j |  j |  j |  j |  j ƒ d  S(   N(   Rn   Ro   Rp   Rq   Rd   Rr   (   R   (    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt	   install_f(  s    Rn   s   Install wheelsRo   t   nargst   *s   Requirements to install.s   --forcet   actiont
   store_trues!   Install incompatible wheel files.s   --wheel-dirR.   R`   Rq   s   Directories containing wheels.s   --requirements-files   -rs*   A file containing requirements to install.s   --lists   -lRr   sJ   List wheels which would be installed, but don't actually install anything.c         S   s   t  |  j ƒ d  S(   N(   Rˆ   R„   (   R   (    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt   install_scripts_f>  s    s   install-scriptss   Install console_scriptsR„   s2   Regenerate console_scripts for these distributionsc         S   s   t  |  j |  j |  j ƒ d  S(   N(   R”   RŽ   R   R   (   R   (    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt	   convert_fE  s    R”   s   Convert egg or wininst to wheelRŽ   s   Installers to converts
   --dest-dirs/   Directory to store wheels (default %(default)s)s	   --verboses   -vc         S   s(   d d l  m } t j j d | ƒ d  S(   Ni   (   t   __version__s	   wheel %s
(   t    R¥   R!   R"   R#   (   R   R¥   (    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt	   version_fN  s    t   versions   Print version and exitc            s   ˆ  j  ƒ  d  S(   N(   t
   print_help(   R   (   t   p(    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt   help_fT  s    s   Show this help(   t   argparset   ArgumentParsert   add_subparserst
   add_parsert   set_defaultst   add_argumentRS   t   __doc__RW   t   FalseR\   R]   Rh   (   t   sR—   t   keygen_parserR™   t   sign_parserRš   t   unsign_parserR›   t   verify_parserRœ   t   unpack_parserRž   t   install_parserR£   t   install_scripts_parserR¤   t   convert_parserR§   t   version_parserR«   t   help_parser(    (   Rª   sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt   parser  sv    									c          C   sw   t  ƒ  }  |  j ƒ  } t | d ƒ s1 |  j ƒ  nB y | j | ƒ d SWn* t k
 rr } t j j | j	 d ƒ n Xd S(   NR˜   i    s   
i   (
   R¿   t
   parse_argst   hasattrR©   R˜   R   R!   RX   R#   t   message(   Rª   R   t   e(    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt   main[  s    	($   R²   R\   R:   R!   R?   t   globR    R¦   R   t   utilR   R   R   R   R   Rn   R   R   t   pathsR	   R   R¬   t	   ExceptionR   R   R-   R³   R=   RS   RW   Rb   t   NoneRˆ   R”   R¿   RÄ   (    (    (    sf   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/tool/__init__.pyt   <module>   s2   (						S			V