
    fXf                       d dl Z d dlmZ d dlZd dlZd dlm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n# e$ r dZY nw xY wd dlZd dlZd dlZd dlZd dlZ	 d dlZn# e$ r d dlZY nw xY wd dlZddlm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)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0  e
j1        e2          Z3 ej4        d          Z5 ej4        d          Z6 ej4        d	          Z7 ej4        d
          Z8 ej4        d          Z9 ej4        d          Z: ej4        d          Z; ej4        d          Z<d Z=d Z>d Z?d Z@d ZAdkdZBd ZCd ZDd ZEejF        d             ZGejF        d             ZHejF        dld            ZI G d deJ          ZKd ZL G d d eJ          ZMd! ZN G d" d#eJ          ZO ej4        d$ejP                  ZQd% ZRdmd&ZSd' ZTd( ZUd) ZVd* ZWd+ ZX ej4        d,ejY                  ZZ ej4        d-          Z[dmd.Z\ ej4        d/          Z]d0 Z^d1 Z_d2 Z`d3Zad4 Zbd5 Zc G d6 d7eJ          Zd G d8 d9eJ          Ze G d: d;eJ          Zfd<Zgdnd>Zhd? Zid@Zj G dA dBeJ          Zk ej4        dC          Zl ej4        dD          Zm ej4        dE          ZndF ZdG Zoer:ddHlmpZqmrZrmsZs  G dI dJe$jt                  Zt G dK dLeq          Zp G dM dNepe'          Zu G dO dPe%jv                  Zver G dQ dRe%jw                  Zw G dS dTe%jx                  ZxdU Zy G dV dWeJ          Zz G dX dYez          Z{ G dZ d[ez          Z| G d\ d]e(          Z} G d^ d_eJ          Z~d` Z G da dbeJ          Zdc Zdd Zde ZdfdgdhdiZdj ZdS )o    N)deque)iglob   )DistlibException)string_types	text_typeshutil	raw_inputStringIOcache_from_sourceurlopenurljoinhttplib	xmlrpclib	splittypeHTTPHandlerBaseConfiguratorvalid_ident	ContainerconfigparserURLErrorZipFilefsdecodeunquoteurlparsez^([\w\.-]+)\s*z^([\w\.*+-]+)\s*z^(<=?|>=?|={2,3}|[~!]=)\s*z*^((<=?)|(>=?)|={2,3}|[~!]=|in|not\s+in)\s*z^or\b\s*z	^and\b\s*z(\S+)\s*z(([\s\w\.{}()*+#:;,/?!~`@$%^&=|<>\[\]-]+)c                 F    d fdfdfd |           S )ae  
    Parse a marker string and return a dictionary containing a marker expression.

    The dictionary will contain keys "op", "lhs" and "rhs" for non-terminals in
    the expression grammar, or strings. A string contained in quotes is to be
    interpreted as a literal string, and a string not contained in quotes is a
    variable (such as os_name).
    c                    t                               |           }|r8|                                d         }| |                                d          } ns| st	          d          | d         }|dvrt	          d| z            d                    |d          }| dd          } |g}| r| d         |k    rn| d         |k    r |                    |           | dd          } nwt                              |           }|st	          d| z            |                    |                                d                    | |                                d          } | d                    |          }t	          d|z            |                    |           d                    |          }| dd          	                                } || fS )	Nr   zunexpected end of inputz'"zinvalid expression: %s r   zerror in string literal: %szunterminated string: %s)

IDENTIFIERmatchgroupsendSyntaxErrorreplaceappendSTRING_CHUNKjoinlstrip)	remainingmresultqoqpartsss          Q/var/www/html/Qu*py/bism/lib/python3.11/site-packages/pip/_vendor/distlib/util.py
marker_varz parse_marker.<locals>.marker_varA   s   Y'' 	/XXZZ]F!!%%''((+II 	/7888!A~~!":Y"FGGGq"%%B!!""ICE AQ<1$$q\R''LL$$$ )!""II$**955A U)*G)*STTTLLA/// )!%%''(( 3I  A GGENN!";a"?@@@LLOOOWWU^^F!!"",,..Iy      c                    | ro| d         dk    rc | dd                                                     \  }} | d         dk    rt          d| z            | dd                                           } n{ |           \  }} | rit                              |           }|snL|                                d         }| |                                d          }  |           \  }} |||d}| i|}|| fS )Nr   (r   )unterminated parenthesis: %soplhsrhs)r(   r#   	MARKER_OPr    r!   r"   )r)   r+   r9   r*   r8   r:   markerr1   s         r0   marker_exprz!parse_marker.<locals>.marker_expre   s    	1,, &y}';';'='= > >FI|s""!"@9"LMMM!!"",,..II'Z	22NC 9OOI.. XXZZ]%aeegghh/	!+I!6!6YC88  9 Fy  r2   c                      |           \  }} | rOt                               |           }|sn2| |                                d          }  |           \  }} d||d}| O|| fS )Nandr7   )ANDr    r"   )r)   r9   r*   r:   r=   s       r0   
marker_andz parse_marker.<locals>.marker_andx   s    $Y//Y 	8		)$$A !!%%''((+I([33NCs377C  	8 I~r2   c                      |           \  }} | rOt                               |           }|sn2| |                                d          }  |           \  }} d||d}| O|| fS )Norr7   )ORr    r"   )r)   r9   r*   r:   rA   s       r0   r<   zparse_marker.<locals>.marker   s    #I..Y 	7##A !!%%''((+I'Z	22NCc#66C  	7 I~r2    )marker_stringr<   rA   r=   r1   s    @@@@r0   parse_markerrG   8   sx    "! "! "!H! ! ! ! ! !&	 	 	 	 		 	 	 	 	 6-   r2   c                    |                                  }|r|                    d          rdS t                              |          }|st	          d|z            |                                d         }||                                d         }dx}x}x}}|r"|d         dk    r|                    dd          }|dk     rt	          d|z            |d|         }	||dz   d                                         }g }|	rt                              |	          }|st	          d	|	z            |	                    |                                d                    |	|                                d         }	|	sn<|	d         d
k    rt	          d|	z            |	dd                                         }	|	|sd}|r|d         dk    r|dd                                         }t                              |          }|st	          d|z            |                                d         }t          |          }
|
j        r|
j        st	          d|z            ||                                d                                         }n.d }|d         dk    r ||          \  }}n|                    dd          }|dk     rt	          d|z            |d|         }	||dz   d                                         }t                              |	          r ||	          \  }}nt                              |	          }|st	          d|	z            |                                d         }|	|                                d                                         }	|	rt	          d|	z            d|fg}|rL|d         dk    rt	          d|z            |dd                                         }t!          |          \  }}|r|d         dk    rt	          d|z            |s|}n$|dd                    d |D                       }t%          ||||||          S )z
    Parse a requirement passed in as a string. Return a Container
    whose attributes contain the various parts of the requirement.
    #Nzname expected: %sr   []r   zunterminated extra: %szmalformed extra: %s,zcomma expected in extras: %s@zinvalid URI: %szInvalid URL: %sc                 t   t                               |           }d}|rg }	 |                                d         }| |                                d         } t                              |           }|st          d| z            |                                d         }|                    ||f           | |                                d         } | r| d         dk    rnO| dd                                         } | sn0t                               |           }|st          d| z            |sd}|| fS )z|
                Return a list of operator, version tuples if any are
                specified, else None.
                NTr   zinvalid version: %srL   r   invalid constraint: %s)
