o
    f}”eœœ  ã                   @   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
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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#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 /d
¡Z0e /dej1¡Z2e /d¡Z3e /dej1¡j4Z5d 6¡ Z7g d¢Z8dZ9dZ:e:j;dj;ej<Ž ed�Z=dd„ Z>dd„ Z?dd„ Z@dBdd„ZAdBdd„ZBdBdd„ZCdedfd d!„ZDd"d#„ ZEe /d$ej1¡ZFeEd%d&„ ƒZGG d'd(„ d(ƒZHG d)d*„ d*eHƒZIG d+d,„ d,eƒZJe /d-¡jKZLd.d/„ ZMd0d1„ ZNdCd2d3„ZOd4d5„ ZPG d6d7„ d7ƒZQG d8d9„ d9ejRƒZSejTjUfd:d;„ZVd<d=„ ZWeOe9ƒeVƒZVd>d?„ ZXd@dA„ ZYdS )Dz#PyPI and direct package downloadingé    N©Úwraps)ÚCHECKOUT_DISTÚDistributionÚBINARY_DISTÚnormalize_pathÚSOURCE_DISTÚEnvironmentÚfind_distributionsÚ	safe_nameÚsafe_versionÚto_filenameÚRequirementÚDEVELOP_DISTÚEGG_DISTÚparse_version)Úlog)ÚDistutilsError)Ú	translate)ÚWheel©Úunique_everseenz^egg=([-A-Za-z0-9_.+!]+)$zhref\s*=\s*['"]?([^'"> ]+)zƒ<a href="([^"#]+)">([^<]+)</a>\n\s+\(<a (?:title="MD5 hash"\n\s+)href="[^?]+\?:action=show_md5&amp;digest=([0-9a-f]{32})">md5</a>\)z([-+.a-z0-9]{2,}):z.tar.gz .tar.bz2 .tar .zip .tgz)ÚPackageIndexÚdistros_for_urlÚparse_bdist_wininstÚinterpret_distro_nameé   z<setuptools/{setuptools.__version__} Python-urllib/{py_major}z{}.{})Zpy_majorÚ
setuptoolsc              
   C   s6   zt  | ¡W S  ty } ztd| f ƒ|‚d }~ww )Nz1Not a URL, existing file, or requirement spec: %r)r   ÚparseÚ
ValueErrorr   )ÚspecÚe© r"   úa/Users/abhinavbhinder/Documents/map/venv/lib/python3.10/site-packages/setuptools/package_index.pyÚparse_requirement_arg6   s   ÿþ€ÿr$   c                 C   s°   |   ¡ }d\}}}| d¡rS| d¡r| dd… }d}n7| dd¡r1| d	d
… }| dd… }d}n"| d¡r?| dd… }d}n| dd¡rS| d	d
… }| dd… }d}|||fS )z=Return (base,pyversion) or (None,None) for possible .exe name)NNNú.exez
.win32.exeNiöÿÿÿÚwin32z	.win32-pyiðÿÿÿiùÿÿÿéüÿÿÿz.win-amd64.exeiòÿÿÿz	win-amd64z.win-amd64-pyiìÿÿÿ)ÚlowerÚendswithÚ
startswith)Únamer(   ÚbaseÚpy_verÚplatr"   r"   r#   r   ?   s$   




r   c           	      C   sx   t j | ¡}|\}}}}}}t j | d¡d ¡}|dkr,|dkr,t j | d¡d ¡}d|v r8| dd¡\}}||fS )Nú/éÿÿÿÿzsourceforge.netÚdownloadéþÿÿÿú#é   )Úurllibr   ÚurlparseÚunquoteÚsplit)	ÚurlÚpartsÚschemeÚserverÚpathÚ
parametersÚqueryÚfragmentr,   r"   r"   r#   Úegg_info_for_urlW   s   rA   c                 c   sf   � t | ƒ\}}t| ||ƒD ]}|V  q|r-t |¡}|r/t| | d¡|td�D ]	}|V  q'dS dS dS )zEYield egg or source distribution objects that might be found at a URLr4   )Ú
precedenceN)rA   Údistros_for_locationÚEGG_FRAGMENTÚmatchr   Úgroupr   )r9   Úmetadatar,   r@   ÚdistrE   r"   r"   r#   r   b   s   €

