o
    *‘siTœ  ã                   @   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"   ú}C:\Users\PC\students\dividedattentionclub\pushnotificationexperiment\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ú,Z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    €€
€ûrz   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|   Úpatternru   Ú	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                       s\  e Zd ZdZ		dN‡ fd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                    sl   t ƒ j|i |¤Ž |dd | d¡ …  | _i | _i | _i | _t d 	t
t|ƒ¡¡j| _g | _tjj| _d S )Nr/   ú|)Úsuperr’   r)   Ú	index_urlÚscanned_urlsÚfetched_urlsÚpackage_pagesrY   r›   ra   rn   r   rE   ÚallowsÚto_scanr5   ÚrequestÚurlopenÚopener)r   r¢   ÚhostsZ	ca_bundleZ
verify_sslrc   Úkw©Ú	__class__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   Ú	Exceptionr¡   Úadd)r   rH   r­   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¤   rn   r°   ÚinfoÚopen_urlÚ
isinstancer5   ÚerrorÚ	HTTPErrorr¶   rš   r9   ÚheadersÚgetr(   ÚcloseÚreadro   Ú	get_paramÚdecoderq   rk   r   rr   rs   rF   Úprocess_urlr*   r¢   ÚgetattrÚprocess_index)r   r9   ÚretrieveÚdistsÚtmplÚfr,   rv   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º   rn   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Ý   rn   ro   rp   rQ   r
   rK   r   rB   r°   )r   r=   rÜ   Z	raw_linesÚlinesZ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º   rn   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>)rq   rk   ré   r5   r   rr   rs   rF   r   rz   rA   r)   Úneed_version_infoÚscan_urlÚPYPI_MD5Úsub)	r   r9   rv   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   Ú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º   rn   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#   rt   ]  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  Zlocal_indexrH   rt   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rztj |¡}tj |¡|krGtj 	||¡}tj 
|¡r?tj ||¡sGt ||¡ |}ttj 	|d¡dƒ�}| d|d j|d jtj |¡d f ¡ W d   ƒ |S 1 ssw   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   zsetup.pyÚwzIfrom setuptools import setup
setup(name=%r, version=%r, py_modules=[%r])
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   rÐ   ÚsamefileÚshutilÚcopy2rä   ÚwriterL   rM   Úsplitextr   )	r   rW   r@   r  rE   rÌ   rR   ÚdstrØ   r"   r"   r#   r	  ž  sD   

þýþþÿ
ÿ	÷	þÿÿ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Úmaxrn   Ú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"   )ro   )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ÚreasonÚBadStatusLineÚlineÚ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ï   0  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  3  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ä   rp   rY   ru   rÄ   rV   rÿ   rD  r   )r   r9   rÂ   rW   rØ   r9  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   Úcredsr;   Únetlocr=   r[   ÚqrÎ   ÚauthÚhostÚuserÚpwr:   r"   r"   r#   rD  I  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;   rR  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©r\  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  q  ó   þ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 -qra  rb  r"   r"   r#   rF  �  rc  zPackageIndex._download_hgc                 G   ó   t j|g|¢R Ž  d S rb   )r   r¼   rö   r"   r"   r#   r¼   ‘  ó   zPackageIndex.debugc                 G   rd  rb   )r   r½   rö   r"   r"   r#   r½   ”  re  zPackageIndex.infoc                 G   rd  rb   )r   rÑ   rö   r"   r"   r#   rÑ   —  re  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±   Úunescape)rE   Úwhatr"   r"   r#   Údecode_entity   s   

rj  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_subrj  )Útextr"   r"   r#   rs   ¥  s   
	rs   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   rp  ©ro  re   r#   rp  ²  s   z'socket_timeout.<locals>._socket_timeoutr"   )ro  rp  r"   rq  r#   Úsocket_timeout±  s   rr  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  )rT  Zauth_sZ
auth_bytesZencoded_bytesÚencodedr"   r"   r#   Ú_encode_authÀ  s
   
rx  c                   @   r{   )	Ú
Credentialz:
    A username/password pair. Use like a namedtuple.
    c                 C   s   || _ || _d S rb   ©ÚusernameÚpassword)r   r{  r|  r"   r"   r#   r’   Ú  s   
zCredential.__init__c                 c   s   � | j V  | jV  d S rb   rz  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’   r}  r  r"   r"   r"   r#   ry  Õ  s
    ry  c                       s8   e Zd Z‡ fdd„Zedd„ ƒZdd„ Zdd„ Z‡  ZS )	Ú
PyPIConfigc                    sP   t  g d¢d¡}tƒ  |¡ tj tj d¡d¡}tj |¡r&|  	|¡ dS dS )z%
        Load from ~/.pypirc
        )r{  r|  Ú
repositoryr³   ú~z.pypircN)
ÚdictÚfromkeysr¡   r’   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Ã   rp   )rZ   Úsectionrƒ   r"   r#   r  ô  s    þÿz2PyPIConfig.creds_by_repository.<locals>.<listcomp>)Úsectionsrƒ  rn   Ú_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�  r{  r|  )rÃ   rp   ry  )r   rˆ  Ú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_credential)	rˆ   r‰   rŠ   r’   Úpropertyr‹  rŠ  r�  rg  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: '')r3  ÚhttpsNz*Authenticating as %s for %s (from .pypirc)zBasic ÚAuthorizationz
User-Agent)r5   r   r6   r)   r3  r4  r5  rN  r€  r�  ro   r{  r   r½   rx  rO  r¨   ÚRequestÚ
add_headerÚ
user_agentr9   )r9   rª   Úparsedr;   rR  r=   Úparamsr?   ró   rT  ÚaddressrŽ  r½   r:   rò   r¨   r(  Ús2Úh2Zpath2Zparam2Zquery2Zfrag2r"   r"   r#   r2    s8   

r2  c                 C   s$   |   d¡\}}} |r|| fS d| fS )zNsplituser('user[:passwd]@host[:port]')
    --> 'user[:passwd]', 'host[:port]'.rJ  N)Ú
rpartition)rU  rV  Údelimr"   r"   r#   rN  ;  s   rN  c                 C   s   | S rb   r"   )r9   r"   r"   r#   Ú
fix_sf_urlF  r.  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>rs  )r9   Úfiles)éÈ   Ú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#   r1  J  s0   
ÿÿ


r1  rb   )r   )Zr‹   ÚsysrV   rY   r¤  r  r;  ru  rŽ   rÞ   rL  Úconfigparserr±   Úhttp.clientr3  Úurllib.parser5   Úurllib.requestÚurllib.errorÚ	functoolsr   r   Úpkg_resourcesr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   Ú	distutilsr   Zdistutils.errorsr   Úfnmatchr   Zsetuptools.wheelr   Z setuptools.extern.more_itertoolsr   r›   rD   ÚIrq   rð   rE   r¸   r8   rP   Ú__all__Z_SOCKET_TIMEOUTZ_tmplr£  Úversion_infor•  r$   r   rA   r   rC   rX   r   rh   rj   rz   r|   rŒ   r   rñ   rk  rj  rs   rr  rx  ry  ÚRawConfigParserr€  r¨   r©   r2  rN  r�  r1  r"   r"   r"   r#   Ú<module>   sŽ    @
ÿÿ	


!
þ#
!     	
&/