COMPARE_OPr    r!   r"   VERSION_IDENTIFIERr#   r%   r(   )ver_remainingr*   versionsr8   vs        r0   get_versionsz'parse_requirement.<locals>.get_versions   sT   
 $$]33 (!HXXXZZ](5aeegghh(?.44]CC  U"-.Cm.S"T"TTHHJJqM Q000(5aeegghh(?, "a0@C0G0G!(5abb(9(@(@(B(B  - "!&,,];;  X"-.F.V"W"WW%X& $ (#'..r2   r4   r5   r6   rO   z~=;zinvalid requirement: %szunexpected trailing data: %s , c                     g | ]}d |z  S )z%s %srE   ).0cons     r0   
<listcomp>z%parse_requirement.<locals>.<listcomp>	  s    ,O,O,OsWs],O,O,Or2   )nameextrasconstraintsr<   urlrequirement)strip
startswithr   r    r#   r!   r"   findr(   r%   	NON_SPACEr   schemenetlocrP   rQ   rG   r'   r   )reqr)   r*   distnamer^   	mark_exprrS   uriir/   trU   _rT   rss                  r0   parse_requirementrp      s   
 		I 	,,S11 t##A ;-	9:::xxzz!}H!%%''((#I*..F.Y.C Yq\S((NN3""q556BCCCacNa!eff%,,..	 
	  ##A =!"7!";<<<MM!((**Q-(((!%%''((A ts{{!"@1"DEEE!""A  
	  	F G+Q<3!!"",,..I	**A A!"3i"?@@@((**Q-CA
 H ; ;!"3c"9:::!!%%''((+2244II/ / /@ |s""&2l9&=&=#))NN3**q55%&Dy&PQQQacN%a!eff-4466	 ##A&& 
+".,q//KHaa*0033A H)*BQ*FGGG

1A!%%''((**,,A H)*BQ*FGGG!%q	{H 7Q<37)CDDDabbM((**	+I66	9 FYq\S((89DEEE R $)),O,Oh,O,O,O"P"P"PQ(6x%3B@ @ @ @r2   c                    d }i }|D ]\  }}}t           j                            | |          }t          |          D ]}t           j                            ||          }	t          |	          D ]v}
 || |
          }||                    |d           ' |||
          }|                    t           j        j        d                              d          }|dz   |z   ||<   w|S )z%Find destinations for resources filesc                    |                      t          j        j        d          } |                     t          j        j        d          }|                    |           sJ |t          |           d                              d          S N/)r$   ospathseprc   lenr(   )rootrv   s     r0   get_rel_pathz)get_resources_dests.<locals>.get_rel_path  sk    ||BGK--||BGK--t$$$$$CIIJJ&&s+++r2   Nrt   )ru   rv   r'   r   popr$   rw   rstrip)resources_rootrulesrz   destinationsbasesuffixdestprefixabs_baseabs_globabs_pathresource_filerel_pathrel_dests                 r0   get_resources_destsr     s   , , , L# L Lfdnd33f 		L 		LHw||Hf55H!(OO L L ,^X F F< $$]D9999+|Hh??H#||BGK==DDSIIH2:S.82KL//L		L r2   c                      t          t          d          rd} n.t          j        t          t          dt          j                  k    } | S )Nreal_prefixTbase_prefix)hasattrsysr   getattrr+   s    r0   in_venvr   (  s=    sM"" G wsM3:FFFMr2   c                  f    t           j        } t          | t                    st	          |           } | S N)r   
executable
isinstancer   r   r   s    r0   get_executabler   2  s/     ^Ffi(( "&!!Mr2   c                     | }	 t          |          }| }|s|r|}|r)|d                                         }||v rn|rd||| fz  }C|S )NTr   z	%c: %s
%s)r
   lower)promptallowed_charserror_promptdefaultpr/   cs          r0   proceedr   D  s|    A
=aLL 	W 	A 	=!

AM!! = A|V#<<
= Hr2   c                     t          |t                    r|                                }i }|D ]}|| v r| |         ||<   |S r   )r   r   split)dkeysr+   keys       r0   extract_by_keyr   T  sQ    $%% zz||F ! !!88C&F3KMr2   c                    t           j        d         dk    r t          j        d          |           } |                                 }t          |          } 	 t          j        |           }|d         d         d         }|                                D ]>\  }}|                                D ]$\  }}|d|}t          |          }	|	J |	||<   %?|S # t          $ r |                     dd           Y nw xY wd }
t          j                    }	  |
||            nX# t          j        $ rF |                                  t!          j        |          }t          |          }  |
||            Y nw xY wi }|                                D ]C}i x||<   }|                    |          D ]$\  }}|d|}t          |          }	|	J |	||<   %D|S )	Nr      utf-8
extensionszpython.exportsexports = c                 ~    t          | d          r|                     |           d S |                     |           d S )N	read_file)r   r   readfp)cpstreams     r0   read_streamz!read_exports.<locals>.read_streamq  sD    2{## 	LL     IIfr2   )r   version_infocodecs	getreaderreadr   jsonloaditemsget_export_entry	Exceptionseekr   ConfigParserMissingSectionHeaderErrorclosetextwrapdedentsections)r   datajdatar+   groupentrieskrT   r/   entryr   r   r   r]   values                  r0   read_exportsr   ]  s:   
a*!'**622;;==Dd^^F	&!!|$%56yA$llnn 	# 	#NE7 # #1!"AA&(++((("

	#
    Aq   
	"	$	$B B1      t$$$B	  F{{}} " " ""sg88C== 	" 	"KD%!TT55)A$Q''E$$$!GDMM	" Ms&   A<C  C87C8D AE43E4c                    t           j        d         dk    r t          j        d          |          }t	          j                    }|                                 D ]\  }}|                    |           |                                D ]e}|j	        |j
        }n|j
        d|j	        }|j        r |dd                    |j                  d}|                    ||j        |           f|                    |           d S )Nr   r   r   :z [rX   rK   )r   r   r   	getwriterr   r   r   add_sectionvaluesr   r   flagsr'   setr]   write)r   r   r   r   rT   r   r/   s          r0   write_exportsr     s   
a*!'**622		"	$	$B 
% 
%1
qXXZZ 	% 	%E|#L$|||U\\:{ <!"DIIek$:$:$:$:;FF1ej!$$$$	% HHVr2   c               #      K   t          j                    } 	 | V  t          j        |            d S # t          j        |            w xY wr   )tempfilemkdtempr	   rmtree)tds    r0   tempdirr     sN      				Bbbs	   1 Ac              #      K   t          j                    }	 t          j        |            d V  t          j        |           d S # t          j        |           w xY wr   )ru   getcwdchdir)r   cwds     r0   r   r     sO      
)++C

   A A   c              #      K   t          j                    }	 t          j        |            d V  t          j        |           d S # t          j        |           w xY wr   )socketgetdefaulttimeoutsetdefaulttimeout)secondsctos     r0   socket_timeoutr     sa      

"
$
$C& ))) %%%%% %%%%r   c                       e Zd Zd ZddZdS )cached_propertyc                     || _         d S r   )func)selfr   s     r0   __init__zcached_property.__init__  s    			r2   Nc                     || S |                      |          }t                              || j         j        |           |S r   )r   object__setattr____name__)r   objclsr   s       r0   __get__zcached_property.__get__  s=    ;K		#3	 2E:::r2   r   )r   
__module____qualname__r   r   rE   r2   r0   r   r     s7          
     r2   r   c                    t           j        dk    r| S | s| S | d         dk    rt          d| z            | d         dk    rt          d| z            |                     d          }t           j        |v r-|                    t           j                   t           j        |v -|st           j        S t          j        j        | S )a  Return 'pathname' as a name that will work on the native filesystem.

    The path is split on '/' and put back together again using the current
    directory separator.  Needed because filenames in the setup script are
    always supplied in Unix style, and have to be converted to the local
    convention before we can actually use them in the filesystem.  Raises
    ValueError on non-Unix-ish systems if 'pathname' either starts or
    ends with a slash.
    rt   r   zpath '%s' cannot be absolutezpath '%s' cannot end with '/')ru   rw   
ValueErrorr   curdirremoverv   r'   )pathnamepathss     r0   convert_pathr     s     
v}} {c7(BCCC|s88CDDDNN3E
)u

RY )u

 y7<r2   c                   v    e Zd ZddZd Zd Zd ZddZdd	Zd
 Z	d Z