ÿúr   c                 C   sä   |  d¡r|dd… }|  d¡rd|v rt | ||¡gS |  d¡r<d|v r<t|ƒ}| ¡ s/g S t| |j|jtd d�gS |  d	¡rUt|ƒ\}}}|durUt	| |||t
|ƒS tD ]}|  |¡ro|dt|ƒ … }t	| ||ƒ  S qWg S )
z:Yield egg or source distribution objects based on basenameú.egg.zipNr'   z.eggú-z.whlr4   )ÚlocationÚproject_nameÚversionrB   r%   )r)   r   Úfrom_locationr   Úis_compatiblerL   rM   r   r   r   r   Ú
EXTENSIONSÚlen)rK   ÚbasenamerG   ÚwheelZwin_baser-   ÚplatformÚextr"   r"   r#   rC   p   s4   
û
ÿ
þrC   c                 C   s   t t| ƒtj | ¡|ƒS )zEYield possible egg or source distribution objects based on a filename)rC   r   Úosr=   rR   )ÚfilenamerG   r"   r"   r#   Údistros_for_filename‘   s   ÿrX   c              
   c   s~   � |  d¡}|stdd„ |dd… D ƒƒrdS tdt|ƒd ƒD ]}t| |d |d|… ¡d ||d… ¡|||d�V  q dS )zØ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!
    rJ   c                 s   s   � | ]	}t  d |¡V  qdS )z	py\d\.\d$N)ÚrerE   )Ú.0Úpr"   r"   r#   Ú	<genexpr>¯   s   € z(interpret_distro_name.<locals>.<genexpr>é   Nr4   )Ú
py_versionrB   rT   )r8   ÚanyÚrangerQ   r   Újoin)rK   rR   rG   r^   rB   rT   r:   r[   r"   r"   r#   r   ˜   s   €
$
ýÿr   c                    s   t ˆ ƒ‡ fdd„ƒ}|S )zs
    Wrap a function returning an iterable such that the resulting iterable
    only ever yields unique items.
    c                     s   t ˆ | i |¤ŽƒS ©Nr   )ÚargsÚkwargs©Úfuncr"   r#   ÚwrapperÁ   s   zunique_values.<locals>.wrapperr   )rf   rg   r"   re   r#   Úunique_values»   s   rh   z(<([^>]*\srel\s*=\s*['"]?([^'">]+)[^>]*)>c              	   c   s¼   � t  |¡D ]2}| ¡ \}}tttj| ¡  d¡ƒƒ}d|v s#d|v r8t	 |¡D ]}t
j | t| d¡ƒ¡V  q(qdD ] }| |¡}|dkr[t	 ||¡}|r[t
j | t| d¡ƒ¡V  q;dS )zEFind rel="homepage" and rel="download" links in `page`, yielding URLsú,Úhomepager1   r4   )z<th>Home Pagez<th>Download URLr0   N)ÚRELÚfinditerÚgroupsÚsetÚmapÚstrÚstripr(   r8   ÚHREFr5   r   ÚurljoinÚ
htmldecoderF   ÚfindÚsearch)r9   ÚpagerE   ÚtagÚrelZrelsÚposr"   r"   r#   Úfind_external_linksÌ   s    €€
€ûr{   c                   @   ó(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚContentCheckerzP
    A null content checker that defines the interface for checking content
    c                 C   ó   dS )z3
        Feed a block of data to the hash.
        Nr"   ©ÚselfÚblockr"   r"   r#   Úfeedä   ó   zContentChecker.feedc                 C   r~   )zC
        Check the hash. Return False if validation fails.
        Tr"   ©r€   r"   r"   r#   Úis_validê   rƒ   zContentChecker.is_validc                 C   r~   )zu
        Call reporter with information about the checker (hash name)
        substituted into the template.
        Nr"   )r€   ÚreporterÚtemplater"   r"   r#   Úreportð   s   zContentChecker.reportN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r‚   r…   rˆ   r"   r"   r"   r#   r}   ß   s
    r}   c                   @   sB   e Zd Ze d¡Zdd„ Zedd„ ƒZdd„ Z	dd	„ Z
d
d„ ZdS )ÚHashCheckerzK(?P<hash_name>sha1|sha224|sha384|sha256|sha512|md5)=(?P<expected>[a-f0-9]+)c                 C   s   || _ t |¡| _|| _d S rb   )Ú	hash_nameÚhashlibÚnewÚhashÚexpected)r€   rŽ   r’   r"   r"   r#   Ú__init__þ   s   
zHashChecker.__init__c                 C   sB   t j |¡d }|stƒ S | j |¡}|stƒ S | di | ¡ ¤ŽS )z5Construct a (possibly null) ContentChecker from a URLr0   Nr"   )r5   r   r6   r}   Úpatternrv   Ú	groupdict)Úclsr9   r@   rE   r"   r"   r#   Úfrom_url  s   zHashChecker.from_urlc                 C   s   | j  |¡ d S rb   )r‘   Úupdater   r"   r"   r#   r‚     ó   zHashChecker.feedc                 C   s   | j  ¡ | jkS rb   )r‘   Ú	hexdigestr’   r„   r"   r"   r#   r…     r™   zHashChecker.is_validc                 C   s   || j  }||ƒS rb   )rŽ   )r€   r†   r‡   Úmsgr"   r"   r#   rˆ     s   
zHashChecker.reportN)r‰   rŠ   r‹   rY   Úcompiler”   r“   Úclassmethodr—   r‚   r…   rˆ   r"   r"   r"   r#   r�   ø   s    ÿ

