
    N9hG                    ~   S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJr  SSKJr  SSKJr  SSKJr  SSKrSSKJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,  SS	K-J.r.  S
SK/J0r0J1r1  SSK2J3r3  SSK4J5r5  \Rl                  " S5      r7\Rl                  " S\Rp                  5      r9\Rl                  " S5      r:\Rl                  " S\Rp                  5      Rv                  r<SR{                  5       r>/ SQr?Sr@S\R                   S\R                  R                   S\R                  R                   3rES rFS rGS rHS5S jrIS5S jrJS5S jrKS\#S4S jrLS rM\Rl                  " S \Rp                  5      rN \MS! 5       rO " S" S#5      rP " S$ S%\P5      rQ " S& S'\%5      rR\Rl                  " S(5      R                  rTS) rUS* rVS6S+ jrWS, rX " S- S.\5      rY " S/ S0\R                  5      r[\R                  R                  4S1 jr^S2 r_\W" \@5      " \^5      r^S3 r`S4 rag)7z$PyPI and direct package downloading.    )annotationsN)	translatewraps)
NamedTupleunique_everseen)BINARY_DISTCHECKOUT_DISTDEVELOP_DISTEGG_DISTSOURCE_DISTDistributionEnvironmentRequirementfind_distributionsnormalize_pathparse_version	safe_namesafe_versionto_filename)Wheel   )_cfg_read_utf8_with_fallback_read_utf8_with_fallback)log)DistutilsErrorz^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/z Python-urllib/.c                t     [         R                  " U 5      $ ! [         a  n[        SU < 35      UeS nAff = f)Nz/Not a URL, existing file, or requirement spec: )r   parse
ValueErrorr   )speces     8lib/python3.13/site-packages/setuptools/package_index.pyparse_requirement_argr*   H   sB      && =dXF
	s    
727c                f   U R                  5       nSu  p#nUR                  S5      (       a  UR                  S5      (       a  U SS nSnOeUR                  SS5      (       a  U S	S
 nU SS nSnOAUR                  S5      (       a  U SS nSnO#UR                  SS5      (       a  U S	S
 nU SS nSnX#U4$ )z=Return (base,pyversion) or (None,None) for possible .exe name)NNN.exez
.win32.exeNiwin32z	.win32-pyiiz.win-amd64.exeiz	win-amd64z.win-amd64-pyi)lowerendswith
startswith)namer/   basepy_verplats        r)   r    r    Q   s     JJLE)D$~~f>>,'':DDk3//"R[F:DD^^,--:DDos33"R[F:DD    c                b   [         R                  R                  U 5      nUu  p#pEpg[         R                  R                  UR	                  S5      S   5      nUS:X  a7  US:X  a1  [         R                  R                  UR	                  S5      S   5      nSU;   a  UR	                  SS5      u  pX4$ )N/zsourceforge.netdownload#r   )urllibr%   urlparseunquotesplit)	urlparts_schemeserverpath_parameters_queryfragmentr3   s	            r)   egg_info_for_urlrI   i   s    LL!!#&E;@8GT<<

3 34D""tz'9||##DJJsOB$78
d{C+>r6   c              #     #    [        U 5      u  p#[        XU5       Sh  vN   U(       aD  [        R                  U5      nU(       a'  [	        XR                  S5      U[        S9 Sh  vN   ggg NP N	7f)zEYield egg or source distribution objects that might be found at a URLNr   )
precedence)rI   distros_for_locationEGG_FRAGMENTmatchr!   groupr   )rA   metadatar3   rH   rN   s        r)   r   r   t   sl     %c*ND#Cx888""8,,[[^X-     9s"   A4A0AA4(A2)A42A4c                b   UR                  S5      (       a  USS nUR                  S5      (       a  SU;   a  [        R                  " XU5      /$ UR                  S5      (       aP  SU;   aJ  [        U5      nUR	                  5       (       d  / $ [        U UR
                  UR                  [        S-   S9/$ UR                  S	5      (       a#  [        U5      u  pEnUb  [        XX%[        U5      $ [         H6  nUR                  U5      (       d  M  US[        U5      *  n[        XU5      s  $    / $ )
z:Yield egg or source distribution objects based on basenamez.egg.zipNr.   .egg-z.whlr   )locationproject_nameversionrK   r,   )r0   r   from_locationr   is_compatiblerU   rV   r   r    r!   r
   