d Zd Zd ZddZd Zd Zd Zd ZdS )FileOperatorFc                 b    || _         t                      | _        |                                  d S r   )dry_runr   ensured_init_record)r   r  s     r0   r   zFileOperator.__init__  s,    uur2   c                 `    d| _         t                      | _        t                      | _        d S NF)recordr   files_writtendirs_createdr   s    r0   r  zFileOperator._init_record  s'     UUEEr2   c                 L    | j         r| j                            |           d S d S r   )r  r  add)r   rv   s     r0   record_as_writtenzFileOperator.record_as_written  s3    ; 	)""4(((((	) 	)r2   c                 H   t           j                            |          s/t          dt           j                            |          z            t           j                            |          sdS t          j        |          j        t          j        |          j        k    S )a  Tell if the target is newer than the source.

        Returns true if 'source' exists and is more recently modified than
        'target', or if 'source' exists and 'target' doesn't.

        Returns false if both exist and 'target' is the same age or younger
        than 'source'. Raise PackagingFileError if 'source' does not exist.

        Note that this test is not very accurate: files created in the same
        second will have the same "age".
        zfile '%r' does not existT)ru   rv   existsr   abspathstatst_mtime)r   sourcetargets      r0   newerzFileOperator.newer  s     w~~f%% 	<"#=#%7??6#:#:$; < < <w~~f%% 	4wv'"'&//*BBBr2   Tc                    |                      t          j                            |                     t                              d||           | j        sd}|rht          j                            |          rd|z  }nCt          j                            |          r$t          j        	                    |          sd|z  }|rt          |dz             t          j        ||           |                     |           dS )z8Copy a file respecting dry-run and force flags.
        zCopying %s to %sNz%s is a symlinkz%s is a non-regular filez which would be overwritten)
ensure_dirru   rv   dirnameloggerinfor  islinkr  isfiler   r	   copyfiler  )r   infileoutfilecheckmsgs        r0   	copy_filezFileOperator.copy_file  s     	00111&888| 		-C ?7>>'** ?+g5CCW^^G,, ?RW^^G5L5L ?4w>C F 'D!DEEEOFG,,,w'''''r2   Nc                    t           j                            |          rJ |                     t           j                            |                     t
                              d||           | j        sn|t          |d          }nt          j        |d|          }	 t          j        ||           |                                 n# |                                 w xY w|                     |           d S )NzCopying stream %s to %swbwencoding)ru   rv   isdirr  r  r  r  r  openr   r	   copyfileobjr   r  )r   instreamr  r&  	outstreams        r0   copy_streamzFileOperator.copy_stream  s    7==)))))00111-xAAA| 	" $//		"KxHHH	""8Y777!!!!	!!!!w'''''s   "C C"c                    |                      t          j                            |                     | j        spt          j                            |          rt          j        |           t          |d          5 }|                    |           d d d            n# 1 swxY w Y   | 	                    |           d S )Nr#  )
r  ru   rv   r  r  r  r   r(  r   r  )r   rv   r   fs       r0   write_binary_filezFileOperator.write_binary_file'  s    --...| 	w~~d##  	$dD!! Q              t$$$$$s   =BB#&B#c                 X    |                      ||                    |                     d S r   )r/  encode)r   rv   r   r&  s       r0   write_text_filezFileOperator.write_text_file0  s*    tT[[%:%:;;;;;r2   c                 ^   t           j        dk    s t           j        dk    rt           j        dk    rz|D ]y}| j        rt                              d|           %t          j        |          j        |z  |z  }t                              d||           t          j        ||           vd S d S d S )Nposixjavazchanging mode of %szchanging mode of %s to %o)	ru   r]   _namer  r  r  r  st_modechmod)r   bitsmaskfilesr.  modes         r0   set_modezFileOperator.set_mode3  s    7g"'V"3"3G8K8K  & &< &KK 5q9999GAJJ.5=DKK ;QEEEHQ%%%% #4"38K8K& &r2   c                 0    |                      dd|          S )Nim  i  )r=  )r/   r.  s     r0   <lambda>zFileOperator.<lambda>?  s    qzz%'C'C r2   c                    t           j                            |          }|| j        vrt           j                            |          s| j                            |           t           j                            |          \  }}|                     |           t          	                    d|z             | j
        st          j        |           | j        r | j                            |           d S d S d S d S )NzCreating %s)ru   rv   r  r  r  r  r   r  r  r  r  mkdirr  r  )r   rv   r   r.  s       r0   r  zFileOperator.ensure_dirA  s    wt$$t|##BGNN4,@,@#LT"""7==&&DAqOOAKK,---< { ,!%%d+++++ $###, ,r2   c                    t          ||           }t                              d||           | j        s|s|                     ||          r3|sd }n.|                    |          sJ |t          |          d          }i }|r)t          t          d          rt          j	        j
        |d<   t          j        |||dfi | |                     |           |S )NzByte-compiling %s to %sPycInvalidationModeinvalidation_modeT)r   r  r  r  r  rc   rx   r   
py_compilerC  CHECKED_HASHcompiler  )	r   rv   optimizeforcer   hashed_invalidationdpathdiagpathcompile_kwargss	            r0   byte_compilezFileOperator.byte_compileM  s    !$H55-tU;;;| 
	N 2

4// 2 2#HH??622222#CKKLL1HN" bwz;P'Q'Q b6@6T6a23tUHdMMnMMMu%%%r2   c                    t           j                            |          r+t           j                            |          rt           j                            |          sft
                              d|           | j        st          j	        |           | j
        r%|| j        v r| j                            |           d S d S d S t           j                            |          rd}nd}t
                              d||           | j        st          j        |           | j
        r'|| j        v r | j                            |           d S d S d S d S )NzRemoving directory tree at %slinkfilezRemoving %s %s)ru   rv   r  r'  r  r  debugr  r	   r   r  r  r   r  )r   rv   r/   s      r0   ensure_removedzFileOperator.ensure_removed^  sX   7>>$ 	8w}}T"" 827>>$+?+? 8<dCCC| (M$'''; 7t000)00666667 700 7>>$'' AAA-q$777| $IdOOO; 8t111*11$77777%	8 	8 8 811r2   c                     d}|sit           j                            |          r t          j        |t           j                  }n*t           j                            |          }||k    rn|}|i|S r  )ru   rv   r  accessW_OKr  )r   rv   r+   parents       r0   is_writablezFileOperator.is_writables  sp     	w~~d## 411W__T**F~~D  	 r2   c                 \    | j         sJ | j        | j        f}|                                  |S )zV
        Commit recorded changes, turn off recording, return
        changes.
        )r  r  r  r  )r   r+   s     r0   commitzFileOperator.commit  s9    
 {#T%66r2   c                    | j         st          | j                  D ]5}t          j                            |          rt          j        |           6t          | j        d          }|D ]o}t          j	        |          }|rC|dgk    sJ t          j        
                    ||d                   }t          j        |           t          j        |           p|                                  d S )NT)reverse__pycache__r   )r  listr  ru   rv   r  r   sortedr  listdirr'   rmdirr  )r   r.  dirsr   flistsds         r0   rollbackzFileOperator.rollback  s    | 	$,-- ! !7>>!$$ !IaLLL $+T:::D  
1 ! ]O3333aq22BHRLLLr2   FTr   )FFNF)r   r   r   r   r  r  r  r!  r,  r/  r2  r=  set_executable_moder  rN  rS  rX  rZ  re  rE   r2   r0   r   r     s          
" " "
) ) )C C C(( ( ( ("( ( ( (% % %< < <
& 
& 
& DC
, 
, 
,   "8 8 8*
 
 
      r2   r   c                 
   | t           j        v rt           j        |          }nt          |           }||}nM|                    d          }t	          ||                    d                    }|D ]}t	          ||          }|S )N.r   )r   modules
__import__r   r   r{   )module_namedotted_pathmodr+   r.   r   s         r0   resolverp    s    ck!!k+&%%!!#&&eiill++ 	( 	(AVQ''FFMr2   c                   D    e Zd Zd Zed             Zd Zd Zej	        Z	dS )ExportEntryc                 >    || _         || _        || _        || _        d S r   r]   r   r   r   )r   r]   r   r   r   s        r0   r   zExportEntry.__init__  s"    	


r2   c                 6    t          | j        | j                  S r   )rp  r   r   r	  s    r0   r   zExportEntry.value  s    t{DK000r2   c           	      H    d| j         d| j        d| j        d| j        d	S )Nz<ExportEntry r   r   rW   >rt  r	  s    r0   __repr__zExportEntry.__repr__  s2     04			4;;;04TZZZI 	Ir2   c                     t          |t                    sd}n@| j        |j        k    o/| j        |j        k    o| j        |j        k    o| j        |j        k    }|S r  )r   rr  r]   r   r   r   )r   otherr+   s      r0   __eq__zExportEntry.__eq__  sh    %-- 	1FFi5:- 0kU\10kU\10 jEK/  r2   N)
r   r   r   r   r   r   rx  r{  r   __hash__rE   r2   r0   rr  rr    sb           1 1 _1I I I   HHHr2   rr  z(?P<name>(\w|[-.+])+)
                      \s*=\s*(?P<callable>(\w+)([:\.]\w+)*)
                      \s*(\[\s*(?P<flags>[\w-]+(=\w+)?(,\s*\w+(=\w+)?)*)\s*\])?
                      c                    t                               |           }|sd }d| v sd| v rt          d| z            n|                                }|d         }|d         }|                    d          }|dk    r|d }}n0|dk    rt          d| z            |                    d          \  }}|d	         }	|	d| v sd| v rt          d| z            g }	nd
 |	                    d          D             }	t          ||||	          }|S )NrJ   rK   zInvalid specification '%s'r]   callabler   r   r   r   c                 6    g | ]}|                                 S rE   rb   )rZ   r.  s     r0   r\   z$get_export_entry.<locals>.<listcomp>  s     9991QWWYY999r2   rL   )ENTRY_REsearchr   	groupdictcountr   rr  )
specificationr*   r+   r   r]   rv   colonsr   r   r   s
             r0   r   r     sX   &&A :-3-#7#7" $*,9$: ; ; ; $8 KKMMy}CQ;;!4FFF{{& (.0=(> ? ? ?!ZZ__NFF'
=m##sm';';& (.0=(> ? ? ?EE99C(8(8999ET66599Mr2   c                    | d} t           j        dk    r.dt           j        v r t           j                            d          }nt           j                            d          }t           j                            |          r=t          j        |t           j                  }|st          
                    d|           nG	 t          j        |           d}n/# t          $ r" t          
                    d	|d
           d}Y nw xY w|s.t          j                    }t          
                    d|           t           j                            ||           S )a  
    Return the default base location for distlib caches. If the directory does
    not exist, it is created. Use the suffix provided for the base directory,
    and default to '.distlib' if it isn't provided.

    On Windows, if LOCALAPPDATA is defined in the environment, then it is
    assumed to be a directory, and will be the parent directory of the result.
    On POSIX, and on Windows if LOCALAPPDATA is not defined, the user's home
    directory - using os.expanduser('~') - will be the parent directory of
    the result.

    The result is just the directory '.distlib' in the parent directory as
    determined above, or with the name specified with ``suffix``.
    Nz.distlibntLOCALAPPDATAz$localappdata~z(Directory exists but is not writable: %sTzUnable to create %s)exc_infoFz#Default location unusable, using %s)ru   r]   environrv   
expandvars
expanduserr'  rU  rV  r  warningmakedirsOSErrorr   r   r'   )r   r+   usables      r0   get_cache_baser    s:    ~	w$>RZ77##O44 ##C(( 
w}}V 
627++ 	ONNEvNNN	KFF 	 	 	NN0&4NHHHFFF	  F!##<fEEE7<<'''s   ?C )DDc                     t           j                            t           j                            |                     \  }}|r|                    dd          }|                    t           j        d          }||z   dz   S )a  
    Convert an absolute path to a directory name for use in a cache.

    The algorithm used is:

    #. On Windows, any ``':'`` in the drive is replaced with ``'---'``.
    #. Any occurrence of ``os.sep`` is replaced with ``'--'``.
    #. ``'.cache'`` is appended.
    r   z---z--z.cache)ru   rv   
splitdriver  r$   rw   )rv   r   r   s      r0   path_to_cache_dirr    sj     7bgood3344DAq "IIc5!!			"&$Aq58r2   c                 :    |                      d          s| dz   S | S rs   )endswith)r/   s    r0   ensure_slashr  $  s"    ::c?? 3wHr2   c                     d x}}d| v r9|                      dd          \  }} d|vr|}n|                    dd          \  }}|rt          |          }|rt          |          }||| fS )NrM   r   r   )rsplitr   r   )rg   usernamepasswordr   s       r0   parse_credentialsr  *  s    Hx
f}}sA..fHH!'c1!5!5Hh %8$$ %8$$Xv%%r2   c                  V    t          j        d          } t          j        |            | S )N   )ru   umaskr   s    r0   get_process_umaskr  9  s$    Xd^^FHVMr2   c                 r    d}d }t          |           D ]\  }}t          |t                    sd} n|J |S )NTF)	enumerater   r   )seqr+   rl   r/   s       r0   is_string_sequencer  >  sV    FA#  1!\** 	FE	 ===Mr2   z3([a-z0-9_]+([.-][a-z_][a-z0-9_]*)*)-([a-z0-9_.+-]+)z-py(\d\.?\d?)c                 z   d}d}t          |                               dd          } t                              |           }|r1|                    d          }| d|                                         } |r{t          |           t          |          dz   k    rXt          j        t          j	        |          dz   |           }|r,|
                                }| d|         | |dz   d         |f}|Gt                              |           }|r+|                    d          |                    d          |f}|S )zw
    Extract name, version, python version from a filename (no extension)

    Return name, version, pyver or None
    NrW   -r   z\br   )r   r$   PYTHON_VERSIONr  r   startrx   rer    escaper"   PROJECT_NAME_AND_VERSION)filenameproject_namer+   pyverr*   ns         r0   split_filenamer  M  s+    FEx  ((c22Hh''A (

JQWWYYJ' ;HL(9(9A(===HRY|,,u4h?? 	;Abqb\8AEFF#3U:F~$**844 	3WWQZZU2FMr2   z-(?P<name>[\w .-]+)\s*\(\s*(?P<ver>[^\s)]+)\)$c                     t                               |           }|st          d| z            |                                }|d                                                                         |d         fS )z
    A utility method used to get name and version from a string.

    From e.g. a Provides-Dist value.

    :param p: A value in a form 'foo (1.0)'
    :return: The name and version as a tuple.
    z$Ill-formed name/version string: '%s'r]   ver)NAME_VERSION_REr    r   r  rb   r   )r   r*   r   s      r0   parse_name_and_versionr  i  sj     	a  A MG!KLLL	AV9??""$$ah..r2   c                    t                      }t          | pg           } t          |pg           }d| v r|                     d           ||z  }| D ]}|dk    r|                    |           |                    d          rE|dd          }||vrt                              d|z             ||v r|                    |           x||vrt                              d|z             |                    |           |S )N*r  r   zundeclared extra: %s)r   r   r  rc   r  r  )	requested	availabler+   runwanteds        r0   
get_extrasr  x  s   UUFIO$$IIO$$I
i)  88JJqMMMM\\# 		uHy((5@AAA6!!h'''	!!59:::JJqMMMMMr2   c                    i }	 t          |           }|                                }|                    d          }|                    d          st                              d|           n1 t          j        d          |          }t          j	        |          }n3# t          $ r&}t                              d| |           Y d }~nd }~ww xY w|S )NzContent-Typezapplication/jsonz(Unexpected response for JSON request: %sr   z&Failed to get external data for %s: %s)r   r  getrc   r  rR  r   r   r   r   r   	exception)r`   r+   respheadersctreaderes          r0   _get_external_datar    s    FK s||))++[[((}}/00 	'LLCRHHHH.V%g..t44F Yv&&F K K KA3JJJJJJJJKMs   BB 
C)C

Cz'https://www.red-dove.com/pypi/projects/c                     | d                                          d| d}t          t          |          }t          |          }|S )Nr   rt   z/project.jsonupperr   _external_data_base_urlr  )r]   r`   r+   s      r0   get_project_datar    sB    "&q'--////444
8C
)3
/
/C$$FMr2   c                     | d                                          d| d|d}t          t          |          }t          |          S )Nr   rt   z	/package-z.jsonr  )r]   versionr`   s      r0   get_package_datar    sD    %)!W]]____dddGGG
DC
)3
/
/Cc"""r2   c                   $    e Zd ZdZd Zd Zd ZdS )Cachez
    A class implementing a cache for resources that need to live in the file system
    e.g. shared libraries. This class was moved from resources to here because it
    could be used by other modules, e.g. the wheel module.
    c                 d   t           j                            |          st          j        |           t          j        |          j        dz  dk    rt                              d|           t           j                            t           j        	                    |                    | _
        dS )zu
        Initialise an instance.

        :param base: The base directory where the cache should be located.
        ?   r   zDirectory '%s' is not privateN)ru   rv   r'  r  r  r7  r  r  r  normpathr   )r   r   s     r0   r   zCache.__init__  s     w}}T"" 	KGDMM!D(Q..NN<dCCCGOOBG$4$4T$:$:;;			r2   c                      t          |          S )zN
        Converts a resource prefix to a directory name in the cache.
        )r  )r   r   s     r0   prefix_to_dirzCache.prefix_to_dir  s     !(((r2   c                    g }t          j        | j                  D ]}t           j                            | j        |          }	 t           j                            |          st           j                            |          rt          j        |           n3t           j                            |          rt          j
        |           # t          $ r |                    |           Y w xY w|S )z"
        Clear the cache.
        )ru   r`  r   rv   r'   r  r  r   r'  r	   r   r   r%   )r   not_removedfns      r0   clearzCache.clear  s     *TY'' 	' 	'Bdi,,B'7>>"%% &);); &IbMMMMW]]2&& &M"%%% ' ' '""2&&&&&'s   BCC-,C-N)r   r   r   __doc__r   r  r  rE   r2   r0   r  r    sK         < < <) ) )    r2   r  c                   2    e Zd ZdZd Zd	dZd Zd Zd ZdS )