r�   c                       sX  e Zd ZdZ		dNdd„Z‡ fdd	„ZdOdd„ZdOdd„ZdOdd„Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdPdd„Zdd„ ZdP‡ fdd „	Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Z	
	dQd+d,„ZdRd-d.„Zd/d0„ Zd1Zd2d3„ Zd4d5„ ZdPd6d7„Zd8d9„ Zd:d;„ Zd<d=„ Zd>d?„ Z d@dA„ Z!e"dOdBdC„ƒZ#dDdE„ Z$dFdG„ Z%dHdI„ Z&dJdK„ Z'dLdM„ Z(‡  Z)S )Sr   z;A distribution index that scans web pages for download URLsúhttps://pypi.org/simple/©Ú*NTc                 O   sr   t j| g|¢R i |¤Ž |dd | d¡ …  | _i | _i | _i | _t d 	t
t|ƒ¡¡j| _g | _tjj| _d S )Nr/   ú|)r	   r“   r)   Ú	index_urlÚscanned_urlsÚfetched_urlsÚpackage_pagesrY   rœ   ra   ro   r   rE   ÚallowsÚto_scanr5   ÚrequestÚurlopenÚopener)r€   r¢   ÚhostsZ	ca_bundleZ
verify_sslrc   Úkwr"   r"   r#   r“     s   zPackageIndex.__init__c                    s0   zt |jƒ W n
 ty   Y d S w tƒ  |¡S rb   )r   rM   Ú	ExceptionÚsuperÚadd)r€   rH   ©Ú	__class__r"   r#   r¯   )  s   ÿzPackageIndex.addFc                 C   sÜ  || j v r	|s	dS d| j |< t|ƒs|  |¡ dS tt|ƒƒ}|r.|  |¡s(dS |  d|¡ |s7|r7|| jv rAtt| j	|ƒƒ dS |  |¡sMd| j|< dS |  
d|¡ d| j|< d}|  ||| ¡}|du rhdS t|tjjƒr||jdkr||  
d|j ¡ d| j|j< d|j d	d
¡ ¡ vr“| ¡  dS |j}| ¡ }t|tƒs·t|tjjƒr©d}n|j d¡p°d}| |d¡}| ¡  t |¡D ]}	tj |t|	  d¡ƒ¡}
|  !|
¡ qÀ| "| j#¡rêt$|ddƒdkrì|  %||¡}dS dS dS )z<Evaluate a URL as a possible download, and maybe retrieve itNTzFound link: %sz
Reading %sz<Download error on %s: %%s -- Some packages may not be found!i‘  zAuthentication error: %sÚhtmlúcontent-typeÚ zlatin-1ÚcharsetÚignorer4   Úcodeé”  )&r£   Ú
URL_SCHEMEÚprocess_filenameÚlistr   Úurl_okÚdebugr¤   ro   r¯   ÚinfoÚopen_urlÚ
isinstancer5   ÚerrorÚ	HTTPErrorr·   r›   r9   ÚheadersÚgetr(   ÚcloseÚreadrp   Ú	get_paramÚdecoderr   rl   r   rs   rt   rF   Úprocess_urlr*   r¢   ÚgetattrÚprocess_index)r€   r9   ZretrieveÚdistsÚtmplÚfr,   rw   rµ   rE   Úlinkr"   r"   r#   rÉ   2  sV   






ÿzPackageIndex.process_urlc                 C   sŽ   t j |¡s|  d|¡ d S t j |¡r/|s/t j |¡}t  |¡D ]}|  t j ||¡d¡ q!t	|ƒ}|rE|  
d|¡ tt| j|ƒƒ d S d S )NzNot found: %sTz	Found: %s)rV   r=   ÚexistsÚwarnÚisdirÚrealpathÚlistdirrº   ra   rX   r½   r»   ro   r¯   )r€   ÚfnÚnestedr=   ÚitemrÌ   r"   r"   r#   rº   g  s   þzPackageIndex.process_filenamec                 C   s`   t |ƒ}|o| d¡ ¡ dk}|s|  tj |¡d ¡rdS d}|r(t|| ƒ‚|  ||¡ d S )Nr4   ÚfileTzN
Note: Bypassing %s (disallowed host; see http://bit.ly/2hrImnY for details).
)	r¹   rF   r(   r¦   r5   r   r6   r   rÑ   )r€   r9   ÚfatalÚsÚis_filer›   r"   r"   r#   r¼   w  s   ÿzPackageIndex.url_okc                 C   s2   t tjj|ƒ}dd„ |D ƒ}tt | j|¡ƒ d S )Nc                 s   s2   � | ]}t  |¡D ]}| d ¡r	||fV  q	qdS )z	.egg-linkN)rV   rÔ   r)   )rZ   r=   Úentryr"   r"   r#   r\   †  s   € ýüÿz.PackageIndex.scan_egg_links.<locals>.<genexpr>)ÚfilterrV   r=   rÒ   r»   Ú	itertoolsÚstarmapÚscan_egg_link)r€   Úsearch_pathÚdirsZ	egg_linksr"   r"   r#   Úscan_egg_links„  s
   þzPackageIndex.scan_egg_linksc                 C   s¢   t tj ||¡ƒ�}ttd ttj|ƒƒƒ}W d   ƒ n1 sw   Y  t	|ƒdkr,d S |\}}t
