
2ec           @   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 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 d d l Z d d l m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z 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/ Z0 e j1 d  Z2 e j1 d e j3  Z4 e j1 d  Z5 e j1 d e j3  j6 Z7 d j8   Z9 d d d d g Z: d Z; d Z< e< j= d d j= e j>   d e  Z? d   Z@ d   ZA d   ZB eC d  ZD eC d   ZE eC d!  ZF eC e eC d"  ZG eC d#  ZH d$   ZI e j1 d% e j3  ZJ eI d&    ZK d' f  d(     YZL d) eL f d*     YZM d e f d+     YZN e j1 d,  jO ZP d-   ZQ d.   ZR d d/  ZS d0   ZT d1 f  d2     YZU d3 e jV f d4     YZW e jX jY d5  ZZ d6   Z[ eS e;  eZ  ZZ d7   Z\ d8   Z] d S(9   s#   PyPI and direct package downloadingiN(   t   wraps(   t   six(   t   urllibt   http_clientt   configparsert   map(   t   CHECKOUT_DISTt   Distributiont   BINARY_DISTt   normalize_patht   SOURCE_DISTt   Environmentt   find_distributionst	   safe_namet   safe_versiont   to_filenamet   Requirementt   DEVELOP_DISTt   EGG_DIST(   t   ssl_support(   t   log(   t   DistutilsError(   t	   translate(   t   get_all_headers(   t   unescape(   t   Wheels   ^egg=([-A-Za-z0-9_.+!]+)$s   href\s*=\s*['"]?([^'"> ]+)s   <a href="([^"#]+)">([^<]+)</a>\n\s+\(<a (?:title="MD5 hash"\n\s+)href="[^?]+\?:action=show_md5&amp;digest=([0-9a-f]{32})">md5</a>\)s   ([-+.a-z0-9]{2,}):s   .tar.gz .tar.bz2 .tar .zip .tgzt   PackageIndext   distros_for_urlt   parse_bdist_wininstt   interpret_distro_namei   s<   setuptools/{setuptools.__version__} Python-urllib/{py_major}t   py_majors   {}.{}t
   setuptoolsc         C   s<   y t  j |   SWn$ t k
 r7 t d |  f   n Xd  S(   Ns1   Not a URL, existing file, or requirement spec: %r(   R   t   parset
   ValueErrorR   (   t   spec(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   parse_requirement_arg4   s
    c         C   s   |  j    } d \ } } } | j d  r | j d  rL |  d  } d } q | j d d  r~ |  d d !} |  d  } d } q | j d	  r |  d
  } d } q | j d d  r |  d d !} |  d  } d } q n  | | | f S(   s=   Return (base,pyversion) or (None,None) for possible .exe names   .exes
   .win32.exeit   win32s	   .win32-pyiiis   .win-amd64.exeis	   win-amd64s   .win-amd64-pyiN(   NNN(   t   lowert   Nonet   endswitht
   startswith(   t   nameR%   t   baset   py_vert   plat(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR   =   s$    
	
	
	
c   	      C   s   t  j j |   } | \ } } } } } } t  j j | j d  d  } | d k r | d k r t  j j | j d  d  } n  d | k r | j d d  \ } } n  | | f S(   Nt   /is   sourceforge.nett   downloadit   #i   (   R   R    t   urlparset   unquotet   split(	   t   urlt   partst   schemet   servert   patht
   parameterst   queryt   fragmentR*   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   egg_info_for_urlU   s    "c         c   s   t  |   \ } } x t |  | |  D] } | Vq% W| r t j |  } | r x1 t |  | j d  | d t D] } | Vqq Wq n  d S(   sE   Yield egg or source distribution objects that might be found at a URLi   t
   precedenceN(   R;   t   distros_for_locationt   EGG_FRAGMENTt   matchR   t   groupR   (   R3   t   metadataR*   R:   t   distR?   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR   `   s    	"c      
   C   sA  | j  d  r | d  } n  | j  d  rM d | k rM t j |  | |  g S| j  d  r d | k r t |  } | j   s g  St d |  d | j d | j d	 t d
  g S| j  d  r t |  \ } } } | d k	 r t
 |  | | | t |  Sn  x> t D]6 } | j  |  r| t |   } t
 |  | |  SqWg  S(   s:   Yield egg or source distribution objects based on basenames   .egg.zipis   .eggt   -s   .whlt   locationt   project_namet   versionR<   i   s   .exeN(   R'   R   t   from_locationR   t   is_compatibleRE   RF   R   R   R&   R   R   t
   EXTENSIONSt   len(   RD   t   basenameRA   t   wheelt   win_baseR+   t   platformt   ext(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR=   n   s.    		c         C   s"   t  t |   t j j |   |  S(   sE   Yield possible egg or source distribution objects based on a filename(   R=   R	   t   osR7   RK   (   t   filenameRA   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   distros_for_filename   s    c         c   s   | j  d  } | r4 t d   | d D  r4 d Sxa t d t |  d  D]F } t |  | d j | |   d j | |  d | d | d | VqN Wd S(	   s   Generate alternative interpretations of a source distro name

    Note: if `location` is a filesystem filename, you should call
    ``pkg_resources.normalize_path()`` on it before passing it to this
    routine!
    RC   c         s   s!   |  ] } t  j d  |  Vq d S(   s	   py\d\.\d$N(   t   reR?   (   t   .0t   p(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pys	   <genexpr>   s    i   Ni   t
   py_versionR<   RN   (   R2   t   anyt   rangeRJ   R   t   join(   RD   RK   RA   RV   R<   RN   R4   RU   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR      s    ! )c         c   s   t    } | j } | d k rS xm t j j | j |   D] } | |  | Vq7 Wn; x8 |  D]0 } | |  } | | k rZ | |  | VqZ qZ Wd S(   sH   List unique elements, preserving order. Remember all elements ever seen.N(   t   sett   addR&   R   t   movest   filterfalset   __contains__(   t   iterablet   keyt   seent   seen_addt   elementt   k(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   unique_everseen   s    		

c            s   t       f d    } | S(   ss   
    Wrap a function returning an iterable such that the resulting iterable
    only ever yields unique items.
    c             s   t    |  |    S(   N(   Re   (   t   argst   kwargs(   t   func(    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   wrapper   s    (   R    (   Rh   Ri   (    (   Rh   sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   unique_values   s    s(   <([^>]*\srel\s*=\s*['"]?([^'">]+)[^>]*)>c         c   s  x t  j |  D] } | j   \ } } t t t j | j   j d    } d | k sg d | k r x= t	 j |  D]) } t
 j j |  t | j d    Vqw Wq q Wxj d	 D]b } | j |  } | d k r t	 j | |  } | rt
 j j |  t | j d    Vqq q Wd S(
   sE   Find rel="homepage" and rel="download" links in `page`, yielding URLst   ,t   homepageR.   i   s   <th>Home Pages   <th>Download URLiN(   s   <th>Home Pages   <th>Download URL(   t   RELt   finditert   groupsRZ   R   t   strt   stripR%   R2   t   HREFR   R    t   urljoint
   htmldecodeR@   t   findt   search(   R3   t   pageR?   t   tagt   relt   relst   pos(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   find_external_links   s    '.t   ContentCheckerc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   sP   
    A null content checker that defines the interface for checking content
    c         C   s   d S(   s3   
        Feed a block of data to the hash.
        N(    (   t   selft   block(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   feed   s    c         C   s   t  S(   sC   
        Check the hash. Return False if validation fails.
        (   t   True(   R~   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   is_valid   s    c         C   s   d S(   su   
        Call reporter with information about the checker (hash name)
        substituted into the template.
        N(    (   R~   t   reportert   template(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   report  s    (   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR}      s   		t   HashCheckerc           B   sJ   e  Z e j d   Z d   Z e d    Z d   Z d   Z	 d   Z
 RS(   sK   (?P<hash_name>sha1|sha224|sha384|sha256|sha512|md5)=(?P<expected>[a-f0-9]+)c         C   s(   | |  _  t j |  |  _ | |  _ d  S(   N(   t	   hash_namet   hashlibt   newt   hasht   expected(   R~   R   R   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   __init__  s    	c         C   sR   t  j j |  d } | s# t   S|  j j |  } | sB t   S|  | j     S(   s5   Construct a (possibly null) ContentChecker from a URLi(   R   R    R0   R}   t   patternRv   t	   groupdict(   t   clsR3   R:   R?   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   from_url  s    c         C   s   |  j  j |  d  S(   N(   R   t   update(   R~   R   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR     s    c         C   s   |  j  j   |  j k S(   N(   R   t	   hexdigestR   (   R~   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR   "  s    c         C   s   | |  j  } | |  S(   N(   R   (   R~   R   R   t   msg(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR   %  s    (   R   R   RS   t   compileR   R   t   classmethodR   R   R   R   (    (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR   	  s   				c           B   sv  e  Z d  Z d d% d& e d  Z e d  Z e d  Z e d  Z	 d   Z
 d   Z d	   Z d
   Z d& d  Z d   Z d& d  Z d   Z d   Z d   Z d   Z d   Z e e e d& d  Z e e d  Z d   Z d Z d   Z d   Z d& d  Z d   Z d   Z d   Z d   Z  d   Z! e" e d   Z# d    Z$ d!   Z% d"   Z& d#   Z' d$   Z( RS('   s;   A distribution index that scans web pages for download URLss   https://pypi.org/simple/t   *c         O   s   t  j |  | |  | d | j d   |  _ i  |  _ i  |  _ i  |  _ t j d j	 t
 t |    j |  _ g  |  _ | o t j o | p t j   } | r t j |  |  _ n t j j |  _ d  S(   NR-   t   |(   R   R   R'   t	   index_urlt   scanned_urlst   fetched_urlst   package_pagesRS   R   RY   R   R   R?   t   allowst   to_scanR   t   is_availablet   find_ca_bundlet
   opener_fort   openerR   t   requestt   urlopen(   R~   R   t   hostst	   ca_bundlet
   verify_sslRf   t   kwt   use_ssl(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR   -  s    			'		c         C   sg  | |  j  k r | r d St |  j  | <t |  sD |  j |  d St t |   } | r |  j |  so d S|  j d |  n  | s | s | |  j k r t t	 |  j
 |   d S|  j |  s t |  j | <d S|  j d |  t |  j | <d } |  j | | |  } | d k r!d St |  j | j <d | j j d d  j   k r`| j   d S| j } | j   } t | t  st | t j j  rd } n | j j d	  pd } | j | d
  } n  | j   xH t j |  D]7 }	 t j j | t |	 j  d    }
 |  j! |
  qW| j" |  j#  rct$ | d d  d k rc|  j% | |  } n  d S(   s<   Evaluate a URL as a possible download, and maybe retrieve itNs   Found link: %ss
   Reading %ss<   Download error on %s: %%s -- Some packages may not be found!t   htmls   content-typet    s   latin-1t   charsett   ignorei   t   codei  (&   R   R   t
   URL_SCHEMEt   process_filenamet   listR   t   url_okt   debugR   R   R[   t   infot   open_urlR&   R3   t   headerst   getR%   t   closet   readt
   isinstanceRp   R   t   errort	   HTTPErrort	   get_paramt   decodeRr   Rn   R    Rs   Rt   R@   t   process_urlR(   R   t   getattrt   process_index(   R~   R3   t   retrievet   distst   tmplt   fR*   Rw   R   R?   t   link(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR   B  sP    !
		
$*c         C   s   t  j j |  s& |  j d |  d  St  j j |  r | r t  j j |  } x9 t  j |  D]% } |  j t  j j | |  t	  qa Wn  t
 |  } | r |  j d |  t t |  j |   n  d  S(   Ns   Not found: %ss	   Found: %s(   RP   R7   t   existst   warnt   isdirt   realpatht   listdirR   RY   R   RR   R   R   R   R[   (   R~   t   fnt   nestedR7   t   itemR   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR   u  s    &c         C   s   t  |  } | o* | j d  j   d k } | sR |  j t j j |  d  rV t Sd } | ru t | |   n |  j	 | |  d  S(   Ni   t   filesN   
Note: Bypassing %s (disallowed host; see http://bit.ly/2hrImnY for details).
(
   R   R@   R%   R   R   R    R0   R   R   R   (   R~   R3   t   fatalt   st   is_fileR   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR     s    !%c         C   sB   t  t j j |  } d   | D } t t j |  j |   d  S(   Nc         s   s@   |  ]6 } t  j |  D]  } | j d   r | | f Vq q d S(   s	   .egg-linkN(   RP   R   R'   (   RT   R7   t   entry(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pys	   <genexpr>  s   (   t   filterRP   R7   R   R   t	   itertoolst   starmapt   scan_egg_link(   R~   t   search_patht   dirst	   egg_links(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   scan_egg_links  s    
c      
   C   s   t  t j j | |   ( } t t d  t t j	 |    } Wd  QXt
 |  d k r[ d  S| \ } } xQ t t j j | |   D]4 } t j j | |  | _ t | _ |  j |  q Wd  S(   Ni   (   t   openRP   R7   RY   R   R   R&   R   Rp   Rq   RJ   R   RD   R
   R<   R[   (   R~   R7   R   t	   raw_linest   linest   egg_patht
   setup_pathRB   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR     s    '"	c   
         s    f d   } xW t  j |  D]F } y, | t j j | t | j d     Wq t k
 rd q Xq W| |  \ } } | rxy t | |  D]h } t	 |  \ } }	 | j
 d  r |	 r | r | d | | f 7} q   j |  n    j |  q Wt j d   |  Sd Sd S(   s#   Process the contents of a PyPI pagec            s   |  j    j  r t t t j j |  t   j  j d    } t |  d k r d | d k r t	 | d  } t
 | d  } t   j j | j   i   |  <t |  t |  f Sn  d S(   NR-   i   R/   i   i    (   NN(   R(   R   R   R   R   R    R1   RJ   R2   R   R   R   R   t
   setdefaultR%   R   R&   (   R   R4   t   pkgt   ver(   R~   (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   scan  s    +"i   s   .pys
   #egg=%s-%sc         S   s   d |  j  d d d  S(   Ns   <a href="%s#md5=%s">%s</a>i   i   i   (   R@   (   t   m(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   <lambda>  R   R   N(   Rr   Rn   R   R    Rs   Rt   R@   R!   R|   R;   R'   t   need_version_infot   scan_urlt   PYPI_MD5t   sub(
   R~   R3   Rw   R   R?   R   R   t   new_urlR*   t   frag(    (   R~   sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR     s$    ,c         C   s   |  j  d |  d  S(   NsP   Page at %s links to .py file(s) without version info; an index scan is required.(   t   scan_all(   R~   R3   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR     s    c         G   sO   |  j  |  j k r; | r+ |  j | |  n  |  j d  n  |  j |  j   d  S(   Ns6   Scanning index of all packages (this may take a while)(   R   R   R   R   R   (   R~   R   Rf   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR     s    
c         C   s   |  j  |  j | j d  |  j j | j  sN |  j  |  j | j d  n  |  j j | j  ss |  j |  n  x3 t |  j j | j d   D] } |  j  |  q Wd  S(   NR-   (    (	   R   R   t   unsafe_nameR   R   R`   RE   t   not_found_in_indexR   (   R~   t   requirementR3   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   find_packages  s    %c         C   sk   |  j    |  j |  x8 |  | j D]) } | | k r; | S|  j d | |  q% Wt t |   j | |  S(   Ns   %s does not match %s(   t   prescanR   R`   R   t   superR   t   obtain(   R~   R   t	   installerRB   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR     s    
c         C   si   | j  |  j d |  | j   se | j   t j |  t d | j j t j	 j
 |  f   n  d S(   s-   
        checker is a ContentChecker
        s   Validating %%s checksum for %ss7   %s validation failed for %s; possible download problem?N(   R   R   R   R   RP   t   unlinkR   R   R)   R7   RK   (   R~   t   checkerRQ   t   tfp(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt
   check_hash  s    
c         C   sr   xk | D]c } |  j  d k sJ t |  sJ | j d  sJ t t |   rZ |  j |  q |  j  j |  q Wd S(   s;   Add `urls` to the list that will be prescanned for searchess   file:N(   R   R&   R   R(   R   R   R   t   append(   R~   t   urlsR3   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   add_find_links  s    c         C   s2   |  j  r% t t |  j |  j    n  d |  _  d S(   s7   Scan urls scheduled for prescanning (e.g. --find-links)N(   R   R   R   R   R&   (   R~   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR     s    	c         C   sN   |  | j  r  |  j d } } n |  j d } } | | | j  |  j   d  S(   Ns#   Couldn't retrieve index page for %rs3   Couldn't find index page for %r (maybe misspelled?)(   R`   R   R   R   R   (   R~   R   t   methR   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR   #  s    
c         C   s   t  | t  s t |  } | r| |  j | j d  | |  } t |  \ } } | j d  rx |  j | | |  } n  | St j	 j
 |  r | St |  } n  t |  j | |  d d  S(   s  Locate and/or download `spec` to `tmpdir`, returning a local path

        `spec` may be a ``Requirement`` object, or a string containing a URL,
        an existing local filename, or a project/version requirement spec
        (i.e. the string form of a ``Requirement`` object).  If it is the URL
        of a .py file with an unambiguous ``#egg=name-version`` tag (i.e., one
        that escapes ``-`` as ``_`` throughout), a trivial ``setup.py`` is
        automatically created alongside the downloaded file.

        If `spec` is a ``Requirement`` object or a string containing a
        project/version requirement spec, this method returns the location of
        a matching distribution (possibly after downloading it to `tmpdir`).
        If `spec` is a locally existing file or directory name, it is simply
        returned unchanged.  If `spec` is a URL, it is downloaded to a subpath
        of `tmpdir`, and the local filename is returned.  Various errors may be
        raised if a problem occurs during downloading.
        i   s   .pyRD   N(   R   R   R   t   _download_urlR@   R;   R'   t	   gen_setupRP   R7   R   R#   R   t   fetch_distributionR&   (   R~   R"   t   tmpdirR5   t   foundR*   R:   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR.   -  s    c   	         sF   j  d |  i   d } d       f d  } | rf  j    j |  | |  } n  | r | d k	 r | | |  } n  | d k r  j d k	 r  j   n  | |  } n  | d k r | r  j |  | |  } n  | d k r j d  rd pd |  n#  j  d |  | j d | j  Sd S(	   s|  Obtain a distribution suitable for fulfilling `requirement`

        `requirement` must be a ``pkg_resources.Requirement`` instance.
        If necessary, or if the `force_scan` flag is set, the requirement is
        searched for in the (online) package index as well as the locally
        installed packages.  If a distribution matching `requirement` is found,
        the returned distribution's ``location`` is the value you would have
        gotten from calling the ``download()`` method with the matching
        distribution's URL or filename.  If no matching distribution is found,
        ``None`` is returned.

        If the `source` flag is set, only source distributions and source
        checkout links will be considered.  Unless the `develop_ok` flag is
        set, development and system eggs (i.e., those using the ``.egg-info``
        format) will be ignored.
        s   Searching for %sc            s   | d  k r  } n  x | |  j D] } | j t k rn   rn |  k r#  j d |  d  | <q# q# n  | |  k o | j t k p  } | r#  j | j   } | | _ t	 j
 j | j  r | Sq# q# Wd  S(   Ns&   Skipping development or system egg: %si   (   R&   R`   R<   R   R   R
   R.   RD   t   download_locationRP   R7   R   (   t   reqt   envRB   t   testt   loc(   t
   develop_okR~   t   skippedt   sourceR  (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyRu   g  s     	
	s:   No local packages or working download links found for %s%ss   a source distribution of R   s   Best match: %sRD   N(   R   R&   R   R   R   R   t   cloneR  (	   R~   R   R  t
   force_scanR  R
  t   local_indexRB   Ru   (    (   R
  R~   R  R  R  sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR  O  s0    

c         C   s/   |  j  | | | |  } | d k	 r+ | j Sd S(   s3  Obtain a file suitable for fulfilling `requirement`

        DEPRECATED; use the ``fetch_distribution()`` method now instead.  For
        backward compatibility, this routine is identical but returns the
        ``location`` of the downloaded distribution instead of a distribution
        object.
        N(   R  R&   RD   (   R~   R   R  R  R  RB   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   fetch  s    c      
   C   sp  t  j |  } | rL g  t | | j d  d   D] } | j r1 | ^ q1 pO g  } t |  d k rAt j j	 |  } t j j
 |  | k r t j j | |  } d d l m }	 |	 | |  s t j | |  | } q n  t t j j | d  d  ? }
 |
 j d | d j | d j t j j |  d f  Wd  QX| S| r`t d | | f   n t d	   d  S(
   Ni   i(   t   samefiles   setup.pyt   wsI   from setuptools import setup
setup(name=%r, version=%r, py_modules=[%r])
i    s   Can't unambiguously interpret project/version identifier %r; any dashes in the name or version should be escaped using underscores. %rsp   Can't process plain .py files without an '#egg=name-version' suffix to enable automatic setup script generation.(   R>   R?   R   R@   R&   RF   RJ   RP   R7   RK   t   dirnameRY   t   setuptools.command.easy_installR  t   shutilt   copy2R   t   writeRE   t   splitextR   (   R~   RQ   R:   R  R?   t   dR   RK   t   dstR  R   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR    s2    4!!i    c      
   C   s  |  j  d |  d  } zXt j |  } |  j |  } t | t j j  rn t	 d | | j
 | j f   n  | j    } d } |  j } d } d | k r t | d  }	 t t t |	   } |  j | | | | |  n  t | d  } }
 x` t rO| j |  } | rK| j |  |
 j |  | d 7} |  j | | | | |  q Pq W|  j | | |
  Wd  QX| SWd  | r| j   n  Xd  S(	   Ns   Downloading %ss   Can't download %s: %s %si    is   content-lengths   Content-Lengtht   wbi   (   R   R&   R   R   R   R   R   R   R   R   R   R   t   dl_blocksizeR   t   maxR   t   intt
   reporthookR   R   R   R   R  R   R   (   R~   R3   RQ   t   fpR   R   t   blocknumt   bst   sizet   sizesR   R   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   _download_to  s:    		
c         C   s   d  S(   N(    (   R~   R3   RQ   R!  t   blksizeR#  (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR    s    c         C   s  | j  d  r t |  Sy t | |  j  SWnst t j f k
 r } d j g  | j D] } t	 |  ^ qX  } | r |  j
 | |  qt d | | f   n t j j k
 r } | St j j k
 r} | r |  j
 | | j  qt d | | j f   n t j k
 rU} | r9|  j
 | | j  qt d | | j f   nN t j t j f k
 r} | r|  j
 | |  qt d | | f   n Xd  S(   Ns   file:t    s   %s %ss   Download error for %s: %ss;   %s returned a bad status line. The server might be down, %s(   R(   t
   local_opent   open_with_authR   R!   R   t
   InvalidURLRY   Rf   Rp   R   R   R   R   R   t   URLErrort   reasont   BadStatusLinet   linet   HTTPExceptiont   socket(   R~   R3   t   warningt   vt   argR   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR     s6    
+c         C   sH  t  |  \ } } | rL x7 d | k rH | j d d  j d d  } q Wn d } | j d  rn | d  } n  t j j | |  } | d k s | j d	  r |  j | |  S| d
 k s | j d  r |  j | |  S| j d  r |  j	 | |  S| d k r$t
 j j t
 j j |  d  S|  j | t  |  j | |  Sd  S(   Ns   ..t   .s   \t   _t   __downloaded__s   .egg.zipit   svns   svn+t   gits   git+s   hg+R   i   (   R;   t   replaceR'   RP   R7   RY   R(   t   _download_svnt   _download_gitt   _download_hgR   R   t   url2pathnameR    R0   R   R   t   _attempt_download(   R~   R5   R3   R  R)   R:   RQ   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR     s$    % c         C   s   |  j  | t  d  S(   N(   R   R   (   R~   R3   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR   :  s    c         C   sK   |  j  | |  } d | j d d  j   k rC |  j | | |  S| Sd  S(   NR   s   content-typeR   (   R%  R   R%   t   _download_html(   R~   R3   RQ   R   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR>  =  s    c         C   s   t  |  } xW | D]O } | j   r t j d |  r^ | j   t j |  |  j | |  SPq q W| j   t j |  t d |   d  S(   Ns    <title>([^- ]+ - )?Revision \d+:s   Unexpected HTML page found at (	   R   Rq   RS   Rv   R   RP   R   R:  R   (   R~   R3   R   RQ   R   R.  (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR?  D  s    

c         C   sv  t  j d t  | j d d  d } d } | j   j d  rEd | k rEt j j |  \ } } } } } }	 | rE| j d  rEd	 | d
 k rE| d
 j d	 d  \ } } t	 |  \ }
 } |
 rBd |
 k r|
 j d d  \ } } d | | f } n
 d |
 } | } | | | | | |	 f } t j j
 |  } qBqEn  |  j d | |  t j d | | | f  | S(   Ns"   SVN download support is deprecatedR/   i   i    R   s   svn:t   @s   //R-   i   t   :s    --username=%s --password=%ss    --username=s'   Doing subversion checkout from %s to %ss   svn checkout%s -q %s %s(   t   warningsR   t   UserWarningR2   R%   R(   R   R    R0   t
   _splitusert
   urlunparseR   RP   t   system(   R~   R3   RQ   t   credsR5   t   netlocR7   RU   t   qR   t   autht   hostt   usert   pwR4   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR:  S  s&    !$&
c         C   s   t  j j |   \ } } } } } | j d d  d } | j d d  d } d  } d | k rz | j d d  \ } } n  t  j j | | | | d f  }  |  | f S(   Nt   +i   iR/   i    R@  R   (   R   R    t   urlsplitR2   R&   t   rsplitt
   urlunsplit(   R3   t
   pop_prefixR5   RH  R7   R9   R   t   rev(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   _vcs_split_rev_from_urli  s    !!c         C   s   | j  d d  d } |  j | d t \ } } |  j d | |  t j d | | f  | d  k	 r |  j d |  t j d | | f  n  | S(	   NR/   i   i    RR  s   Doing git clone from %s to %ss   git clone --quiet %s %ss   Checking out %ss   git -C %s checkout --quiet %s(   R2   RT  R   R   RP   RF  R&   (   R~   R3   RQ   RS  (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR;  {  s    	c         C   s   | j  d d  d } |  j | d t \ } } |  j d | |  t j d | | f  | d  k	 r |  j d |  t j d | | f  n  | S(	   NR/   i   i    RR  s   Doing hg clone from %s to %ss   hg clone --quiet %s %ss   Updating to %ss   hg --cwd %s up -C -r %s -q(   R2   RT  R   R   RP   RF  R&   (   R~   R3   RQ   RS  (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR<    s    	c         G   s   t  j | |  d  S(   N(   R   R   (   R~   R   Rf   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR     s    c         G   s   t  j | |  d  S(   N(   R   R   (   R~   R   Rf   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR     s    c         G   s   t  j | |  d  S(   N(   R   R   (   R~   R   Rf   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR     s    (   R   N()   R   R   R   R&   R   R   t   FalseR   R   R   R   R   R   R   R   R   R   R   R   R   R   R.   R  R  R  R  R%  R  R   R   R   R>  R?  R:  t   staticmethodRT  R;  R<  R   R   R   (    (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR   *  sL   3	
		+								
	#J	)	$	#									s!   &(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?c         C   s   |  j  d  } t |  S(   Ni    (   R@   R   (   R?   t   what(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   decode_entity  s    c         C   s   t  t |   S(   s  
    Decode HTML entities in the given text.

    >>> htmldecode(
    ...     'https://../package_name-0.1.2.tar.gz'
    ...     '?tokena=A&amp;tokenb=B">package_name-0.1.2.tar.gz')
    'https://../package_name-0.1.2.tar.gz?tokena=A&tokenb=B">package_name-0.1.2.tar.gz'
    (   t
   entity_subRX  (   t   text(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyRt     s    	c            s     f d   } | S(   Nc            s      f d   } | S(   Nc             s?   t  j   } t  j   z   |  |   SWd  t  j |  Xd  S(   N(   R0  t   getdefaulttimeoutt   setdefaulttimeout(   Rf   Rg   t   old_timeout(   Rh   t   timeout(    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   _socket_timeout  s
    (    (   Rh   R_  (   R^  (   Rh   sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR_    s    (    (   R^  R_  (    (   R^  sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   socket_timeout  s    c         C   sI   t  j j |   } | j   } t j |  } | j   } | j d d  S(   sq  
    A function compatible with Python 2.3-3.3 that will encode
    auth from a URL suitable for an HTTP header.
    >>> str(_encode_auth('username%3Apassword'))
    'dXNlcm5hbWU6cGFzc3dvcmQ='

    Long auth strings should not cause a newline to be inserted.
    >>> long_auth = 'username:' + 'password'*10
    >>> chr(10) in str(_encode_auth(long_auth))
    False
    s   
R   (   R   R    R1   t   encodet   base64t	   b64encodeR   R9  (   RJ  t   auth_st
   auth_bytest   encoded_bytest   encoded(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   _encode_auth  s
    t
   Credentialc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s:   
    A username/password pair. Use like a namedtuple.
    c         C   s   | |  _  | |  _ d  S(   N(   t   usernamet   password(   R~   Rj  Rk  (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR     s    	c         c   s   |  j  V|  j Vd  S(   N(   Rj  Rk  (   R~   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   __iter__  s    c         C   s   d t  |   S(   Ns   %(username)s:%(password)s(   t   vars(   R~   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   __str__  s    (   R   R   R   R   Rl  Rn  (    (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyRi    s   		t
   PyPIConfigc           B   s2   e  Z d    Z e d    Z d   Z d   Z RS(   c         C   su   t  j d d d g d  } t j j |  |  t j j t j j d  d  } t j j	 |  rq |  j
 |  n  d S(   s%   
        Load from ~/.pypirc
        Rj  Rk  t
   repositoryR   t   ~s   .pypircN(   t   dictt   fromkeysR   t   RawConfigParserR   RP   R7   RY   t
   expanduserR   R   (   R~   t   defaultst   rc(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR     s
    !c         C   sM   g  |  j    D]$ } |  j | d  j   r | ^ q } t t |  j |   S(   NRp  (   t   sectionsR   Rq   Rr  R   t   _get_repo_cred(   R~   t   sectiont   sections_with_repositories(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   creds_by_repository  s    $c         C   sO   |  j  | d  j   } | t |  j  | d  j   |  j  | d  j    f S(   NRp  Rj  Rk  (   R   Rq   Ri  (   R~   Rz  t   repo(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyRy    s    c         C   s7   x0 |  j  j   D] \ } } | j |  r | Sq Wd S(   s   
        If the URL indicated appears to be a repository defined in this
        config, return the credential for that repository.
        N(   R|  t   itemsR(   (   R~   R3   Rp  t   cred(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   find_credential  s    (   R   R   R   t   propertyR|  Ry  R  (    (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyRo    s   			c         C   s  t  j j |   } | \ } } } } } } | j d  rK t j d   n  | d	 k rl t |  \ }	 }
 n d
 }	 |	 s t   j	 |   } | r t
 |  }	 | j |  f } t j d |  q n  |	 r&d t |	  }	 | |
 | | | | f } t  j j |  } t  j j |  } | j d |	  n t  j j |   } | j d t  | |  } |	 rt  j j | j  \ } } } } } } | | k r| |
 k r| | | | | | f } t  j j |  | _ qn  | S(   s4   Open a urllib2 request, handling HTTP authenticationRA  s   nonnumeric port: ''t   httpt   httpss*   Authenticating as %s for %s (from .pypirc)s   Basic t   Authorizations
   User-Agent(   R  R  N(   R   R    R0   R'   R   R*  RD  R&   Ro  R  Rp   Rj  R   R   Rh  RE  R   t   Requestt
   add_headert
   user_agentR3   (   R3   R   t   parsedR5   RH  R7   t   paramsR9   R   RJ  t   addressR  R   R4   R   R   R   t   s2t   h2t   path2t   param2t   query2t   frag2(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR)    s8    'c         C   s.   |  j  d  \ } } }  | r$ | n d |  f S(   sJ   splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.R@  N(   t
   rpartitionR&   (   RK  RL  t   delim(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyRD  F  s    c         C   s   |  S(   N(    (   R3   (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt
   fix_sf_urlP  s    c         C   s  t  j j |   \ } } } } } } t  j j |  } t j j |  rX t  j j |   S| j	 d  rPt j j
 |  rPg  } x t j |  D] }	 t j j | |	  }
 |	 d k r t |
 d   } | j   } Wd QXPn t j j
 |
  r |	 d 7}	 n  | j d j d |	   q Wd } | j d |  d	 d
 j |   } d \ } } n d \ } } } i d d 6} t j |  } t  j j |  | | | |  S(   s7   Read a local path, with special support for directoriesR-   s
   index.htmlt   rNs   <a href="{name}">{name}</a>R)   sB   <html><head><title>{url}</title></head><body>{files}</body></html>R3   t   filess   
i   t   OKi  s   Path not founds	   Not founds	   text/htmls   content-type(   i   R  (   i  s   Path not founds	   Not found(   R   R    R0   R   R=  RP   R7   t   isfileR   R'   R   R   RY   R   R   R   t   formatR   t   StringIOR   R   (   R3   R5   R6   R7   t   paramR9   R   RQ   R  R   t   filepathR   t   bodyR   t   statust   messageR   t   body_stream(    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyR(  T  s,    $!!(^   R   t   sysRP   RS   R  R0  Rb  R   R   RB  t	   functoolsR    t   setuptools.externR   t   setuptools.extern.six.movesR   R   R   R   R   t   pkg_resourcesR   R   R   R	   R
   R   R   R   R   R   R   R   R   R   t	   distutilsR   t   distutils.errorsR   t   fnmatchR   t   setuptools.py27compatR   t   setuptools.py33compatR   t   setuptools.wheelR   t   typet   __metaclass__R   R>   t   IRr   R   R?   R   R2   RI   t   __all__t   _SOCKET_TIMEOUTt   _tmplR  t   version_infoR  R#   R   R;   R&   R   R=   RR   R   Re   Rj   Rm   R|   R}   R   R   R   RY  RX  Rt   R`  Rh  Ri  Rt  Ro  R   R   R)  RD  R  R(  (    (    (    sB   /usr/local/lib/python2.7/dist-packages/setuptools/package_index.pyt   <module>   s|   "X			$				!"	!  			&/		