EventMixinz1
    A very simple publish/subscribe system.
    c                     i | _         d S r   )_subscribersr	  s    r0   r   zEventMixin.__init__  s    r2   Tc                     | j         }||vrt          |g          ||<   dS ||         }|r|                    |           dS |                    |           dS )a`  
        Add a subscriber for an event.

        :param event: The name of an event.
        :param subscriber: The subscriber to be added (and called when the
                           event is published).
        :param append: Whether to append or prepend the subscriber to an
                       existing subscriber list for the event.
        N)r  r   r%   
appendleft)r   event
subscriberr%   subssqs         r0   r  zEventMixin.add  so      --DKKKeB *		*%%%%%j)))))r2   c                 v    | j         }||vrt          d|z            ||                             |           dS )z
        Remove a subscriber for an event.

        :param event: The name of an event.
        :param subscriber: The subscriber to be removed.
        zNo subscribers: %rN)r  r   r   )r   r  r  r  s       r0   r   zEventMixin.remove  sI      1E9:::U:&&&&&r2   c                 R    t          | j                            |d                    S )z
        Return an iterator for the subscribers for an event.
        :param event: The event to return subscribers for.
        rE   )iterr  r  )r   r  s     r0   get_subscriberszEventMixin.get_subscribers  s%    
 D%))%44555r2   c                    g }|                      |          D ]Q}	  ||g|R i |}n,# t          $ r t                              d           d}Y nw xY w|                    |           Rt                              d||||           |S )a^  
        Publish a event and return a list of values returned by its
        subscribers.

        :param event: The event to publish.
        :param args: The positional arguments to pass to the event's
                     subscribers.
        :param kwargs: The keyword arguments to pass to the event's
                       subscribers.
        z"Exception during event publicationNz/publish %s: args = %s, kwargs = %s, result = %s)r  r   r  r  r%   rR  )r   r  argskwargsr+   r  r   s          r0   publishzEventMixin.publish  s     ..u55 	! 	!J"
5:4:::6::     !EFFF MM%    FD&&	2 	2 	2s   (&AANrg  )	r   r   r   r  r   r  r   r  r  rE   r2   r0   r  r    sn           * * * *(
' 
' 
'6 6 6    r2   r  c                   f    e Zd Zd Zd ZddZd Zd Zd Zd Z	e
d	             Ze
d
             ZdS )	Sequencerc                 H    i | _         i | _        t                      | _        d S r   )_preds_succsr   _nodesr	  s    r0   r   zSequencer.__init__(  s    eer2   c                 :    | j                             |           d S r   )r  r  )r   nodes     r0   add_nodezSequencer.add_node-  s    r2   Fc                 0   || j         v r| j                             |           |rt          | j                            |d                    D ]}|                     ||           t          | j                            |d                    D ]}|                     ||           t          | j                                                  D ]\  }}|s| j        |= t          | j                                                  D ]\  }}|s| j        |= d S d S )NrE   )r  r   r   r  r  r  r^  r   )r   r  edgesr   r/   r   rT   s          r0   remove_nodezSequencer.remove_node0  s3   4;Kt$$$ 	'r2233 % %At$$$$r2233 % %D!$$$$T[..0011 ' '1 'AT[..0011 ' '1 'A	' 	'' 'r2   c                     ||k    sJ | j                             |t                                                    |           | j                            |t                                                    |           d S r   )r  
setdefaultr   r  r  )r   predsuccs      r0   r  zSequencer.add@  si    t||||tSUU++//555tSUU++//55555r2   c                 (   ||k    sJ 	 | j         |         }| j        |         }n # t          $ r t          d|z            w xY w	 |                    |           |                    |           d S # t          $ r t          |d|          w xY w)Nz%r not a successor of anythingz not a successor of )r  r  KeyErrorr   r   )r   r  r  predssuccss        r0   r   zSequencer.removeE  s    t||||	FK%EK%EE 	F 	F 	F=DEEE	F	HLLLL 	H 	H 	H444FGGG	Hs   % A*A2 2Bc                 8    || j         v p|| j        v p|| j        v S r   )r  r  r  )r   steps     r0   is_stepzSequencer.is_stepR  s.    # $tt{': $#	%r2   c                    |                      |          st          d|z            g }g }t                      }|                    |           |r|                    d          }||v r1||k    r*|                    |           |                    |           nZ|                    |           |                    |           | j                            |d          }|	                    |           |t          |          S )NzUnknown: %rr   rE   )r  r   r   r%   r{   r   r  r  r  extendreversed)r   finalr+   todoseenr  r  s          r0   	get_stepszSequencer.get_stepsV  s    ||E"" 	4]U2333uuE 	#88A;;Dt|| 5==MM$'''MM$'''d###b11E"""  	#  r2   c                 v    dgg i i g | j         fdD ]}|vr |           S )Nr   c                 <   d         | <   d         | <   dxx         dz  cc<   
                     |            	 |          }n# t          $ r g }Y nw xY w|D ]T}|vr+ |           t          |          |                   | <   1|
v rt          |          |                   | <   U|          |          k    rZg }	 
                                }|                     |           || k    rn1t	          |          }	                     |           d S d S Nr   r   )r%   r   minr{   tuple)r  
successors	successorconnected_component	componentgraphindexindex_counterlowlinksr+   stackstrongconnects        r0   r  z3Sequencer.strong_connections.<locals>.strongconnectz  sx   '*E$K*1-HTN!!LL "4[

      


 ' J J	H,,!M),,,%($8K%L%LHTNN%'' &)$i8H%I%IHTN ~t,,&(#0 %		I'..y999 D((%0 ""566	i((((( -,s   A AA)r  )	r   r  r  r  r  r  r+   r  r  s	     @@@@@@@r0   strong_connectionszSequencer.strong_connectionso  s      	)  	)  	)  	)  	)  	)  	)  	)  	)  	)  	)D  	$ 	$D8##d###r2   c           	         dg}| j         D ]0}| j         |         }|D ]}|                    d|d|d           1| j        D ]}|                    d|z             |                    d           d                    |          S )Nzdigraph G {z  z -> rV   z  %s;}
)r  r%   r  r'   )r   r+   r  r  r  r  s         r0   dotzSequencer.dot  s    K 	< 	<DK%E < <tttTTT:;;;;<K 	* 	*DMM'D.))))cyy   r2   Nrf  )r   r   r   r   r  r  r  r   r  r
  propertyr  r  rE   r2   r0   r  r  '  s          
  ' ' ' ' 6 6 6
H H H% % %     2 0 0 X0d 	! 	! X	! 	! 	!r2   r  ).tar.gz.tar.bz2.tar.zip.tgz.tbz.whlTc                   
 
fd}t           j                                      t                    
d }|x|                     d          rd}n`|                     d          rd}d}nF|                     d          rd}d	}n,|                     d
          rd}d}nt          d| z            	 |dk    r7t          | d          }|r$|                                }|D ]} ||           n;t          j	        | |          }|r$|
                                }|D ]} ||           |dk    rft          j        d         dk     rP|                                D ];}	t          |	j        t                     s|	j                            d          |	_        <|                               |r|                                 d S d S # |r|                                 w w xY w)Nc                 P   t          | t                    s|                     d          } t          j                            t          j                            |                     }|                              r|         t          j        k    rt          d|z            d S )Nr   zpath outside destination: %r)