tj ||¡ƒD ]}tjj|g|¢R Ž |_t|_|  |¡ q9d S )Nr]   )ÚopenrV   r=   ra   r»   rÝ   ro   rp   rq   rQ   r
   rK   r   rB   r¯   )r€   r=   rÜ   Z	raw_linesÚlinesÚegg_pathZ
setup_pathrH   r"   r"   r#   rà   Ž  s   þýzPackageIndex.scan_egg_linkc                 C   s”   d}|  | j¡s
|S tttjj|t| jƒd …  d¡ƒƒ}t|ƒdks)d|d v r+|S t	|d ƒ}t
|d ƒ}d| j | ¡ i ¡|< t|ƒt|ƒfS )N)NNr/   r]   r3   r4   r   T)r*   r¢   r»   ro   r5   r   r7   rQ   r8   r   r   r¥   Ú
setdefaultr(   r   )r€   rÏ   ZNO_MATCH_SENTINELr:   ÚpkgÚverr"   r"   r#   Ú_scanž  s   ÿzPackageIndex._scanc           	   
   C   s¾   t  |¡D ]}z|  tj |t| d¡ƒ¡¡ W q ty!   Y qw |  |¡\}}|s-dS t	||ƒD ]$}t
|ƒ\}}| d¡rQ|sQ|rL|d||f 7 }n|  |¡ |  |¡ q2t dd„ |¡S )z#Process the contents of a PyPI pager4   r´   ú.pyz
#egg=%s-%sc                 S   s   d|   ddd¡ S )Nz<a href="%s#md5=%s">%s</a>r4   é   r]   )rF   )Úmr"   r"   r#   Ú<lambda>Ê  s    z,PackageIndex.process_index.<locals>.<lambda>)rr   rl   rê   r5   r   rs   rt   rF   r   r{   rA   r)   Úneed_version_infoÚscan_urlÚPYPI_MD5Úsub)	r€   r9   rw   rE   rè   ré   Únew_urlr,   Úfragr"   r"   r#   rË   °  s&   "ÿ
ÿzPackageIndex.process_indexc                 C   s   |   d|¡ d S )NzPPage at %s links to .py file(s) without version info; an index scan is required.)Úscan_all©r€   r9   r"   r"   r#   rï   Í  s   þzPackageIndex.need_version_infoc                 G   s<   | j | jvr|r| j|g|¢R Ž  |  d¡ |  | j ¡ d S )Nz6Scanning index of all packages (this may take a while))r¢   r¤   rÑ   r¾   rð   ©r€   r›   rc   r"   r"   r#   rõ   Ó  s   ÿzPackageIndex.scan_allc                 C   sz   |   | j|j d ¡ | j |j¡s|   | j|j d ¡ | j |j¡s)|  |¡ t| j |jd¡ƒD ]}|   |¡ q3d S )Nr/   r"   )	rð   r¢   Úunsafe_namer¥   rÄ   ÚkeyrL   Únot_found_in_indexr»   )r€   Úrequirementr9   r"   r"   r#   Úfind_packagesÜ  s   
þzPackageIndex.find_packagesc                    sR   |   ¡  |  |¡ | |j D ]}||v r|  S |  d||¡ qtt| ƒ ||¡S )Nz%s does not match %s)Úprescanrü   rù   r½   r®   r   Úobtain)r€   rû   Ú	installerrH   r°   r"   r#   rþ   ë  s   
zPackageIndex.obtainc                 C   sL   |  | jd| ¡ | ¡ s$| ¡  t |¡ td|jjtj	 
|¡f ƒ‚dS )z-
        checker is a ContentChecker
        zValidating %%s checksum for %sz7%s validation failed for %s; possible download problem?N)rˆ   r½   r…   rÅ   rV   Úunlinkr   r‘   r+   r=   rR   )r€   ÚcheckerrW   Útfpr"   r"   r#   Ú