EXTENSIONSlen)rT   basenamerP   wheelwin_baser4   platformexts           r)   rL   rL      s,   $$CR=  SH_**8xHII  SH_h""$$I!"//#a<
 	
   %8%B"((Hk8 
 S!!3s8),H(XFF  Ir6   c                h    [        [        U 5      [        R                  R	                  U 5      U5      $ )zEYield possible egg or source distribution objects based on a filename)rL   r   osrE   r[   )filenamerP   s     r)   distros_for_filenamerc      s*    x "''"2"28"<h r6   c           
   #  ^  #    UR                  S5      nU(       d  [        S USS  5       5      (       a  g[        [        U5      5       H  nXg   SS R	                  5       (       d  M    O   [        U5      n[        U USR                  USU 5      SR                  XgS 5      UUUS9v   g7f)zGenerate the interpretation 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!
rS   c              3  P   #    U  H  n[         R                  " S U5      v   M     g7f)z	py\d\.\d$N)rerN   ).0ps     r)   	<genexpr>(interpret_distro_name.<locals>.<genexpr>   s     KAbhh|Q77s   $&   Nr   )
py_versionrK   r^   )r@   anyrangerZ   isdigitr   join)rT   r[   rP   rl   rK   r^   rB   rh   s           r)   r!   r!      s      NN3E#KqrKKK 3u:8BQ<!!  J
rr s   A#B-)AB-c                0   ^  [        T 5      U 4S j5       nU$ )zg
Wrap a function returning an iterable such that the resulting iterable
only ever yields unique items.
c                 &   > [        T" U 0 UD65      $ Nr   )argskwargsfuncs     r)   wrapperunique_values.<locals>.wrapper   s    tT4V455r6   r   )rv   rw   s   ` r)   unique_valuesry      s"     4[6 6 Nr6   z3<([^>]*\srel\s{0,10}=\s{0,10}['"]?([^'" >]+)[^>]*)>c           
   #    #    [         R                  U5       H  nUR                  5       u  p4[        [	        [
        R                  UR                  5       R                  S5      5      5      nSU;   d  SU;   d  Mc  [        R                  U5       H=  n[        R                  R                  U [        UR                  S5      5      5      v   M?     M     S Ht  nUR                  U5      nUS:w  d  M  [        R!                  X5      nU(       d  M:  [        R                  R                  U [        UR                  S5      5      5      v   Mv     g7f)zEFind rel="homepage" and rel="download" links in `page`, yielding URLs,homepager:   r   )z<th>Home Pagez<th>Download URLr9   N)RELfinditergroupssetmapstrstripr/   r@   HREFr=   r%   urljoin
htmldecoderO   findsearch)rA   pagerN   tagrelrelsposs          r)   find_external_linksr      s      d#<<>3syy#))+"3"3C"89:t!3s+ll**3
5;;q>0JKK ,	 $ 5iin"9KK*Eull**3
5;;q>0JKK 5s   A5E;A4E3E?Ec                  *    \ rS rSrSrS rS rS rSrg)ContentChecker   zH
A null content checker that defines the interface for checking content
c                    g)z#
Feed a block of data to the hash.
N selfblocks     r)   feedContentChecker.feed   s     	r6   c                    g)z3
Check the hash. Return False if validation fails.
Tr   r   s    r)   is_validContentChecker.is_valid   s     r6   c                    g)z]
Call reporter with information about the checker (hash name)
substituted into the template.
Nr   )r   reportertemplates      r)   reportContentChecker.report  s    
 	r6   r   N)	__name__
__module____qualname____firstlineno____doc__r   r   r   __static_attributes__r   r6   r)   r   r      s    r6   r   c                  d    \ rS rSr\R
                  " S5      rS
S jr\S 5       r	S r
S rS rSrg	)HashCheckeri  zK(?P<hash_name>sha1|sha224|sha384|sha256|sha512|md5)=(?P<expected>[a-f0-9]+)c                R    Xl         [        R                  " U5      U l        X l        g rs   )	hash_namehashlibnewhashexpected)r   r   r   s      r)   __init__HashChecker.__init__  s    "KK	*	 r6   c                    [         R                  R                  U5      S   nU(       d
  [        5       $ U R                  R                  U5      nU(       d
  [        5       $ U " S0 UR                  5       D6$ )z5Construct a (possibly null) ContentChecker from a URLr9   r   )r=   r%   r>   r   patternr   	groupdict)clsrA   rH   rN   s       r)   from_urlHashChecker.from_url  s^     <<((-b1!##""8,!##'U__&''r6   c                :    U R                   R                  U5        g rs   )r   updater   s     r)   r   HashChecker.feed!  s    		r6   c                P    U R                   R                  5       U R                  :H  $ rs   )r   	hexdigestr   r   s    r)   r   HashChecker.is_valid$  s    yy""$55r6   c                .    X R                   -  nU" U5      $ rs   )r   )r   r   r   msgs       r)   r   HashChecker.report'  s    '}r6   )r   r   r   NreturnNone)r   r   r   r   rf   compiler   r   classmethodr   r   r   r   r   r   r6   r)   r   r     s=    jj	#G