r   r   decoderu   rv   r  r'   rc   rw   r   )rv   r   dest_dirplens     r0   
check_pathzunarchive.<locals>.check_path  s    $	** 	(;;w''DGOOBGLL48899||H%% 	A4BF):):;a?@@@ *;):r2   )r#  r&  zip)r   r$  tgzzr:gz)r!  r%  tbzzr:bz2r"  tarr  zUnknown format for %rr   r   r   )ru   rv   r  rx   r  r   r   namelisttarfiler(  getnamesr   r   
getmembersr   r]   r   r)  
extractallr   )archive_filenamer*  formatr  r,  archiver<  namesr]   tarinfor+  s    `        @r0   	unarchiver;    sW   A A A A A A wx((Hx==DG~$$%566 	IFF&&':;; 
	IFDD&&';<< 	IFDD&&v.. 	IFDD47GGHHHU??.44G %((**! % %DJt$$$$l#3T::G %((**! % %DJt$$$$U??s/2Q66
 #--// @ @!',	:: @#*<#6#6w#?#?GL8$$$  	MMOOOOO	 	7 	MMOOOO	s   4C9G G c                    t          j                    }t          |           }t          |d          5 }t	          j        |           D ]k\  }}}|D ]b}t          j                            ||          }||d         }	t          j                            |	|          }
|                    ||
           cl	 ddd           n# 1 swxY w Y   |S )z*zip a directory tree into a BytesIO objectr$  N)	ioBytesIOrx   r   ru   walkrv   r'   r   )	directoryr+   dlenzfry   rb  r;  r]   fullrelr   s              r0   zip_dirrE    s   Z\\Fy>>D			 %!#!3!3 	% 	%D$ % %w||D$//455kw||C..t$$$$	%	%% % % % % % % % % % % % % % % Ms   BCCC)r   KMGTPc                       e Zd ZdZddZd Zd Zd Zd Ze	d	             Z
e	d
             Zd Ze	d             Ze	d             ZdS )ProgressUNKNOWNr   d   c                 n    |||k    sJ |x| _         | _        || _        d | _        d| _        d| _        d S )Nr   F)r  curmaxstartedelapseddone)r   minvalmaxvals      r0   r   zProgress.__init__  sE    ~6!1!1!1!1$$48			r2   c                     | j         |k    sJ | j        || j        k    sJ || _        t          j                    }| j        	|| _        d S || j        z
  | _        d S r   )r  rQ  rP  timerR  rS  )r   curvalnows      r0   updatezProgress.update
  sf    x6!!!!x6TX#5#5#5#5ikk<DLLL-DLLLr2   c                 P    |dk    sJ |                      | j        |z              d S )Nr   )r[  rP  )r   incrs     r0   	incrementzProgress.increment  s-    qyyyyDHtO$$$$$r2   c                 :    |                      | j                   | S r   )r[  r  r	  s    r0   r  zProgress.start  s    DHr2   c                 V    | j         |                     | j                    d| _        d S NT)rQ  r[  rT  r	  s    r0   stopzProgress.stop  s)    8KK!!!			r2   c                 ,    | j         | j        n| j         S r   )rQ  unknownr	  s    r0   maximumzProgress.maximum!  s    #x/t||TX=r2   c                 |    | j         rd}n1| j        d}n'd| j        | j        z
  z  | j        | j        z
  z  }d|z  }|S )Nz100 %z ?? %g      Y@z%3d %%)rT  rQ  rP  r  )r   r+   rT   s      r0   
percentagezProgress.percentage%  sQ    9 	"FFXFFDH,-DH1DEA\Fr2   c                     |dk    r| j         | j        | j        k    rd}n't          j        dt          j        |                    }|S )Nr   z??:??:??z%H:%M:%S)rQ  rP  r  rX  strftimegmtime)r   durationr+   s      r0   format_durationzProgress.format_duration0  sI    MMtx/48tx3G3GFF ]:t{8/D/DEEFr2   c                 "   | j         r
d}| j        }ned}| j        d}nY| j        dk    s| j        | j        k    rd}n;t          | j        | j        z
            }|| j        | j        z
  z  }|dz
  | j        z  }|d|                     |          S )NDonezETA r   r   r   z: )rT  rS  rQ  rP  r  floatrl  )r   r   rm   s      r0   ETAzProgress.ETA9  s    9 	+FAA Fx""tx48';'; $(TX-..TX((Udl*!664#7#7#:#:#:;;r2   c                     | j         dk    rd}n| j        | j        z
  | j         z  }t          D ]}|dk     r n|dz  }d||fz  S )Nr   g        i  g     @@z%d %sB/s)rS  rP  r  UNITS)r   r+   units      r0   speedzProgress.speedL  sc    <1FFh)T\9F 	 	D}}fFFVTN**r2   N)r   rN  )r   r   r   rd  r   r[  r^  r  rb  r  re  rg  rl  rp  rt  rE   r2   r0   rL  rL    s        G   . . .% % %    
 > > X>   X   < < X<$ 	+ 	+ X	+ 	+ 	+r2   rL  z\{([^}]*)\}z[^/\\,{]\*\*|\*\*[^/\\,}]z^[^{]*\}|\{[^}]*$c                     t                               |           rd}t          || z            t                              |           rd}t          || z            t	          |           S )zAExtended globbing function that supports ** and {opt1,opt2,opt3}.z7invalid glob %r: recursive glob "**" must be used alonez2invalid glob %r: mismatching set marker '{' or '}')_CHECK_RECURSIVE_GLOBr  r   _CHECK_MISMATCH_SET_iglob)	path_globr   s     r0   r   r   a  sj    ##I.. *Ky)))!!),, *Fy))))r2   c              #     K   t                               | d          }t          |          dk    rit          |          dk    s
J |            |\  }}}|                    d          D ].}t          d                    |||f                    D ]}|V  /d S d| vrt          |           D ]}|V  d S |                     dd          \  }}|dk    rd}|dk    rd}n*|                    d          }|                    d	          }t          j        |          D ]Y\  }}}	t          j	        
                    |          }t          t          j	                            ||                    D ]}
|
V  Zd S )
Nr   r   rL   r   z**rj  r  rt   \)	RICH_GLOBr   rx   rx  r'   	std_iglobr(   ru   r?  rv   r  )ry  rich_path_globr   r   r   itemrv   radicaldirr;  r  s              r0   rx  rx  l  s     __Y22N
>Q>""a'''''',VIIcNN 	 	Drwwf'=>>??  



	 	 y  !),,  



  (oodA66OFG||"}} "..--!....$&GFOO   c5w''-- dG!<!<==  BHHHH r2   )HTTPSHandlermatch_hostnameCertificateErrorc                       e Zd ZdZdZd ZdS )HTTPSConnectionNTc                    t          j        | j        | j        f| j                  }t          | dd          r|| _        |                                  t          j	        t          j
                  }t          t          d          r|xj        t          j        z  c_        | j        r |                    | j        | j                   i }| j        rLt          j        |_        |                    | j                   t          t          dd          r
| j        |d<    |j        |fi || _        | j        r| j        r	 t/          | j                                        | j                   t2                              d| j                   d S # t6          $ r? | j                            t           j                   | j                                          w xY wd S d S )N_tunnel_hostFOP_NO_SSLv2)cafileHAS_SNIserver_hostnamezHost verified: %s)r   create_connectionhostporttimeoutr   sock_tunnelssl
SSLContextPROTOCOL_SSLv23r   optionsr  	cert_fileload_cert_chainkey_fileca_certsCERT_REQUIREDverify_modeload_verify_locationswrap_socketcheck_domainr  getpeercertr  rR  r  shutdown	SHUT_RDWRr   )r   r  contextr  s       r0   connectzHTTPSConnection.connect  s   +TY	,BDLQQDt^U33  	nS%899GsM** 33?2~ G''FFFF} :&)&7#--T]-CCC3	511 :04	F,-++D;;F;;DI} !2 "49#8#8#:#:DIFFFLL!4di@@@@@'   I&&v'7888IOO%%%	   s   >AF A	G)r   r   r   r  r  r  rE   r2   r0   r  r    s-        	 	 	 	 	r2   r  c                   "    e Zd ZddZd Zd ZdS )r  Tc                 J    t          j        |            || _        || _        d S r   )BaseHTTPSHandlerr   r  r  )r   r  r  s      r0   r   zHTTPSHandler.__init__  s(    %d+++$DM ,Dr2   c                 \    t          |i |}| j        r| j        |_        | j        |_        |S )a  
            This is called to create a connection instance. Normally you'd
            pass a connection class to do_open, but it doesn't actually check for
            a class, and just expects a callable. As long as we behave just as a
            constructor would have, we should be OK. If it ever changes so that
            we *must* pass a class, we'll create an UnsafeHTTPSConnection class
            which just sets check_domain to False in the class definition, and
            choose which one to pass to do_open.
            )r  r  r  )r   r  r  r+   s       r0   _conn_makerzHTTPSHandler._conn_maker  s9     %d5f55F} 8"&-&*&7#Mr2   c                     	 |                      | j        |          S # t          $ r3}dt          |j                  v rt          d|j        z             d }~ww xY w)Nzcertificate verify failedz*Unable to verify server certificate for %s)do_openr  r   strreasonr  r  )r   rh   r  s      r0   
https_openzHTTPSHandler.https_open  sy    ||D$4c:::   .#ah--??* ,469h,? @ @ @ s    
A.AANrg  )r   r   r   r   r  r  rE   r2   r0   r  r    sF        	- 	- 	- 	-
	 	 	 	 	 	 	 	r2   r  c                       e Zd Zd ZdS )HTTPSOnlyHandlerc                 &    t          d|z            )NzAUnexpected HTTP request on what should be a secure connection: %s)r   )r   rh   s     r0   	http_openzHTTPSOnlyHandler.http_open  s!     ,.12 3 3 3r2   N)r   r   r   r  rE   r2   r0   r  r    s#        	3 	3 	3 	3 	3r2   r  c                       e Zd ZddZd ZdS )	Transportr   c                 T    || _         t          j                            | |           d S r   )r  r   r  r   r   r  use_datetimes      r0   r   zTransport.__init__  s(    $$T<88888r2   c                     |                      |          \  }}}| j        r|| j        d         k    r"|| _        |t          j        |          f| _        | j        d         S r  )get_host_info_connection_extra_headersr   HTTPConnection)r   r  hehx509s        r0   make_connectionzTransport.make_connection  sf    ((..2t 	?44+;A+>#>#>"$D#W%;A%>%>>D""r2   Nr   r   r   r   r   r  rE   r2   r0   r  r    s7        9 9 9 9# # # # #r2   r  c                       e Zd ZddZd ZdS )SafeTransportr   c                 T    || _         t          j                            | |           d S r   )r  r   r  r   r  s      r0   r   zSafeTransport.__init__  s(    "DL#,,T<@@@@@r2   c                     |                      |          \  }}}|si }| j        |d<   | j        r|| j        d         k    r!|| _        |t	          j        |d fi |f| _        | j        d         S )Nr  r   r   )r  r  r  r  r   r  )r   r  r  r  r  s        r0   r  zSafeTransport.make_connection  s     ..t44MAr6  $F9# Ktt/?/B'B'B&(##')@D *K *KCI*K *K $K #A&&r2   Nr  r  rE   r2   r0   r  r    s;        	A 	A 	A 	A		' 		' 		' 		' 		'r2   r  c                       e Zd Zd ZdS )ServerProxyc                 &   |                     dd           x| _        }|Yt          |          d         }|                    dd          }|dk    rt          }nt
          } |||          x|d<   }|| _        t          j        j	        | |fi | d S )Nr  r   r  https)r  	transport)
r{   r  r   r  r  r  r  r   r  r   )r   rk   r  r  rf   r  tclsrm   s           r0   r   zServerProxy.__init__  s    !'It!<!<<w c]]1%F!::na88L  $ &*d7&N&N&NNF;!DN&tS;;F;;;;;r2   N)r   r   r   r   rE   r2   r0   r  r     s#        < < < < <r2   r  c                 j    t           j        d         dk     r|dz  }n
d|d<   d|d<   t          | |fi |S )Nr   r   br   newliner   r&  )r   r   r(  )r  r<  r  s      r0   	_csv_openr    sN    
Qy %zD##F###r2   c                   \    e Zd Z ed           ed           ed          dZd Zd ZdS )CSVBaserL   "r  )	delimiter	quotecharlineterminatorc                     | S r   rE   r	  s    r0   	__enter__zCSVBase.__enter__(      r2   c                 8    | j                                          d S r   )r   r   )r   r  s     r0   __exit__zCSVBase.__exit__+  s    r2   N)r   r   r   r  defaultsr  r  rE   r2   r0   r  r  !  s_        SXXSXX#d)) H      r2   r  c                   $    e Zd Zd Zd Zd ZeZdS )	CSVReaderc                    d|v rC|d         }t           j        d         dk    r t          j        d          |          }|| _        nt          |d         d          | _        t          j        | j        fi | j        | _        d S )Nr   r   r   r   rv   r  )	r   r   r   r   r   r  csvr  r  )r   r  r   s      r0   r   zCSVReader.__init__0  s    vH%F"a''2)'226:: DKK#F6NC88DKj>>>>r2   c                     | S r   rE   r	  s    r0   __iter__zCSVReader.__iter__;  r  r2   c                     t          | j                  }t          j        d         dk     rBt	          |          D ]2\  }}t          |t                    s|                    d          ||<   3|S Nr   r   r   )nextr  r   r   r  r   r   r)  )r   r+   rl   r  s       r0   r  zCSVReader.next>  sl    dk""A""$V,, 5 54!$	22 5 $G 4 4F1Ir2   N)r   r   r   r   r  r  __next__rE   r2   r0   r  r  /  sB        	? 	? 	?     HHHr2   r  c                       e Zd Zd Zd ZdS )	CSVWriterc                 r    t          |d          | _        t          j        | j        fi | j        | _        d S )Nr$  )r  r   r  writerr  )r   r  r  s      r0   r   zCSVWriter.__init__I  s4    C((j>>>>r2   c                     t           j        d         dk     rHg }|D ]A}t          |t                    r|                    d          }|                    |           B|}| j                            |           d S r  )r   r   r   r   r1  r%   r  writerow)r   rowr  r  s       r0   r  zCSVWriter.writerowM  s~    A""A  dI.. 0;;w//DCS!!!!!r2   N)r   r   r   r   r  rE   r2   r0   r  r  H  s2        ? ? ?" " " " "r2   r  c                   \     e Zd Z eej                  Zded<   d fd	Zd Zd Zd Z	 xZ
S )	Configuratorinc_convertincNc                     t          t          |                               |           |pt          j                    | _        d S r   )superr  r   ru   r   r   )r   configr   	__class__s      r0   r   zConfigurator.__init__`  s7    lD!!**6222'BIKK			r2   c                    
 
 fd
                     d          }t          |          s                     |          }                     dd           }                     dd          }|rt          