check_hashô  s   þ
þÿýzPackageIndex.check_hashc                 C   sN   |D ]"}| j du st|ƒr| d¡stt|ƒƒr|  |¡ q| j  |¡ qdS )z;Add `urls` to the list that will be prescanned for searchesNúfile:)r§   r¹   r*   r»   r   rð   Úappend)r€   Zurlsr9   r"   r"   r#   Úadd_find_links  s   ÿþý
üõzPackageIndex.add_find_linksc                 C   s"   | j rtt| j| j ƒƒ d| _ dS )z7Scan urls scheduled for prescanning (e.g. --find-links)N)r§   r»   ro   rð   r„   r"   r"   r#   rý     s   
zPackageIndex.prescanc                 C   s<   | |j  r| jd}}n| jd}}|||jƒ |  ¡  d S )Nz#Couldn't retrieve index page for %rz3Couldn't find index page for %r (maybe misspelled?))rù   r¾   rÑ   rø   rõ   )r€   rû   Úmethr›   r"   r"   r#   rú     s   
þzPackageIndex.not_found_in_indexc                 C   s~   t |tƒs5t|ƒ}|r)|  | d¡||¡}t|ƒ\}}| d¡r'|  |||¡}|S tj	 
|¡r1|S t|ƒ}t|  ||¡ddƒS )a  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.
        r4   rë   rK   N)rÀ   r   r¹   Ú_download_urlrF   rA   r)   Ú	gen_setuprV   r=   rÐ   r$   rÊ   Úfetch_distribution)r€   r    Útmpdirr;   Úfoundr,   r@   r"   r"   r#   r1   #  s   