!
 ( ( 6r6   r   c                    ^  \ rS rSrSr    S*     S+U 4S jjjrU 4S jrS,S-S jjrS,S.S jjrS,S/S jjr	S0S jr
S0S	 jrS
 rS rS0S jrS1S0S jjrS0S jrS1U 4S jjrS0S jrS0S jrS rS0S jrS r    S2       S3S jjr S4     S5S jjrS rSrS rS0S jrS1S jr\S 5       r\ S 5       r!S r"\S 5       r#S  r$S! r%S0S" jr&S# r'S$ r(\S% 5       r)S0S& jr*S0S' jr+S0S( jr,S)r-U =r.$ )6r   i,  z;A distribution index that scans web pages for download URLsc                b  > [         TU ]  " U0 UD6  USS UR                  S5      (       +  -   U l        0 U l        0 U l        0 U l        [        R                  " SR                  [        [        U5      5      5      R                  U l        / U l        [        R                   R"                  U l        g )Nr8   |)superr   r0   	index_urlscanned_urlsfetched_urlspackage_pagesrf   r   rp   r   r   rN   allowsto_scanr=   requesturlopenopener)r   r   hosts	ca_bundle
verify_sslrt   kw	__class__s          r)   r   PackageIndex.__init__/  s     	$%"%"S)Fy/A/A#/F+F%GG"$"$#%jj#i*?!@AGGnn,,r6   c                n   >  [        UR                  5        [        TU ]  U5      $ ! [         a     g f = frs   )r   rV   	Exceptionr   add)r   distr   s     r)   r   PackageIndex.addA  s9    	$,,' w{4    		s   ' 
44c           	        [         R                  " S5      (       a  [        SU-  5      eXR                  ;   a  U(       d  gSU R                  U'   [	        U5      (       d  U R                  U5        g[        [        U5      5      nU(       a)  U R                  U5      (       d  gU R                  SU5        U(       d  U(       a  XR                  ;   a   [        [        U R                  U5      5        gU R                  U5      (       d  SU R                  U'   gU R                  SU5        SU R                  U'   SnU R                  XU-  5      nUc  g[        U[         R"                  R$                  5      (       a.  UR&                  S:X  a  U R                  S	UR(                   35        SU R                  UR*                  '   S
UR,                  R/                  SS5      R1                  5       ;  a  UR3                  5         gUR*                  nUR5                  5       n[        U[6        5      (       db  [        U[         R"                  R$                  5      (       a  SnO$UR,                  R9                  S5      =(       d    SnUR;                  US5      nUR3                  5         [<        R?                  U5       HL  n	[         R@                  RC                  U[E        U	RG                  S5      5      5      n
U RI                  U
5        MN     URK                  U RL                  5      (       a$  [O        USS5      S:w  a  U RQ                  X5      nggg)z<Evaluate a URL as a possible download, and maybe retrieve itCONDA_BUILDzkSetuptools downloading is disabled in conda build. Be sure to add all dependencies in the meta.yaml  url=%sNTzFound link: %sz
Reading %sz<Download error on %s: %%s -- Some packages may not be found!i  zAuthentication error: htmlcontent-type zlatin-1charsetignorer   code  ))ra   getenvRuntimeErrorr   
URL_SCHEMEprocess_filenamelistr   url_okdebugr   r   r   infoopen_url
isinstancer=   error	HTTPErrorr   r   rA   headersgetr/   closereadr   	get_paramdecoder   r~   r%   r   r   rO   process_urlr1   r   getattrprocess_index)r   rA   retrievediststmplfr3   r   r   rN   links              r)   r   PackageIndex.process_urlJ  s   99]##  Z\_ ` a a ###H!%##!!#&-.E{{3''

+S1C+<+<$<TXXu%&{{3%)Dc"		,$!%#MMM#cz*9a//00QVVs]II.quug67#'!%% ~r:@@BBGGIuuvvx$$$!V\\3344#))--i8EI;;w1D		]]4(E<<''jQ.HIDT" ) >>$..))ga.F#.M%%c0D /N)r6   c                &   [         R                  R                  U5      (       d  U R                  SU5        g [         R                  R	                  U5      (       ar  U(       dk  [         R                  R                  U5      n[         R                  " U5       H2  nU R                  [         R                  R                  X45      S5        M4     [        U5      nU(       a2  U R                  SU5        [        [        U R                  U5      5        g g )NzNot found: %sTz	Found: %s)ra   rE   existswarnisdirrealpathlistdirr   rp   rc   r   r   r   r   )r   fnnestedrE   itemr   s         r)   r   PackageIndex.process_filename  s    ww~~b!!IIor*77==V77##B'D

4(%%bggll4&>E ) %R(JJ{B'TXXu%& r6   c                :   [        U5      nU=(       a"    UR                  S5      R                  5       S:H  nU(       d6  U R                  [        R
                  R                  U5      S   5      (       a  gSnU(       a  [        XQ-  5      eU R                  XQ5        g)Nr   fileTz
Note: Bypassing %s (disallowed host; see https://setuptools.pypa.io/en/latest/deprecated/easy_install.html#restricting-downloads-with-allow-hosts for details).
F)	r   rO   r/   r   r=   r%   r>   r   r  )r   rA   fatalsis_filer   s         r)   r   PackageIndex.url_ok  s    sO4
((*f4dkk&,,"7"7"<Q"?@@W 	
  ++IIcr6   c                    [        [        R                  R                  U5      nS U 5       n[	        [
        R                  " U R                  U5      5        g )Nc              3     #    U  H>  n[         R                  " U5        H   nUR                  S 5      (       d  M  X4v   M"     M@     g7f)z	.egg-linkN)ra   r  r0   )rg   rE   entrys      r)   ri   .PackageIndex.scan_egg_links.<locals>.<genexpr>  s=      
D)~~k* TM) s
   4AA)filterra   rE   r  r   	itertoolsstarmapscan_egg_link)r   search_pathdirs	egg_linkss       r)   scan_egg_linksPackageIndex.scan_egg_links  sB    bggmm[1

	 	Yt119=>r6   c           
        [        [        R                  R                  X5      5      n[	        [        S [        [        R                  UR                  5       5      5      5      n[        U5      S:w  a  g Uu  pV[        [        R                  R                  X5      5       HE  n[        R                  R                  " U/UQ76 Ul        [        Ul        U R                  U5        MG     g )Nrk   )r   ra   rE   rp   r   r  r   r   r   
splitlinesrZ   r   rT   r   rK   r   )r   rE   r  contentlinesegg_path_setup_pathr   s           r)   r  PackageIndex.scan_egg_link  s    *277<<+DEVD#cii1C1C1E"FGHu:? %&rww||D'CDDGGLL66DM)DOHHTN Er6   c           	        SnUR                  U R                  5      (       d  U$ [        [        [        R
                  R                  U[        U R                  5      S  R                  S5      5      5      n[        U5      S:w  d	  SUS   ;   a  U$ [        US   5      n[        US   5      nSU R                  R                  UR                  5       0 5      U'   [        U5      [        U5      4$ )NNNr8   rk   r<   r   r   T)r1   r   r   r   r=   r%   r?   rZ   r@   r   r   r   
setdefaultr/   r   )r   r   NO_MATCH_SENTINELrB   pkgvers         r)   _scanPackageIndex._scan  s    &t~~..$$S--tC4G4I/J/P/PQT/UVWu:?cU1Xo$$ a!58$?C%%ciik26t<3S!111r6   c                2   [         R                  U5       HK  n U R                  [        R                  R                  U[        UR                  S5      5      5      5        MM     U R                  U5      u  pEU(       d  g[        X5       Hb  n[        U5      u  pxUR                  S5      (       a+  U(       d$  U(       a  USU SU 3-  nOU R                  U5        U R                  U5        Md     [        R                  S U5      $ ! [         a     M  f = f)z#Process the contents of a PyPI pager   r   .pyz#egg=rS   c                B    SR                   " U R                  SSS5      6 $ )Nz<a href="{}#md5={}">{}</a>r      rk   )formatrO   )ms    r)   <lambda>,PackageIndex.process_index.<locals>.<lambda>  s    2991771a;KLr6   )r   r~   r,  r=   r%   r   r   rO   r&   r   rI   r0   need_version_infoscan_urlPYPI_MD5sub)	r   rA   r   rN   r*  r+  new_urlr3   frags	            r)   r   PackageIndex.process_index  s     ]]4(E

6<<//ZA5OPQ ) ::c? +35G)'2JD}}U##Dse1SE22G**3/MM'" 6 ||Ld
 	
%  s   AD
DDc                (    U R                  SU5        g )NzPPage at %s links to .py file(s) without version info; an index scan is required.)scan_allr   rA   s     r)   r6  PackageIndex.need_version_info  s     	
r6   c                    U R                   U R                  ;  a+  U(       a  U R                  " U/UQ76   U R                  S5        U R	                  U R                   5        g )Nz6Scanning index of all packages (this may take a while))r   r   r  r   r7  r   r   rt   s      r)   r>  PackageIndex.scan_all  sE    >>!2!22		#%%IINOdnn%r6   c                   U R                  U R                  UR                  -   S-   5        U R                  R	                  UR
                  5      (       d+  U R                  U R                  UR                  -   S-   5        U R                  R	                  UR
                  5      (       d  U R                  U5        [        U R                  R	                  UR
                  S5      5       H  nU R                  U5        M     g )Nr8   r   )	r7  r   unsafe_namer   r   keyrU   not_found_in_indexr   )r   requirementrA   s      r)   find_packagesPackageIndex.find_packages  s    dnn{'>'>>DE!!%%koo66MM$..;+C+CCcIJ!!%%koo66##K0**..{CDCMM# Er6   c                   > U R                  5         U R                  U5        XR                      H  nX1;   a  Us  $ U R                  SX5        M      [        TU ]  X5      $ )Nz%s does not match %s)prescanrI  rF  r   r   obtain)r   rH  	installerr   r   s       r)   rM  PackageIndex.obtain  sV    ;')D"JJ-{A * w~k55r6   c                <   UR                  U R                  SU 35        UR                  5       (       dh  UR                  5         [        R
                  " U5        [        UR                  R                   S[        R                  R                  U5       S35      eg)z
checker is a ContentChecker
zValidating %s checksum for z validation failed for z; possible download problem?N)r   r   r   r   ra   unlinkr   r   r2   rE   r[   )r   checkerrb   tfps       r)   
check_hashPackageIndex.check_hash  s     	tzz%@
#KL!!IIKIIh <<$$%%<RWW=M=Mh=W<X Y- -  "r6   c                
   U H}  nU R                   b?  [        U5      (       a/  UR                  S5      (       d  [        [	        U5      5      (       a  U R                  U5        Mb  U R                   R                  U5        M     g)z;Add `urls` to the list that will be prescanned for searchesNfile:)r   r   r1   r   r   r7  append)r   urlsrA   s      r)   add_find_linksPackageIndex.add_find_links  s`    C$!#>>'**,-- c" ##C( r6   c                    U R                   (       a)  [        [        U R                  U R                   5      5        SU l         g)z7Scan urls scheduled for prescanning (e.g. --find-links)N)r   r   r   r7  r   s    r)   rL  PackageIndex.prescan,  s'    <<T]]DLL12r6   c                    XR                      (       a  U R                  Sp2OU R                  Sp2U" X1R                  5        U R	                  5         g )Nz#Couldn't retrieve index page for %rz3Couldn't find index page for %r (maybe misspelled?))rF  r   r  rE  r>  )r   rH  methr   s       r)   rG  PackageIndex.not_found_in_index2  s;     		#H#		#X#S))*r6   c                z   [        U[        5      (       d  [        U5      nU(       aH  U R                  X5      n[	        U5      u  pVUR                  S5      (       a  U R                  XFU5      nU$ [        R                  R                  U5      (       a  U$ [        U5      n[        U R                  X5      SS5      $ )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.
r/  rT   N)r   r   r   _download_urlrI   r0   	gen_setupra   rE   r  r*   r   fetch_distribution)r   r'   tmpdirschemefoundr3   rH   s          r)   r:   PackageIndex.download:  s    $ $,,%F**48!1$!7=='' NN5FCE%%,T2t..t<j$OOr6   c                &  ^ ^^^^	 T R                  SU5        [        5       m	SnS	S
UU U	UU4S jjjnU(       a)  T R                  5         T R                  U5        U" U5      nU(       d  Ub  U" X5      nUc%  T R                  b  T R                  5         U" U5      nUc   U(       d  T R                  U5        U" U5      nUc&  T R                  ST=(       a    S=(       d    SU5        gT R                  SU5        UR                  UR                  S9$ )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                  > Uc  TnXR                       H  nUR                  [        :X  a2  T(       d+  UT;  a#  TR                  SU5        TR	                  U5        MI  X ;   =(       a!    UR                  [
        :*  =(       d    T(       + nU(       d  M~  TR                  UR                  T	5      nXBl        [        R                  R                  UR                  5      (       d  M  Us  $    g )Nz&Skipping development or system egg: %s)rF  rK   r   r  r   r   r:   rT   download_locationra   rE   r  )
reqenvr   testloc
develop_okr   skippedsourcere  s
        r)   r   -PackageIndex.fetch_distribution.<locals>.findz  s    { GG??l2:7*		D   D){U;(F(Tf*4--v>C-0*ww~~d&<&<==# %" r6   z:No local packages or working download links found for %s%sza source distribution of r   zBest match: %s)rT   rs   )rm  zEnvironment | None)r   r   rL  rI  r   r  clonerk  )
r   rH  re  
force_scanrr  rp  local_indexr   r   rq  s
   ` ` ``   @r)   rd  PackageIndex.fetch_distribution\  s    4 			$k2%	 	0 LLN{+$D/1D<||'$D<
{+$D<IIL77=2
 II&-::t'='=:>>r6   c                F    U R                  XX45      nUb  UR                  $ g)a  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)rd  rT   )r   rH  re  ru  rr  r   s         r)   fetchPackageIndex.fetch  s)     &&{JO== r6   c                    [         R                  U5      nU=(       a?    [        XR                  S5      S 5       Vs/ s H  nUR                  (       d  M  UPM     sn=(       d    / n[        U5      S:X  GaM  [        R                  R                  U5      n[        R                  R                  U5      U:w  a  [        R                  R                  X75      n[        R                  R                  U5      (       a$  [        R                  R                  X5      (       d  [        R                  " X5        Un[        [        R                  R                  US5      SSS9 n	U	R!                  SUS   R"                  < SUS   R                  < S	[        R                  R%                  U5      S   < S
35        S S S 5        U$ U(       a  ['        SU< SU< 35      e['        S5      es  snf ! , (       d  f       U$ = f)Nr   zsetup.pywzutf-8)encodingz(from setuptools import setup
setup(name=r   z
, version=z, py_modules=[z])
z9Can't unambiguously interpret project/version identifier zI; any dashes in the name or version should be escaped using underscores. zpCan't process plain .py files without an '#egg=name-version' suffix to enable automatic setup script generation.)rM   rN   r!   rO   rV   rZ   ra   rE   r[   dirnamerp   r  samefileshutilcopy2openwriterU   splitextr   )
r   rb   rH   re  rN   dr   r[   dstr  s
             r)   rc  PackageIndex.gen_setup  s   ""8,  /xQNNA99 N  	 u:?ww''1H wwx(F2ggll64s++0@0@0O0OLL/"Hbggll6:6gNRV

""'("7"7!:*U1XEUEUDXXfgigngngwgw  yA  hB  CD  hE  gH  HLM O
 O KH< X  %y*  !G A$ ON
 Os   G)G)!AG..
G=i    c                l   U R                  SU5        S n [        R                  U5      nU R                  U5      n[	        U[
        R                  R                  5      (       a(  [        SU SUR                   SUR                   35      eUR                  5       nSnU R                  nSnSU;   a=  UR                  S5      n	[        [        [        U	5      5      nU R!                  XXgU5        [#        US	5       n
 UR%                  U5      nU(       a;  UR'                  U5        U
R)                  U5        US
-  nU R!                  XXgU5        OOMV  U R+                  XBU
5        S S S 5        UU(       a  UR-                  5         $ $ ! , (       d  f       N(= f! U(       a  UR-                  5         f f = f)NzDownloading %szCan't download :  r   r9   zcontent-lengthzContent-Lengthwbr   )r   r   r   r   r   r=   r   r   r   r   r   dl_blocksizeget_allmaxr   int
reporthookr  r   r   r  rT  r   )r   rA   rb   fprR  r   blocknumbssizesizesrS  r   s               r)   _download_toPackageIndex._download_to  sm   		"C(	!**3/Gs#B"fll4455$se2bggYax%PQQggiGH""BD7*(893sE?+xTBh%GGBKEU+		%( AxTJ  37 & 
  &% 
 s%   C&F <A*F&	F 
FF F3c                    g rs   r   )r   rA   rb   r  blksizer  s         r)   r  PackageIndex.reporthook
  s    r6   c           	     $   UR                  S5      (       a  [        U5      $  [        XR                  5      $ ! [        [
        R                  R                  4 an  nSR                  UR                   Vs/ s H  n[        U5      PM     Os  snf sn5      nU(       a  U R                  X%5         S nAg [        U SU 35      UeS nAf[        R                  R                   a  nUs S nA$ S nAf[        R                  R                    aH  nU(       a   U R                  X#R"                  5         S nAg [        SU SUR"                   35      UeS nAf[
        R                  R$                   aG  nU(       a   U R                  X#R&                  5         S nAg [        U SUR&                   35      UeS nAf[
        R                  R(                  [*        4 a4  nU(       a  U R                  X#5         S nAg [        SU SU 35      UeS nAff = f)NrW  r  zDownload error for r  z7 returned a bad status line. The server might be down, )r1   
local_openopen_with_authr   r&   httpclient
InvalidURLrp   rt   r   r  r   r=   r   r   URLErrorreasonBadStatusLinelineHTTPExceptionOSError)r   rA   warningvargr   s         r)   r   PackageIndex.open_url  s   >>'""c?"	N!#{{33DKK223 	<((7CH78C		'''$uAcU^4!;||%% 	H||$$ 	U		'88,,$':3%r!((%LMSTT{{(( 			'66**$e VVH&  ))73 	N		'%%$':3%r!%EFAM		Nso   8 $HC5B

%C4C!H&C-'H-!H"E5E!H2"F4F44'HH
8H

Hc                T    SR                  S5      n[        R                  " USU 5      $ )a9  
Replace unsafe path directives with underscores.

>>> san = PackageIndex._sanitize
>>> san('/home/user/.ssh/authorized_keys')
'_home_user_.ssh_authorized_keys'
>>> san('..\\foo\\bing')
'__foo_bing'
>>> san('D:bar')
'D_bar'
>>> san('C:\\bar')
'C__bar'
>>> san('foo..bar')
'foo..bar'
>>> san('D:../foo')
'D___foo'
r   ):z[/\\]z6(?:(?<=([/\\]|:))\.\.(?=[/\\]|$))|(?:^\.\.(?=[/\\]|$))_)rp   rf   r9  )r2   r   s     r)   	_sanitizePackageIndex._sanitize.  s,    & (( 
  vvgtT**r6   c                    [        U5      u  p4U R                  U=(       d    S5      n[        R                  " SSU5      n[        R
                  R                  X#5      $ )a  
>>> import pathlib
>>> du = PackageIndex._resolve_download_filename
>>> root = getfixture('tmp_path')
>>> url = 'https://files.pythonhosted.org/packages/a9/5a/0db.../setuptools-78.1.0.tar.gz'
>>> str(pathlib.Path(du(url, root)).relative_to(root))
'setuptools-78.1.0.tar.gz'
__downloaded__z\.egg\.zip$rR   )rI   r  rf   r9  ra   rE   rp   )r   rA   re  r2   	_fragments        r)   _resolve_download_filename'PackageIndex._resolve_download_filenameK  sR     +3/}}  	
 vvnfd3ww||F))r6   c                v    U R                  X5      nU R                  X5      =(       d    U R                  X5      $ )z"
Determine the download filename.
)r  _download_vcs_download_other)r   rA   re  rb   s       r)   rb  PackageIndex._download_urlb  s5     223?!!#0WD4H4H4WWr6   c                    [         R                  R                  U 5      R                  nUR	                  S5      u  p#n[        SS/S/[        U5      -  -   5      n[        [        U1U-  5      S5      $ )z
>>> rvcs = PackageIndex._resolve_vcs
>>> rvcs('git+http://foo/bar')
'git'
>>> rvcs('hg+https://foo/bar')
'hg'
>>> rvcs('git:myhost')
'git'
>>> rvcs('hg:myhost')
>>> rvcs('http://foo/bar')
+svngithgN)	r=   r%   urlsplitrf  	partitionr   boolnextiter)rA   rf  presep_postalloweds         r)   _resolve_vcsPackageIndex._resolve_vcsi  sh     &&s+22 **3/%uenvS	'99:D#)400r6   c                   U R                  U5      nU(       d  g US:X  a  [        SU 35      eUR                  S5      u  n  nU R                  U5      u  pU R	                  SU SU SU 35        [
        R                  " USSX/5        [        US	US
SU/USUSS	SUS/S9nUb,  U R	                  SU 35        [
        R                  " Xs   5        U$ )Nr  z/Invalid config, SVN download is not supported: r<   zDoing z clone from z to rt  z--quietz-Ccheckoutz--cwdupz-rz-q)r  r  zChecking out )r  r   r  _vcs_split_rev_from_urlr   
subprocess
check_calldict)r   rA   spec_filenamevcsrb   r  revco_commandss           r)   r  PackageIndex._download_vcs|  s    $%< A#G  '005!Q//4		F3%|C5XJ?@sGYFGdHj)SAWhdD#tD
 ?IIcU+,!!+"23r6   c                2   [         R                  R                  U5      R                  nUS:X  aF  [         R                  R                  [         R                  R                  U5      R                  5      $ U R                  US5        U R                  X5      $ )Nr  T)
r=   r%   r  rf  r   url2pathnamer>   rE   r   _attempt_download)r   rA   rb   rf  s       r)   r  PackageIndex._download_other  sm    &&s+22V>>..v||/D/DS/I/N/NOOC%%c44r6   c                (    U R                  US5        g )NT)r   r?  s     r)   r7  PackageIndex.scan_url  s    d#r6   c                    U R                  X5      nSUR                  SS5      R                  5       ;   a  U R                  XU5      $ U$ )Nr   r   r   )r  r   r/   _invalid_download_html)r   rA   rb   r   s       r)   r  PackageIndex._attempt_download  sF    ##C2W[[4::<<..sXFFOr6   c                J    [         R                  " U5        [        SU 35      e)NzUnexpected HTML page found at )ra   rQ  r   )r   rA   r   rb   s       r)   r  #PackageIndex._invalid_download_html  s!    
		(=cUCDDr6   c                H   [         R                  R                  U 5      nUR                  R	                  SS5      S   nUR
                  R                  S5      u  n  nUR                  S5      u  pVnU(       a  XW4OUS4u  pUR                  UUSS9R                  5       n
X4$ )	a  
Given a possible VCS URL, return a clean URL and resolved revision if any.

>>> vsrfu = PackageIndex._vcs_split_rev_from_url
>>> vsrfu('git+https://github.com/pypa/setuptools@v69.0.0#egg-info=setuptools')
('https://github.com/pypa/setuptools', 'v69.0.0')
>>> vsrfu('git+https://github.com/pypa/setuptools#egg-info=setuptools')
('https://github.com/pypa/setuptools', None)
>>> vsrfu('http://foo/bar')
('http://foo/bar', None)
r  r   r9   r<   @Nr   )rf  rE   rH   )
r=   r%   r  rf  r@   rE   r  
rpartition_replacegeturl)rA   rB   clean_schemeno_fragment_pathr  r  r  post
clean_pathr  resolveds              r)   r  $PackageIndex._vcs_split_rev_from_url  s     %%c*||))#q1"5 "'!5!5c!:!Q)44S9$),3+4,
>>	 " 

 &( 	 }r6   c                2    [         R                  " U/UQ76   g rs   )r   r   rB  s      r)   r   PackageIndex.debug  s    		#r6   c                2    [         R                  " U/UQ76   g rs   )r   r   rB  s      r)   r   PackageIndex.info      tr6   c                2    [         R                  " U/UQ76   g rs   )r   r  rB  s      r)   r  PackageIndex.warn  r  r6   )r   r   r   r   r   r   r   )zhttps://pypi.org/simple/)*NT)r   r   r   r  r   r   )F)r   r  r   r   )r	  r  r   r   )r  r  r   r  r   rs   )FFFN)ru  r  rr  r  rp  r  r   zDistribution | None)FF)ru  r  rr  r  r   z
str | None)/r   r   r   r   r   r   r   r   r   r   r  r  r,  r   r6  r>  rI  rM  rT  rZ  rL  rG  r:   rd  ry  rc  r  r  r  r   staticmethodr  r   r  rb  r  r  r  r7  r  r  r  r   r   r  r   __classcell__r   s   @r)   r   r   ,  s   E 4--
 - 
- -$!71r'  ? 2 
:
&6) PL ! P? 	P?
 P? P? 
P?f MR/3EI	'R L DN@ + +8 * *,X 1 1$25$E  > r6   r   z!&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?c                P    U R                  S5      n[        R                  " U5      $ )Nr   )rO   r   unescape)rN   whats     r)   decode_entityr    s    ;;q>D==r6   c                "    [        [        U 5      $ )z
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_subr  )texts    r)   r   r     s     mT**r6   c                   ^  U 4S jnU$ )Nc                   >^  U U4S jnU$ )Nc                    > [         R                  " 5       n[         R                  " T5         T" U 0 UD6[         R                  " U5        $ ! [         R                  " U5        f = frs   )socketgetdefaulttimeoutsetdefaulttimeout)rt   ru   old_timeoutrv   timeouts      r)   _socket_timeout@socket_timeout.<locals>._socket_timeout.<locals>._socket_timeout  sN     224K$$W-6T,V,((5((5s   A A$r   )rv   r  r  s   ` r)   r  'socket_timeout.<locals>._socket_timeout  s    	6 r6   r   )r  r  s   ` r)   socket_timeoutr    s    	 r6   c                    [         R                  R                  U 5      nUR                  5       n[        R
                  " U5      nUR                  5       nUR                  SS5      $ )a  
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   )r=   r%   r?   encodebase64	b64encoder   replace)authauth_s
auth_bytesencoded_bytesencodeds        r)   _encode_authr    sR     \\!!$'FJ$$Z0M""$G??4$$r6   c                  8    \ rS rSr% SrS\S'   S\S'   S	S jrSrg)

Credentiali  zx
A username/password pair.

Displayed separated by `:`.
>>> str(Credential('username', 'password'))
'username:password'
r   usernamepasswordc                8    U R                    SU R                   3$ )Nr  )r  r  r   s    r)   __str__Credential.__str__  s    --$--11r6   r   N)r   r   )r   r   r   r   r   __annotations__r  r   r   r6   r)   r  r    s     MM2r6   r  c                  D   ^  \ rS rSrU 4S jr\S 5       rS rS rSr	U =r
$ )
PyPIConfigi  c                .  > [         R                  / SQS5      n[        TU ]  U5        [        R
                  R                  [        R
                  R                  S5      S5      n[        R
                  R                  U5      (       a  [        X5        gg)z
Load from ~/.pypirc
)r  r  
repositoryr   ~z.pypircN)
r  fromkeysr   r   ra   rE   rp   
expanduserr  r   )r   defaultsrcr   s      r)   r   PyPIConfig.__init__   sf     ==!GL"WW\\"'',,S19=77>>"(2 r6   c                    U R                  5        Vs/ s H,  nU R                  US5      R                  5       (       d  M*  UPM.     nn[        [	        U R
                  U5      5      $ s  snf )Nr   )sectionsr   r   r  r   _get_repo_cred)r   sectionsections_with_repositoriess      r)   creds_by_repositoryPyPIConfig.creds_by_repository+  sa      ==?&
*xx.446 * 	# &
 C++-GHII&
s   )A' A'c                    U R                  US5      R                  5       nU[        U R                  US5      R                  5       U R                  US5      R                  5       5      4$ )Nr   r  r  )r   r   r  )r   r*  repos      r)   r)  PyPIConfig._get_repo_cred5  s]    xx.446ZHHWj)//1HHWj)//1
 
 	
r6   c                ~    U R                   R                  5        H  u  p#UR                  U5      (       d  M  Us  $    g)zt
If the URL indicated appears to be a repository defined in this
config, return the credential for that repository.
N)r,  itemsr1   )r   rA   r   creds       r)   find_credentialPyPIConfig.find_credential<  s:    
 !% 8 8 > > @J~~j)) !A r6   r   )r   r   r   r   r   propertyr,  r)  r4  r   r  r  s   @r)   r  r    s-    	3 J J
 r6   r  c                   [         R                  R                  U 5      nUu  p4pVpxUR                  S5      (       a  [        R
                  R                  S5      eUS;   a  [        U5      u  pOSu  pU	(       dP  [        5       R                  U 5      nU(       a0  [        U5      n	UR                  U 4n[        R                  " S/UQ76   U	(       ad  S[        U	5      -   n	X:XVXx4n[         R                  R                  U5      n[         R                   R#                  U5      nUR%                  SU	5        O[         R                   R#                  U 5      nUR%                  S[&        5        U" U5      nU	(       ah  [         R                  R                  UR(                  5      u  nnnnnnUU:X  a2  UU
:X  a,  UUUUUU4n[         R                  R                  U5      Ul        U$ )	z4Open a urllib2 request, handling HTTP authenticationr  znonnumeric port: '')r  httpsr'  z*Authenticating as %s for %s (from .pypirc)zBasic Authorizationz
User-Agent)r=   r%   r>   r0   r  r  r  
_splituserr  r4  r   r  r   r   r  
urlunparser   Request
add_header
user_agentrA   )rA   r   parsedrf  netlocrE   paramsqueryr;  r  addressr3  r   rB   r:  r   r  s2h2path2param2query2frag2s                          r)   r  r  G  s    \\""3'F06-FD% skk$$%:;;"""6*g$|++C0t9D==#%DHHAIDI,t,,u:,,))%0..((1?D1..((-|Z0	B 06||/D/DRVV/L,Bvvu<B'Mvvu<E\\,,U3BFIr6   c                F    U R                  S5      u  pn U(       a  X4$ SU 4$ )zJsplituser('user[:passwd]@host[:port]')
--> 'user[:passwd]', 'host[:port]'.r  N)r  )hostuserdelims      r)   r:  r:  w  s,     ,DD**td**r6   c                    U $ rs   r   )rA   s    r)   
fix_sf_urlrO    s    Jr6   c                p   [         R                  R                  U 5      u  pp4pV[         R                  R	                  U5      n[
        R                  R                  U5      (       a  [         R                  R                  U 5      $ UR                  S5      (       a  [
        R                  R                  U5      (       a  / n[
        R                  " U5       Hv  n	[
        R                  R                  Xy5      n
U	S:X  a  [        U
5      n  Of[
        R                  R                  U
5      (       a  U	S-  n	UR                  SU	 SU	 S35        Mx     SnUR                  U SR                  U5      S9nS	u  pOS
u  pnSS0n[         R"                  " U5      n[         R$                  R'                  XXU5      $ )z7Read a local path, with special support for directoriesr8   z
index.htmlz	<a href="z">z</a>zB<html><head><title>{url}</title></head><body>{files}</body></html>r
  )rA   files)   OK)r   zPath not foundz	Not foundr   z	text/html)r=   r%   r>   r   r  ra   rE   isfiler   r0   r  r  rp   r   rX  r2  ioStringIOr   r   )rA   rC   _serverrE   _paramrG   _fragrb   rQ  r   filepathbodyr   statusmessager   body_streams                    r)   r  r    sW   4:LL4I4I#4N1GdF~~**40H	ww~~h~~%%c**	s		h 7 7H%Aww||H0HL /9x((SLL9QCr!D12 & XD;;3dii.>;?D# B{+G++d#K<<!!#wMMr6   rs   )r"   )br   
__future__r   r  configparserr   r   http.clientr  rU  r  ra   rf   r  r   r  sysurllib.errorr=   urllib.parseurllib.requestfnmatchr   	functoolsr   typingr   more_itertoolsr	   
setuptoolspkg_resourcesr
   r   r   r   r   r   r   r   r   r   r   r   r   r   setuptools.wheelr   unicode_utilsr   r   	distutilsr   distutils.errorsr   r   rM   Ir   r8  rN   r   r@   rY   __all___SOCKET_TIMEOUT__version__version_infomajorminorr>  r*   r    rI   r   rL   rc   r!   ry   r}   r   r   r   r   r9  r  r  r   r  r  r  RawConfigParserr  r   r   r  r:  rO  r  r   r6   r)   <module>rx     s$   * "      	  	 	    
       *      # Q  +zz67	zz3RTT:::J ZZ,bdd399
.446
 :112/#BRBRBXBXAYYZ[^[k[k[q[qZrs
0	 F .2kTXD
 	jjKRTTR
 L L$ 2. Bf
; f
V ZZ<=AA

	+%*2 2 %-- %P  &~~55 +`+  0@Nr6   