fd|D                       }
fdD             }t	          |          } ||i |}|r4|                                D ]\  }}	t          || 
|	                      |S )Nc                 J   t          | t          t          f          r% t          |           fd| D                       }n`t          | t                    r6d| v r                    |           }n1i }| D ]} | |                   ||<   n                    |           }|S )Nc                 &    g | ]} |          S rE   rE   )rZ   rl   converts     r0   r\   zBConfigurator.configure_custom.<locals>.convert.<locals>.<listcomp>g  s!    !8!8!8''!**!8!8!8r2   ())r   r^  r  typedictconfigure_customr  )or+   r   r  r   s      r0   r  z.Configurator.configure_custom.<locals>.converte  s    !dE]++ 
) a!8!8!8!8a!8!8!899At$$ )199!22155FFF 2 2$+GAaDMMq		2 aMr2   r  rj  z[]rE   c                 &    g | ]} |          S rE   rE   )rZ   r  r  s     r0   r\   z1Configurator.configure_custom.<locals>.<listcomp>z  s!    333''!**333r2   c                 T    g | ]$}t          |          | |                   f%S rE   )r   )rZ   r   r  r  s     r0   r\   z1Configurator.configure_custom.<locals>.<listcomp>{  s7    KKKQKNNK!WWVAY''(KKKr2   )r{   r~  rp  r  r  r   setattr)r   r  r   propsr  r   r  r+   r  rT   r  s   ``        @r0   r  zConfigurator.configure_customd  s#   	 	 	 	 	 	 JJt{{ 	 QA

3%%zz$## 	53333d33344DKKKKK&KKKeD#F## 	/ / /1771::....r2   c                     | j         |         }t          |t                    r#d|v r|                     |          x| j         |<   }|S )Nr  )r  r   r  r  )r   r   r+   s      r0   __getitem__zConfigurator.__getitem__  sM    S!fd## 	F(,(=(=f(E(EEDKvr2   c                    t           j                            |          s%t           j                            | j        |          }t          j        |dd          5 }t          j        |          }ddd           n# 1 swxY w Y   |S )z*Default converter for the inc:// protocol.r  r   r%  N)	ru   rv   isabsr'   r   r   r(  r   r   )r   r   r.  r+   s       r0   r  zConfigurator.inc_convert  s    w}}U## 	3GLLE22E[g666 	"!Yq\\F	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s   A==BBr   )r   r   r   r  r   value_convertersr   r  r  r  __classcell__)r  s   @r0   r  r  [  s        t,=>>+U( ( ( ( ( (  >        r2   r  c                   &    e Zd ZdZddZd Zd ZdS )SubprocessMixinzC
    Mixin for running subprocesses and capturing their output
    FNc                 "    || _         || _        d S r   )verboseprogress)r   r  r  s      r0   r   zSubprocessMixin.__init__  s     r2   c                 ~   | j         }| j        }	 |                                }|sn| |||           nr|s t          j                            d           n2t          j                            |                    d                     t          j                                         |                                 dS )z
        Read lines from a subprocess' output stream and either pass to a progress
        callable (if specified) or write progress information to sys.stderr.
        TNrj  r   )	r  r  readliner   stderrr   r)  flushr   )r   r   r  r  r  r/   s         r0   r  zSubprocessMixin.reader  s    
 =,	#!!A #G$$$$ 8J$$S))))J$$QXXg%6%6777
  """	# 	r2   c                 0   t          j        |ft           j        t           j        d|}t          j        | j        |j        df          }|                                 t          j        | j        |j        df          }|                                 |	                                 |
                                 |
                                 | j        |                     dd           n&| j        rt          j                            d           |S )N)stdoutr  r  )r  r  r  zdone.mainzdone.
)
subprocessPopenPIPE	threadingThreadr  r  r  r  waitr'   r  r  r   r   )r   cmdr  r   t1t2s         r0   run_commandzSubprocessMixin.run_command  s    S ?$.O? ?7=? ?T[(7KLLL



T[(7KLLL



	
			
			=$MM'6****\ 	(JY'''r2   )FN)r   r   r   r  r   r  r  rE   r2   r0   r
  r
    sP         ! ! ! !  *    r2   r
  c                 R    t          j        dd|                                           S )z,Normalize a python package name a la PEP 503z[-_.]+r  )r  subr   )r]   s    r0   normalize_namer!    s$     6(C&&,,...r2   c                   *    e Zd ZdZdZddZd Zd ZdS )
PyPIRCFilezhttps://upload.pypi.org/legacy/pypiNc                     |=t           j                            t           j                            d          d          }|| _        || _        d S )Nr  z.pypirc)ru   rv   r'   r  r  r`   )r   r  r`   s      r0   r   zPyPIRCFile.__init__  s>    :bg0055yAABr2   c                    i }t           j                            | j                  r| j        p| j        }t          j                    }|                    | j                   |	                                }d|v r|
                    dd          }d |                    d          D             }|g k    r	d|v rdg}n|D ]}d|i}|
                    |d          |d<   d| j        fd	| j        fd
fD ]:\  }}	|                    ||          r|
                    ||          ||<   5|	||<   ;|dk    r|| j        dfv r| j        |d<   |d         |k    r|d         |k    ri }nod|v rkd}|                    |d          r|
                    |d          }n| j        }|
                    |d          |
                    |d          ||| j        d}|S )N	distutilszindex-serversc                 f    g | ].}|                                 d k    |                                 /S )r   r  )rZ   servers     r0   r\   z#PyPIRCFile.read.<locals>.<listcomp>  s<     5 5 5v%||~~33 #LLNN333r2   r  r$  r)  r  
repositoryrealm)r  Nzserver-loginr  )r  r  r*  r)  r+  )ru   rv   r  r  r`   DEFAULT_REPOSITORYr   RawConfigParserr   r   r  r   DEFAULT_REALM
has_option)
r   r+   r*  r  r   index_servers_serversr)  r   r   s
             r0   r   zPyPIRCFile.read  sJ   7>>$-(( 4	<T%<J!133FKK&&&((Hh&& &

; H H5 5)//555 5 5 r>>))$*8"* ( ("*F!3-3ZZ
-K-Kz* /;D<S-T.5t7I-J-?-A 6 6LC  &00== 6.4jj.E.Es.5s
 #f,,&4+BF*KKK373JF<00$X.*<<$\2j@@%'F+(,  8++'$$V\:: 9!'FL!A!AJJ!%!8J &

6: > > &

6: > >",$!/  r2   c                    t          j                    }| j        }|                    |           |                    d          s|                    d           |                    dd|           |                    dd|           t          |d          5 }|                    |           d d d            d S # 1 swxY w Y   d S )Nr$  r  r  r$  )	r   r-  r  r   has_sectionr   r   r(  r   )r   r  r  r  r  r.  s         r0   r[  zPyPIRCFile.update  s    -//]B!!&)) 	'v&&&

6:x000

6:x000"c]] 	aLLOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   B;;B?B?NN)r   r   r   r,  r.  r   r   r[  rE   r2   r0   r#  r#    sR        :M   8 8 8t
 
 
 
 
r2   r#  c                 P    t          | j                                                  S )zG
    Read the PyPI access configuration as supported by distutils.
    )r`   )r#  r`   r   r  s    r0   _load_pypircr7     s#     %)$$$))+++r2   c                 ^    t                                          | j        | j                   d S r   )r#  r[  r  r  r6  s    r0   _store_pypircr9  &  s&    LL77777r2   c                     t           j        dk    rrdt          j                                        v rdS dt          j                                        v rdS dt          j                                        v rdS t          j        S dt           j        v rt           j        d         S t           j        d	k    st          t           d
          st          j        S t          j                    \  } }}}}|                                 	                    dd          } |	                    dd          	                    dd          }| dd         dk    r| d|S | dd         dk    rQ|d         dk    rDd} dt          |d                   dz
  |dd         fz  }ddd}|d|t          j                 z  z  }n| dd         dk    rddlm}  |            S | dd          d!k    rMd!} t          j        d"t          j                  }|                    |          }|r|                                }nI| dd          d#k    r;ddl}	ddl}