zPackageIndex.downloadc           	         sÚ   ˆ  d|¡ i ‰d}d
‡ ‡‡‡‡fdd„	}|r$ˆ ¡  ˆ |¡ ||ƒ}|s/|dur/|||ƒ}|du r@ˆjdur<ˆ ¡  ||ƒ}|du rO|sOˆ |¡ ||ƒ}|du r`ˆ dˆrZdp[d|¡ dS ˆ  d|¡ |j|jd	�S )a|  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.
        zSearching for %sNc                    s’   |d u rˆ}|| j  D ];}|jtkr#ˆ s#|ˆvr"ˆ d|¡ dˆ|< q|| v o.|jtkp.ˆ }|rFˆ |jˆ¡}||_tj	 
|j¡rF|  S qd S )Nz&Skipping development or system egg: %sr4   )rù   rB   r   rÑ   r   r1   rK   Údownload_locationrV   r=   rÐ   )ÚreqÚenvrH   ÚtestÚloc©Ú
develop_okr€   ZskippedÚsourcer  r"   r#   ru   ]  s(   ÿþ€îz-PackageIndex.fetch_distribution.<locals>.findz:No local packages or working download links found for %s%sza source distribution of r´   zBest match: %s)rK   rb   )r¾   rý   rü   r§   rÑ   Úcloner  )	r€   rû   r  Ú
force_scanr  r  Úlocal_indexrH   ru   r"   r  r#   r
  E  s2   




ýzPackageIndex.fetch_distributionc                 C   s"   |   ||||¡}|dur|jS dS )a3  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
  rK   )r€   rû   r  r  r  rH   r"   r"   r#   Úfetch‘  s   zPackageIndex.fetchc           
   	   C   s  t  |¡}|rdd„ t|| d¡d ƒD ƒpg }t|ƒdkrxtj |¡}tj |¡|krEtj 	||¡}ddl
m} |||ƒsEt ||¡ |}ttj 	|d¡dƒ�}	|	 d|d j|d jtj |¡d f ¡ W d   ƒ |S 1 sqw   Y  |S |r‚td	||f ƒ‚td
ƒ‚)Nc                 S   s   g | ]}|j r|‘qS r"   )rM   )rZ   Údr"   r"   r#   Ú
<listcomp>   s    þÿz*PackageIndex.gen_setup.<locals>.<listcomp>r4   r   )Úsamefilezsetup.pyÚwzIfrom setuptools import setup
setup(name=%r, version=%r, py_modules=[%r])
z†Can't unambiguously interpret project/version identifier %r; any dashes in the name or version should be escaped using underscores. %rzpCan't process plain .py files without an '#egg=name-version' suffix to enable automatic setup script generation.)rD   rE   r   rF   rQ   rV   r=   rR   Údirnamera   Úsetuptools.command.easy_installr  ÚshutilÚcopy2rä   ÚwriterL   rM   Úsplitextr   )
r€   rW   r@   r  rE   rÌ   rR   Údstr  rØ   r"   r"   r#   r	  ž  sF   

þý
þþÿ
ÿ	÷	þÿÿzPackageIndex.gen_setupi    c                 C   s2  |   d|¡ d }zˆt |¡}|  |¡}t|tjjƒr%td||j	|j
f ƒ‚|  ¡ }d}| j}d}d|v rI| d¡}	ttt|	ƒƒ}|  |||||¡ t|dƒ�1}
	 | |¡}|ro| |¡ |
 |¡ |d	7 }|  |||||¡ nnqP|  |||
¡ W d   ƒ n1 s‚w   Y  |W |r�| ¡  S S |r˜| ¡  w w )
NzDownloading %szCan't download %s: %s %sr   r0   zcontent-lengthzContent-LengthÚwbTr4   )r¾   r�   r—   r¿   rÀ   r5   rÁ   rÂ   r   r·   r›   Údl_blocksizeÚget_allÚmaxro   ÚintÚ
reporthookrä   rÆ   r‚   r!  r  rÅ   )r€   r9   rW   Úfpr  rÃ   ÚblocknumÚbsÚsizeÚsizesr  r�   r"   r"   r#   Ú_download_toÉ  sF   

ÿ



ø	ö
ÿ
ÿzPackageIndex._download_toc                 C   s   d S rb   r"   )r€   r9   rW   r+  Zblksizer-  r"   r"   r#   r)  í  ó   zPackageIndex.reporthookc              
   C   s¦  |  d¡r	t|ƒS zt|| jƒW S  ttjjfyD } z$d dd„ |j	D ƒ¡}|r0|  
||¡ n	td||f ƒ|‚W Y d }~d S d }~w tjjyY } z|W  Y d }~S d }~w tjjy� } z|rl|  
||j¡ n
td||jf ƒ|‚W Y d }~d S d }~w tjjy© } z|r”|  
||j¡ n
td||jf ƒ|‚W Y d }~d S d }~w tjjtjfyÒ } z|r¾|  
||¡ n	td||f ƒ|‚W Y d }~d S d }~ww )Nr  ú c                 S   s   g | ]}t |ƒ‘qS r"   )rp   )rZ   Úargr"   r"   r#   r  ÷  s    z)PackageIndex.open_url.<locals>.<listcomp>z%s %szDownload error for %s: %sz;%s returned a bad status line. The server might be down, %s)r*   Ú
local_openÚopen_with_authrª   r   ÚhttpÚclientÚ
InvalidURLra   rc   rÑ   r   r5   rÁ   rÂ   ÚURLErrorÚreasonZBadStatusLineÚlineZHTTPExceptionÚsocket)r€   r9   ÚwarningÚvr›   r"   r"   r#   r¿   ñ  s^   
þ€€ÿÿþ€þÿüþ€ÿÿþ€þzPackageIndex.open_urlc                 C   sè   t |ƒ\}}|rd|v r| dd¡ dd¡}d|v snd}| d¡r(|d d… }tj ||¡}|dks8| d	¡r>|  ||¡S |d
ksG| d¡rM|  ||¡S | d¡rX|  	||¡S |dkrht
j t
j |¡d ¡S |  |d¡ |  ||¡S )Nz..Ú.ú\Ú_Z__downloaded__rI   r'   Úsvnzsvn+Úgitzgit+zhg+rØ   r]   T)rA   Úreplacer)   rV   r=   ra   r*   Ú_download_svnÚ_download_gitÚ_download_hgr5   r¨   Úurl2pathnamer   r6   r¼   Ú_attempt_download)r€   r;   r9   r  r+   r@   rW   r"   r"   r#   r    s(   ÿ€

zPackageIndex._download_urlc                 C   s   |   |d¡ d S )NT)rÉ   rö   r"   r"   r#   rð   1  r™   zPackageIndex.scan_urlc                 C   s2   |   ||¡}d| dd¡ ¡ v r|  |||¡S |S )Nr²   r³   r´   )r/  rÄ   r(   Ú_download_html)r€   r9   rW   rÃ   r"   r"   r#   rH  4  s   zPackageIndex._attempt_downloadc                 C   sj   t |ƒ}|D ]}| ¡ r%t d|¡r#| ¡  t |¡ |  ||¡  S  nq| ¡  t |¡ td| ƒ‚)Nz <title>([^- ]+ - )?Revision \d+:zUnexpected HTML page found at )	rä   rq   rY   rv   rÅ   rV   r   rD  r   )r€   r9   rÃ   rW   rØ   r:  r"   r"   r#   rI  ;  s   
ù
zPackageIndex._download_htmlc                 C   s  t  dt¡ | dd¡d }d}| ¡  d¡rqd|v rqtj |¡\}}}}}}	|sq| d¡rqd	|d
d … v rq|d
d …  d	d¡\}}t	|ƒ\}
}|
rqd|
v r]|
 dd¡\}}d||f }nd|
 }|}||||||	f}tj 
|¡}|  d||¡ t d|||f ¡ |S )Nz"SVN download support is deprecatedr3   r4   r   r´   zsvn:ú@z//r/   r]   ú:z --username=%s --password=%sz --username=z'Doing subversion checkout from %s to %szsvn checkout%s -q %s %s)ÚwarningsrÑ   ÚUserWarningr8   r(   r*   r5   r   r6   Ú
_splituserÚ
urlunparser¾   rV   Úsystem)r€   r9   rW   Zcredsr;   Únetlocr=   r[   ÚqrÎ   ÚauthÚhostÚuserZpwr:   r"   r"   r#   rD  J  s&   zPackageIndex._download_svnc                 C   sp   t j | ¡\}}}}}| dd¡d }| dd¡d }d }d|v r)| dd¡\}}t j ||||df¡} | |fS )Nú+r4   r0   r3   r   rJ  r´   )r5   r   Úurlsplitr8   ÚrsplitÚ
urlunsplit)r9   Ú
pop_prefixr;   rQ  r=   r?   rô   Úrevr"   r"   r#   Ú_vcs_split_rev_from_url`  s   z$PackageIndex._vcs_split_rev_from_urlc                 C   ól   |  dd¡d }| j|dd�\}}|  d||¡ t d||f ¡ |d ur4|  d|¡ t d	||f ¡ |S )
Nr3   r4   r   T©rZ  zDoing git clone from %s to %szgit clone --quiet %s %szChecking out %szgit -C %s checkout --quiet %s©r8   r\  r¾   rV   rP  ©r€   r9   rW   r[  r"   r"   r#   rE  r  ó   þzPackageIndex._download_gitc                 C   r]  )
Nr3   r4   r   Tr^  zDoing hg clone from %s to %szhg clone --quiet %s %szUpdating to %szhg --cwd %s up -C -r %s -qr_  r`  r"   r"   r#   rF  ‚  ra  zPackageIndex._download_hgc                 G   ó   t j|g|¢R Ž  d S rb   )r   r½   r÷   r"   r"   r#   r½   ’  ó   zPackageIndex.debugc                 G   rb  rb   )r   r¾   r÷   r"   r"   r#   r¾   •  rc  zPackageIndex.infoc                 G   rb  rb   )r   rÑ   r÷   r"   r"   r#   rÑ   ˜  rc  zPackageIndex.warn)rž   rŸ   NT)Frb   )FFFN)FF)*r‰   rŠ   r‹   rŒ   r“   r¯   rÉ   rº   r¼   rã   rà   rê   rË   rï   rõ   rü   rþ   r  r  rý   rú   r1   r
  r  r	  r%  r/  r)  r¿   r  rð   rH  rI  rD  Ústaticmethodr\  rE  rF  r½   r¾   rÑ   Ú__classcell__r"   r"   r°   r#   r     sV    
þ
	
5


		
#
þ
L)$
#r   z!&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?c                 C   s   |   d¡}t |¡S )Nr   )rF   r²   Zunescape)rE   Úwhatr"   r"   r#   Údecode_entity¡  s   

rg  c                 C   s
   t t| ƒS )a  
    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'
    )Ú
entity_subrg  )Útextr"   r"   r#   rt   ¦  s   
	rt   c                    s   ‡ fdd„}|S )Nc                    s   ‡ ‡fdd„}|S )Nc               	      s:   t  ¡ }t  ˆ¡ zˆ | i |¤ŽW t  |¡ S t  |¡ w rb   )r;  ÚgetdefaulttimeoutÚsetdefaulttimeout)rc   rd   Zold_timeout)rf   Útimeoutr"   r#   Ú_socket_timeout´  s
   
z@socket_timeout.<locals>._socket_timeout.<locals>._socket_timeoutr"   )rf   rm  ©rl  re   r#   rm  ³  s   z'socket_timeout.<locals>._socket_timeoutr"   )rl  rm  r"   rn  r#   Úsocket_timeout²  s   ro  c                 C   s2   t j | ¡}| ¡ }t |¡}| ¡ }| dd¡S )a9  
    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
    Ú
r´   )r5   r   r7   ÚencodeÚbase64Ú	b64encoderÈ   rC  )rS  Zauth_sZ
auth_bytesZencoded_bytesÚencodedr"   r"   r#   Ú_encode_authÁ  s
   
ru  c                   @   r|   )	Ú
Credentialz:
    A username/password pair. Use like a namedtuple.
    c                 C   s   || _ || _d S rb   ©ÚusernameÚpassword)r€   rx  ry  r"   r"   r#   r“   Û  s   
zCredential.__init__c                 c   s   � | j V  | jV  d S rb   rw  r„   r"   r"   r#   Ú__iter__ß  s   €zCredential.__iter__c                 C   s   dt | ƒ S )Nz%(username)s:%(password)s)Úvarsr„   r"   r"   r#   Ú__str__ã  s   zCredential.__str__N)r‰   rŠ   r‹   rŒ   r“   rz  r|  r"   r"   r"   r#   rv  Ö  s
    rv  c                   @   s0   e Zd Zdd„ Zedd„ ƒZdd„ Zdd„ Zd	S )
Ú
PyPIConfigc                 C   sR   t  g d¢d¡}tj | |¡ tj tj d¡d¡}tj 	|¡r'|  
|¡ dS dS )z%
        Load from ~/.pypirc
        )rx  ry  Ú
repositoryr´   ú~z.pypircN)ÚdictÚfromkeysÚconfigparserÚRawConfigParserr“   rV   r=   ra   Ú
expanduserrÐ   rÆ   )r€   ÚdefaultsÚrcr"   r"   r#   r“   è  s   ÿzPyPIConfig.__init__c                    s&   ‡ fdd„ˆ   ¡ D ƒ}ttˆ j|ƒƒS )Nc                    s    g | ]}ˆ   |d ¡ ¡ r|‘qS )r~  )rÄ   rq   )rZ   Úsectionr„   r"   r#   r  õ  s    þÿz2PyPIConfig.creds_by_repository.<locals>.<listcomp>)Úsectionsr€  ro   Ú_get_repo_cred)r€   Zsections_with_repositoriesr"   r„   r#   Úcreds_by_repositoryó  s   
ÿzPyPIConfig.creds_by_repositoryc                 C   s6   |   |d¡ ¡ }|t|   |d¡ ¡ |   |d¡ ¡ ƒfS )Nr~  rx  ry  )rÄ   rq   rv  )r€   r‡  Zrepor"   r"   r#   r‰  ü  s
   þzPyPIConfig._get_repo_credc                 C   s*   | j  ¡ D ]\}}| |¡r|  S qdS )zŒ
        If the URL indicated appears to be a repository defined in this
        config, return the credential for that repository.
        N)rŠ  Úitemsr*   )r€   r9   r~  Úcredr"   r"   r#   Úfind_credential  s
   
ÿÿzPyPIConfig.find_credentialN)r‰   rŠ   r‹   r“   ÚpropertyrŠ  r‰  r�  r"   r"   r"   r#   r}  ç  s    
r}  c                 C   s:  t j | ¡}|\}}}}}}| d¡rtj d¡‚|dv r$t|ƒ\}	}
nd}	|	sBtƒ  	| ¡}|rBt
|ƒ}	|j| f}tjdg|¢R Ž  |	redt|	ƒ }	||
||||f}t j |¡}t j |¡}| d|	¡ nt j | ¡}| dt¡ ||ƒ}|	r›t j |j¡\}}}}}}||kr›||
kr›||||||f}t j |¡|_|S )	z4Open a urllib2 request, handling HTTP authenticationrK  znonnumeric port: '')r5  ÚhttpsNz*Authenticating as %s for %s (from .pypirc)zBasic ZAuthorizationz
User-Agent)r5   r   r6   r)   r5  r6  r7  rN  r}  r�  rp   rx  r   r¾   ru  rO  r¨   ZRequestÚ
add_headerÚ
user_agentr9   )r9   rª   Úparsedr;   rQ  r=   Úparamsr?   rô   rS  ÚaddressrŒ  r¾   r:   ró   r¨   r*  Ús2Zh2Zpath2Zparam2Zquery2Zfrag2r"   r"   r#   r4    s8   

r4  c                 C   s$   |   d¡\}}} |r|| fS d| fS )zNsplituser('user[:passwd]@host[:port]')
    --> 'user[:passwd]', 'host[:port]'.rJ  N)Ú
rpartition)rT  rU  Údelimr"   r"   r#   rN  <  s   rN  c                 C   s   | S rb   r"   )r9   r"   r"   r#   Ú
fix_sf_urlG  r0  r˜  c              	   C   s*  t j | ¡\}}}}}}t j |¡}tj |¡rt j | ¡S | 	d¡r}tj 
|¡r}g }t |¡D ];}	tj ||	¡}
|	dkrXt|
dƒ�}| ¡ }W d  ƒ n1 sQw   Y   n tj 
|
¡rb|	d7 }	| dj|	d�¡ q0d}|j| d |¡d	�}d
\}}nd\}}}ddi}t |¡}t j | ||||¡S )z7Read a local path, with special support for directoriesr/   z
index.htmlÚrNz<a href="{name}">{name}</a>)r+   zB<html><head><title>{url}</title></head><body>{files}</body></html>rp  )r9   Úfiles)éÈ   ZOK)r¸   zPath not foundz	Not foundr³   z	text/html)r5   r   r6   r¨   rG  rV   r=   Úisfiler©   r)   rÒ   rÔ   ra   rä   rÆ   r  ÚformatÚioÚStringIOrÁ   rÂ   )r9   r;   r<   r=   Úparamr?   rô   rW   rš  rÎ   Úfilepathr*  ÚbodyrÍ   ÚstatusÚmessagerÃ   Zbody_streamr"   r"   r#   r3  K  s0   
ÿÿ


r3  rb   )r   )ZrŒ   ÚsysrV   rY   rž  r  r;  rr  r�   rÞ   rL  r‚  r²   Zhttp.clientr5  Úurllib.parser5   Zurllib.requestZurllib.errorÚ	functoolsr   r   Úpkg_resourcesr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   Ú	distutilsr   Údistutils.errorsr   Úfnmatchr   Úsetuptools.wheelr   Ú setuptools.extern.more_itertoolsr   rœ   rD   ÚIrr   rñ   rE   r¹   r8   rP   Ú__all__Z_SOCKET_TIMEOUTZ_tmplr�  Úversion_infor‘  r$   r   rA   r   rC   rX   r   rh   rk   r{   r}   r�   r   rò   rh  rg  rt   ro  ru  rv  rƒ  r}  r¨   r©   r4  rN  r˜  r3  r"   r"   r"   r#   Ú<module>   sŽ    @
ÿÿ	


!
þ#
!     

&/