|	                    |
j                                        | ||          \  } }}| d|d|S )$a  Return a string that identifies the current platform.  This is used mainly to
    distinguish platform-specific build directories and platform-specific built
    distributions.  Typically includes the OS name and version and the
    architecture (as supplied by 'os.uname()'), although the exact information
    included depends on the OS; eg. on Linux, the kernel version isn't
    particularly important.

    Examples of returned values:
       linux-i586
       linux-alpha (?)
       solaris-2.6-sun4u

    Windows will return one of:
       win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc)
       win32 (all others - specifically, sys.platform is returned)

    For other non-POSIX platforms, currently just returns 'sys.platform'.

    r  amd64	win-amd64z(arm)	win-arm32z(arm64)z	win-arm64_PYTHON_HOST_PLATFORMr4  unamert   r   rW   rn   r  N   linuxsunosr   5solarisz%d.%sr      32bit64bit)il    z.%saix)aix_platform   cygwinz[\d.]+darwin)ru   r]   r   r  r   platformr  r   r?  r$   intmaxsize_aix_supportrI  r  rG  ASCIIr    r   _osx_supportdistutils.sysconfigget_platform_osx	sysconfigget_config_vars)osnamer  releaser  machinebitnessrI  rel_rer*   rR  r'  s              r0   get_host_platformr\  .  s   ( 
w$ck''))));ck''))));))++++;| "*,,z122	w'W!5!5 | 13

-VT7GW \\^^##C,,Fooc3''//S99GbqbzW "6677++	w		1:FWQZ1!4gabbk BBG #*wGGGuws{333G	u		------|~~	x		Y11LL!! 	 ggiiG	x		00000000#/#@#@(1(;(K(K(M(M(.$B $B   ''22r2   win32r<  r=  )x86x64armc                      t           j        dk    rt                      S t           j                            d          } | t
          vrt                      S t
          |          S )Nr  VSCMD_ARG_TGT_ARCH)ru   r]   r\  r  r  _TARGET_TO_PLAT)cross_compilation_targets    r0   get_platformre    sQ    	w$ """!z~~.BCC66 """344r2   r4  )r   r   ra  )r   collectionsr   
contextlibr  globr   r}  r=  r   loggingru   rE  r  r   r  ImportErrorr  r   r2  r   r   r  dummy_threadingrX  r   r   compatr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   	getLoggerr   r  rG  r   rQ   rP   r;   rD   r@   re   r&   rG   rp   r   r   r   r   r   r   r   contextmanagerr   r   r   r   r   r   r   rp  rr  VERBOSEr  r   r  r  r  r  r  r  Ir  r  r  r  r  r  r  r  r  r  r  r  r  ARCHIVE_EXTENSIONSr;  rE  rr  rL  r|  rv  rw  rx  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r!  r#  r7  r9  r\  rc  re  rE   r2   r0   <module>rr     s	  
            



 # # # # # # 				   				     				 JJJJ   
CCC     



   ( ( ( (''''''(       ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( 
	8	$	$ RZ)**
RZ 344 RZ566
BJDEE	RZbjBJ{##	rzEFFV! V! V!rz@ z@ z@z  4    $      , , ,^  &       & & & &    f        6u u u u u6 u u un      &   8 2:  :' '
  >&( &( &( &(R  "  & & &  
   &2: '89;? ? ,--   2 "* 9 : :/ / /  2  ( D   # # #) ) ) ) )F ) ) )XC C C C C C C CPE! E! E! E! E! E! E! E!V. 3 3 3 3l  " 	$W+ W+ W+ W+ W+v W+ W+ W+z BJ~&&	"
#?@@  bj!566     6  V3+ + + + + + + + + +    '1   B    '   R3 3 3 3 3< 3 3 3
# 
# 
# 
# 
#	# 
# 
# 
#  '' ' ' ' '	/ ' ' '"< < < < <)' < < <,$ $ $    f          2" " " " " " " "&4 4 4 4 4# 4 4 4n+ + + + +f + + +\/ / /O O O O O O O Ob, , ,8 8 8N3 N3 N3d  5 5 5 5 5s!   ; AAA" "	A.-A.