
    .Phz                       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/  e
j0        e1          Z2 ej3        d          Z4 ej3        d          Z5 ej3        d	          Z6 ej3        d
          Z7 ej3        d          Z8 ej3        d          Z9 ej3        d          Z: ej3        d          Z;d Z<d Z=d Z>d Z?d Z@dkdZAd ZBd ZCd ZDejE        d             ZFejE        d             ZGejE        dld            ZH G d deI          ZJd ZK G d d eI          ZLd! ZM G d" d#eI          ZN ej3        d$ejO                  ZPd% ZQdmd&ZRdnd(ZSd) ZTd* ZUd+ ZVd, ZW ej3        d-ejX                  ZY ej3        d.          ZZdmd/Z[ ej3        d0          Z\d1 Z]d2 Z^d3 Z_d4Z`d5 Zad6 Zb G d7 d8eI          Zc G d9 d:eI          Zd G d; d<eI          Zed=Zfdod>Zgd? Zhd@Zi G dA dBeI          Zj ej3        dC          Zk ej3        dD          Zl ej3        dE          ZmdF ZdG Zner:ddHlmoZpmqZqmrZr  G dI dJe$js                  Zs G dK dLep          Zo G dM dNeoe&          Zt G dO dPe%ju                  Zuer G dQ dRe%jv                  Zv G dS dTe%jw                  ZwdU Zx G dV dWeI          Zy G dX dYey          Zz G dZ d[ey          Z{ G d\ d]e'          Z| G d^ d_eI          Z}d` Z~ G da dbeI          Zdc Zdd Zde ZdfdgdhdiZdj ZdS )p    N)deque)iglob   )DistlibException)string_types	text_typeshutil	raw_inputStringIOcache_from_sourceurlopenurljoinhttplib	xmlrpclib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          L/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/distlib/util.py
marker_varz parse_marker.<locals>.marker_var@   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*   r8   r)   r7   r9   markerr0   s         r/   marker_exprz!parse_marker.<locals>.marker_exprd   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  r1   c                      |           \  }} | rOt                               |           }|sn2| |                                d          }  |           \  }} d||d}| O|| fS )Nandr6   )ANDr   r!   )r(   r8   r)   r9   r<   s       r/   
marker_andz parse_marker.<locals>.marker_andw   s    $Y//Y 	8		)$$A !!%%''((+I([33NCs377C  	8 I~r1   c                      |           \  }} | rOt                               |           }|sn2| |                                d          }  |           \  }} d||d}| O|| fS )Norr6   )ORr   r!   )r(   r8   r)   r9   r@   s       r/   r;   zparse_marker.<locals>.marker   s    #I..Y 	7##A !!%%''((+I'Z	22NCc#66C  	7 I~r1    )marker_stringr;   r@   r<   r0   s    @@@@r/   parse_markerrF   6   sx    "! "! "!H! ! ! ! ! !&	 	 	 	 		 	 	 	 	 6-   r1   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: %srK   r   invalid constraint: %s)
COMPARE_OPr   r    r!   VERSION_IDENTIFIERr"   r$   r'   )ver_remainingr)   versionsr7   vs        r/   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& $ (#'..r1   r3   r4   r5   rN   z~=;zinvalid requirement: %szunexpected trailing data: %s , c                     g | ]}d |z  S )z%s %srD   ).0cons     r/   
<listcomp>z%parse_requirement.<locals>.<listcomp>  s    ,O,O,OsWs],O,O,Or1   )nameextrasconstraintsr;   urlrequirement)strip
startswithr   r   r"   r    r!   findr'   r$   	NON_SPACEr   schemenetlocrO   rP   rF   r&   r   )reqr(   r)   distnamer]   	mark_exprrR   uriir.   trT   _rS   rss                  r/   parse_requirementro      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(6xPY_bprssssr1   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seprb   lenr'   )rootru   s     r/   get_rel_pathz)get_resources_dests.<locals>.get_rel_path  sk    ||BGK--||BGK--t$$$$$CIIJJ&&s+++r1   Nrs   )rt   ru   r&   r   popr#   rv   rstrip)resources_rootrulesry   destinationsbasesuffixdestprefixabs_baseabs_globabs_pathresource_filerel_pathrel_dests                 r/   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 r1   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    r/   in_venvr   &  s=    sM"" G wsM3:FFFMr1   c                  f    t           j        } t          | t                    st	          |           } | S N)r   
executable
isinstancer   r   r   s    r/   get_executabler   0  s/     ^Ffi(( "&!!Mr1   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          r/   proceedr   B  s|    A
=aLL 	W 	A 	=!

AM!! = A|V#<<
= Hr1   c                     t          |t                    r|                                }i }|D ]}|| v r| |         ||<   |S r   )r   r   split)dkeysr*   keys       r/   extract_by_keyr   R  sQ    $%% zz||F ! !!88C&F3KMr1   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     r/   read_streamz!read_exports.<locals>.read_streamp  sD    2{## 	LL     IIfr1   )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krS   r.   entryr   r   r   r\   values                  r/   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 [rW   rJ   )r   r   r   	getwriterr   r   r   add_sectionvaluesr   r   flagsr&   setr\   write)r   r   r   r   rS   r   r.   s          r/   write_exportsr     s   
a*!'**622		"	$	$B 
% 
%1
qXXZZ 	% 	%E|#L$|||U\\:{ <!"DIIek$:$:$:$:;FF1ej!$$$$	% HHVr1   c               #      K   t          j                    } 	 | V  t          j        |            d S # t          j        |            w xY wr   )tempfilemkdtempr	   rmtree)tds    r/   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   )rt   getcwdchdir)r   cwds     r/   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     r/   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     r/   __init__zcached_property.__init__  s    			r1   Nc                     || S |                      |          }t                              || j         j        |           |S r   )r   object__setattr____name__)r   objclsr   s       r/   __get__zcached_property.__get__  s=    ;K		#3	 2E:::r1   r   )r   
__module____qualname__r   r   rD   r1   r/   r   r     s7          
     r1   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.
    rs   r   zpath '%s' cannot be absolutezpath '%s' cannot end with '/')rt   rv   
ValueErrorr   curdirremoveru   r&   )pathnamepathss     r/   convert_pathr     s     
v}} {c7(BCCC|s88CDDDNN3E
)u

RY )u

 y7<r1   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     r/   r   zFileOperator.__init__  s,    uur1   c                 `    d| _         t                      | _        t                      | _        d S NF)recordr   files_writtendirs_createdr   s    r/   r  zFileOperator._init_record  s'     UUEEr1   c                 L    | j         r| j                            |           d S d S r   )r  r  add)r   ru   s     r/   record_as_writtenzFileOperator.record_as_written  s3    ; 	)""4(((((	) 	)r1   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)rt   ru   existsr   abspathstatst_mtime)r   sourcetargets      r/   newerzFileOperator.newer  sz     w~~f%% 	Y"#=PV@W@W#WXXXw~~f%% 	4wv'"'&//*BBBr1   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_dirrt   ru   dirnameloggerinfor   islinkr  isfiler   r	   copyfiler  )r   infileoutfilecheckmsgs        r/   	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'''''r1   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)rt   ru   isdirr  r  r  r  r   openr   r	   copyfileobjr   r  )r   instreamr  r%  	outstreams        r/   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  rt   ru   r  r   r  r   r'  r   r  )r   ru   r   fs       r/   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   ru   r   r%  s       r/   write_text_filezFileOperator.write_text_file2  s*    tT[[%:%:;;;;;r1   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)	rt   r\   _namer   r  r  r  st_modechmod)r   bitsmaskfilesr-  modes         r/   set_modezFileOperator.set_mode5  s    7g"'V"3"3G8K8K  & &< &KK 5q9999GAJJ.5=DKK ;QEEEHQ%%%% #4"38K8K& &r1   c                 0    |                      dd|          S )Nim  i  )r<  )r.   r-  s     r/   <lambda>zFileOperator.<lambda>A  s    qzz%'C'C r1   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)rt   ru   r  r  r  r
  r   r  r  r  r   mkdirr  r  )r   ru   r   r-  s       r/   r  zFileOperator.ensure_dirC  s    wt$$t|##BGNN4,@,@#LT"""7==&&DAqOOAKK,---< { ,!%%d+++++ $###, ,r1   c                    t          ||           }t                              d||           | j        s|s|                     ||          r3|sd }n.|                    |          sJ |t          |          d          }i }|rEt          t          d          r0t          |t          j
                  st          j
        j        }||d<   t          j        |||dfi | |                     |           |S )NzByte-compiling %s to %sPycInvalidationModeinvalidation_modeT)r   r  r  r   r  rb   rw   r   
py_compiler   rB  CHECKED_HASHcompiler  )	r   ru   optimizeforcer   hashed_invalidationdpathdiagpathcompile_kwargss	            r/   byte_compilezFileOperator.byte_compileO  s   !$H55-tU;;;| 	N 2

4// 2 2#HH??622222#CKKLL1HN" Jwz;P'Q'Q J!"5z7UVV V*4*H*U'6I23tUHdMMnMMMu%%%r1   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)rt   ru   r  r&  r  r  debugr   r	   r   r  r  r   r  )r   ru   r.   s      r/   ensure_removedzFileOperator.ensure_removedb  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1r1   c                     d}|sit           j                            |          r t          j        |t           j                  }n*t           j                            |          }||k    rn|}|i|S r  )rt   ru   r  accessW_OKr  )r   ru   r*   parents       r/   is_writablezFileOperator.is_writablew  sp     	w~~d## 411W__T**F~~D  	 r1   c                 \    | j         sJ | j        | j        f}|                                  |S )zV
        Commit recorded changes, turn off recording, return
        changes.
        )r  r  r  r  )r   r*   s     r/   commitzFileOperator.commit  s9    
 {#T%66r1   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  rt   ru   r  r   sortedr  listdirr&   rmdirr  )r   r-  dirsr   flistsds         r/   rollbackzFileOperator.rollback  s    | 	$,-- ! !7>>!$$ !IaLLL $+T:::D  
1 ! ]O3333aq22BHRLLLr1   FTr   )FFNF)r   r   r   r   r  r  r  r   r+  r.  r1  r<  set_executable_moder  rM  rR  rW  rY  rd  rD   r1   r/   r   r     s          
" " "
) ) )C C C&( ( ( ("( ( ( (% % %< < <
& 
& 
& DC
, 
, 
,   &8 8 8*
 
 
      r1   r   c                 
   | t           j        v rt           j        |          }nt          |           }||}nM|                    d          }t	          ||                    d                    }|D ]}t	          ||          }|S )N.r   )r   modules
__import__r   r   rz   )module_namedotted_pathmodr*   r-   r   s         r/   resolvero    s    ck!!k+&%%!!#&&eiill++ 	( 	(AVQ''FFMr1   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        r/   r   zExportEntry.__init__  s"    	


r1   c                 6    t          | j        | j                  S r   )ro  r   r   r  s    r/   r   zExportEntry.value  s    t{DK000r1   c           	      H    d| j         d| j        d| j        d| j        d	S )Nz<ExportEntry r   r   rV   >rs  r  s    r/   __repr__zExportEntry.__repr__  s/     04			4;;;UYU_U_U_``r1   c                     t          |t                    sd}n@| j        |j        k    o/| j        |j        k    o| j        |j        k    o| j        |j        k    }|S r  )r   rq  r\   r   r   r   )r   otherr*   s      r/   __eq__zExportEntry.__eq__  sf    %-- 	1FFi5:- 0$+2M 0RVR]afamRm 0jEK/ r1   N)
r   r   r   r   r   r   rw  rz  r   __hash__rD   r1   r/   rq  rq    sb           1 1 _1a a a   HHHr1   rq  z(?P<name>([^\[]\S*))
                      \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 )NrI   rJ   zInvalid specification '%s'r\   callabler   r   r   r   c                 6    g | ]}|                                 S rD   ra   )rY   r-  s     r/   r[   z$get_export_entry.<locals>.<listcomp>  s     9991QWWYY999r1   rK   )ENTRY_REsearchr   	groupdictcountr   rq  )
specificationr)   r*   r   r\   ru   colonsr   r   r   s
             r/   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Mr1   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)rt   r\   environru   
expandvars
expanduserr&  rT  rU  r  warningmakedirsOSErrorr   r   r&   )r   r*   usables      r/   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Tc                    t           j                            |rt           j                            |           n|           \  }}|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)rt   ru   
splitdriver  r#   rv   )ru   use_abspathr   r   s       r/   path_to_cache_dirr    st     7{Lbgood333MMDAq "IIc5!!			"&$Aq58r1   c                 :    |                      d          s| dz   S | S rr   )endswith)r.   s    r/   ensure_slashr  )  s"    ::c?? 3wHr1   c                     d x}}d| v r9|                      dd          \  }} d|vr|}n|                    dd          \  }}|rt          |          }|rt          |          }||| fS )NrL   r   r   )rsplitr   r   )rf   usernamepasswordr   s       r/   parse_credentialsr  /  s    Hx
f}}sA..fHH!'c1!5!5Hh %8$$ %8$$Xv%%r1   c                  V    t          j        d          } t          j        |            | S )N   )rt   umaskr   s    r/   get_process_umaskr  >  s$    Xd^^FHVMr1   c                 r    d}d }t          |           D ]\  }}t          |t                    sd} n|J |S )NTF)	enumerater   r   )seqr*   rk   r.   s       r/   is_string_sequencer  D  sV    FA#  1!\** 	FE	 ===Mr1   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
    NrV   -r   z\br   )r   r#   PYTHON_VERSIONr  r   startrw   rer   escaper!   PROJECT_NAME_AND_VERSION)filenameproject_namer*   pyverr)   ns         r/   split_filenamer  T  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Mr1   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  ra   r   )r   r)   r   s      r/   parse_name_and_versionr  r  sj     	a  A MG!KLLL	AV9??""$$ah..r1   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
  rb   r  r  )	requested	availabler*   runwanteds        r/   
get_extrasr    s   UUFIO$$IIO$$I
i)  88JJqMMMM\\# 		uHy((5@AAA6!!h'''	!!59:::JJqMMMMMr1   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  getrb   r  rQ  r   r   r   r   r   	exception)r_   r*   respheadersctreaderes          r/   _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   rs   z/project.jsonupperr   _external_data_base_urlr  )r\   r_   r*   s      r/   get_project_datar    sB    "&q'--////444
8C
)3
/
/C$$FMr1   c                     | d                                          d| d|d}t          t          |          }t          |          S )Nr   rs   z	/package-z.jsonr  )r\   versionr_   s      r/   get_package_datar    sD    %)!W]]____dddGGG
DC
)3
/
/Cc"""r1   c                   &    e Zd ZdZd Zd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)rt   ru   r&  r  r  r6  r  r  r  normpathr   )r   r   s     r/   r   zCache.__init__  s     w}}T"" 	KGDMM!D(Q..NN<dCCCGOOBG$4$4T$:$:;;			r1   Tc                 $    t          ||          S )zN
        Converts a resource prefix to a directory name in the cache.
        )r  )r  )r   r   r  s      r/   prefix_to_dirzCache.prefix_to_dir  s     ![AAAAr1   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.
        )rt   r_  r   ru   r&   r  r  r   r&  r	   r   r   r$   )r   not_removedfns      r/   clearzCache.clear  s     *TY'' 	' 	'Bdi,,B'7>>"%% &);); &IbMMMMW]]2&& &M"%%% ' ' '""2&&&&&'s   BCC-,C-Nrf  )r   r   r   __doc__r   r  r  rD   r1   r/   r  r    sT         < < <B B B B    r1   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    r/   r   zEventMixin.__init__  s    r1   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         r/   r
  zEventMixin.add  so      --DKKKeB *		*%%%%%j)))))r1   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       r/   r   zEventMixin.remove  sI      1E9:::U:&&&&&r1   c                 R    t          | j                            |d                    S )z
        Return an iterator for the subscribers for an event.
        :param event: The event to return subscribers for.
        rD   )iterr  r  )r   r  s     r/   get_subscriberszEventMixin.get_subscribers  s%    
 D%))%44555r1   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$   rQ  )r   r  argskwargsr*   r  r   s          r/   publishzEventMixin.publish  s     ..u55 	! 	!J"
5:4:::6::     !EFFF MM%    FtU[]cddds   (&AANrf  )	r   r   r   r  r   r
  r   r  r  rD   r1   r/   r  r    sn           * * * *(
' 
' 
'6 6 6    r1   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    r/   r   zSequencer.__init__:  s    eer1   c                 :    | j                             |           d S r   )r  r
  )r   nodes     r/   add_nodezSequencer.add_node?  s    r1   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 )NrD   )r  r   r   r  r  r  r]  r   )r   r  edgesr   r.   r   rS   s          r/   remove_nodezSequencer.remove_nodeB  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	' 	'' 'r1   c                     ||k    sJ | j                             |t                                                    |           | j                            |t                                                    |           d S r   )r  
setdefaultr   r
  r  )r   predsuccs      r/   r
  zSequencer.addR  si    t||||tSUU++//555tSUU++//55555r1   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        r/   r   zSequencer.removeW  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     r/   is_stepzSequencer.is_stepd  s'    #Qtt{':Qddk>QRr1   c                    |                      |          st          d|z            g }g }t                      }|                    |           |r|                    d          }||v r1||k    r*|                    |           |                    |           nZ|                    |           |                    |           | j                            |d          }|	                    |           |t          |          S )NzUnknown: %rr   rD   )r  r   r   r$   rz   r   r
  r  r  extendreversed)r   finalr*   todoseenr  r  s          r/   	get_stepszSequencer.get_stepsg  s    ||E"" 	4]U2333uuE 	#88A;;Dt|| 5==MM$'''MM$'''d###b11E"""  	#  r1   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   minrz   tuple)r  
successors	successorconnected_component	componentgraphindexindex_counterlowlinksr*   stackstrongconnects        r/   r  z3Sequencer.strong_connections.<locals>.strongconnect  sy   '*E$K*1-HTN!!LL "4[

      


 ' K K	H,,!M),,,%($)9L%M%MHTNN%'' &)$y9I%J%JHTN ~t,,&(# %		I'..y999 D((	
 ""566	i((((( -,s   A AA)r  )	r   r  r  r  r  r  r*   r  r  s	     @@@@@@@r/   strong_connectionszSequencer.strong_connections  s     !	) !	) !	) !	) !	) !	) !	) !	) !	) !	) !	)F  	$ 	$D8##d###r1   c           	         dg}| j         D ]0}| j         |         }|D ]}|                    d|d|d           1| j        D ]}|                    d|z             |                    d           d                    |          S )Nzdigraph G {z  z -> rU   z  %s;}
)r  r$   r  r&   )r   r*   r  r  r  r  s         r/   dotzSequencer.dot  s    K 	< 	<DK%E < <tttTTT:;;;;<K 	* 	*DMM'D.))))cyy   r1   Nre  )r   r   r   r   r  r  r
  r   r  r
  propertyr  r  rD   r1   r/   r  r  8  s          
  ' ' ' ' 6 6 6
H H HS S S     2 1 1 X1f 	! 	! X	! 	! 	!r1   r  ).tar.gz.tar.bz2.tar.zip.tgz.tbz.whlc                    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          |	_        <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   decodert   ru   r  r&   rb   rv   r   )ru   r   dest_dirplens     r/   
check_pathzunarchive.<locals>.check_path  s    $	** 	(;;w''DGOOBGLL48899||H%% 	A4BF):):;a?@@@ *;):r1   )r#  r&  zip)r   r$  tgzzr:gz)r!  r%  tbzzr:bz2r"  tarr  zUnknown format for %rr   r   r   c                     	 t          j        | |          S # t           j        $ r!}t          t	          |                    d}~ww xY w)z9Run tarfile.tar_filter, but raise the expected ValueErrorN)tarfile
tar_filterFilterErrorr   str)memberru   excs      r/   extraction_filterz$unarchive.<locals>.extraction_filter  sP    +)&$777& + + + S***+s    AAA)rt   ru   r  rw   r  r   r   namelistr2  r'  getnamesr   r   
getmembersr   r\   r   r)  r8  
extractallr   )archive_filenamer*  formatr  r,  archiver;  namesr\   tarinfor8  r+  s    `         @r/   	unarchiverB    sp   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
	+ 	+ 	+ %6!8$$$  	MMOOOOO	 	7 	MMOOOO	s   4DG 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BytesIOrw   r   rt   walkru   r&   r   )	directoryr*   dlenzfrx   ra  r:  r\   fullrelr   s              r/   zip_dirrL    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      r/   r   zProgress.__init__$  sE    ~6!1!1!1!1$$48			r1   c                     | j         |k    sJ | j        || j        k    sJ || _        t          j                    }| j        	|| _        d S || j        z
  | _        d S r   )r  rX  rW  timerY  rZ  )r   curvalnows      r/   updatezProgress.update,  sf    x6!!!!x6TX#5#5#5#5ikk<DLLL-DLLLr1   c                 P    |dk    sJ |                      | j        |z              d S )Nr   )rb  rW  )r   incrs     r/   	incrementzProgress.increment6  s-    qyyyyDHtO$$$$$r1   c                 :    |                      | j                   | S r   )rb  r  r  s    r/   r  zProgress.start:  s    DHr1   c                 V    | j         |                     | j                    d| _        d S NT)rX  rb  r[  r  s    r/   stopzProgress.stop>  s)    8KK!!!			r1   c                 ,    | j         | j        n| j         S r   )rX  unknownr  s    r/   maximumzProgress.maximumC  s    #x/t||TX=r1   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 %%)r[  rX  rW  r  )r   r*   rS   s      r/   
percentagezProgress.percentageG  sQ    9 	"FFXFFDH,-DH1DEA\Fr1   c                     |dk    r| j         | j        | j        k    rd}n't          j        dt          j        |                    }|S )Nr   z??:??:??z%H:%M:%S)rX  rW  r  r_  strftimegmtime)r   durationr*   s      r/   format_durationzProgress.format_durationR  sI    MMtx/48tx3G3GFF ]:t{8/D/DEEFr1   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: )r[  rZ  rX  rW  r  floatrs  )r   r   rl   s      r/   ETAzProgress.ETA[  s    9 	+FAA Fx""tx48';'; $(TX-..TX((Udl*!664#7#7#:#:#:;;r1   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)rZ  rW  r  UNITS)r   r*   units      r/   speedzProgress.speedn  sc    <1FFh)T\9F 	 	D}}fFFVTN**r1   N)r   rU  )r   r   r   rk  r   rb  re  r  ri  r  rl  rn  rs  rw  r{  rD   r1   r/   rS  rS  !  s        G   . . .% % %    
 > > X>   X   < < X<$ 	+ 	+ X	+ 	+ 	+r1   rS  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     r/   r   r     sj    ##I.. *Ky)))!!),, *Fy))))r1   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   rK   r   z**ri  r  rs   \)	RICH_GLOBr   rw   r  r&   	std_iglobr'   rt   rF  ru   r  )r  rich_path_globr   r   r   itemru   radicaldirr:  r  s              r/   r  r    s     __Y22N
>Q>""a'''''',VIIcNN 	 	Drwwf'=>>??  



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



  (oodA66OFG||"}} "..--!....$&GFOO   c5w''-- dG!<!<==  BHHHH r1   )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_        t          | dd           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	cert_file)cafileHAS_SNIserver_hostnamezHost verified: %s)r   create_connectionhostporttimeoutr   sock_tunnelssl
SSLContextPROTOCOL_SSLv23r   optionsr  load_cert_chainr  key_fileca_certsCERT_REQUIREDverify_modeload_verify_locationswrap_socketcheck_domainr  getpeercertr  rQ  r  shutdown	SHUT_RDWRr   )r   r  contextr  s       r/   connectzHTTPSConnection.connect  s   +TY	,BDLQQDt^U33  	nS%899GsM** 33?2t[$// 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  rD   r1   r/   r  r    s-        	 	 	 	 	r1   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      r/   r   zHTTPSHandler.__init__  s(    %d+++$DM ,Dr1   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       r/   _conn_makerzHTTPSHandler._conn_maker  s9     %d5f55F} 8"&-&*&7#Mr1   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   r5  reasonr  r  )r   rg   r  s      r/   
https_openzHTTPSHandler.https_open  sy    ||D$4c:::   .#ah--??* ,469h,? @ @ @ s    
A.AANrf  )r   r   r   r   r  r  rD   r1   r/   r  r    sF        	- 	- 	- 	-
	 	 	 	 	 	 	 	r1   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   rg   s     r/   	http_openzHTTPSOnlyHandler.http_open  s!     ,.12 3 3 3r1   N)r   r   r   r  rD   r1   r/   r  r    s#        	3 	3 	3 	3 	3r1   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      r/   r   zTransport.__init__	  s(    $$T<88888r1   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        r/   make_connectionzTransport.make_connection  sf    ((..2t 	?44+;A+>#>#>"$D#W%;A%>%>>D""r1   Nr   r   r   r   r   r  rD   r1   r/   r  r    s7        9 9 9 9# # # # #r1   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      r/   r   zSafeTransport.__init__  s(    "DL#,,T<@@@@@r1   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        r/   r  zSafeTransport.make_connection  s     ..t44MAr6  $F9# Ttt/?/B'B'B&(##')@D)S)SF)S)S#S #A&&r1   Nr  r  rD   r1   r/   r  r    s;        	A 	A 	A 	A	' 	' 	' 	' 	'r1   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)
rz   r  r   r  r  r  r  r   r  r   )r   rj   r  r  re   r  tclsrl   s           r/   r   zServerProxy.__init__*  s    !'It!<!<<w c]]1%F!::na88L  $ &*d7&N&N&NNF;!DN&tS;;F;;;;;r1   N)r   r   r   r   rD   r1   r/   r  r  (  s#        < < < < <r1   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      r/   	_csv_openr  A  sN    
Qy %zD##F###r1   c                   \    e Zd Z ed           ed           ed          dZd Zd ZdS )CSVBaserK   "r  )	delimiter	quotecharlineterminatorc                     | S r   rD   r  s    r/   	__enter__zCSVBase.__enter__S      r1   c                 8    | j                                          d S r   )r   r   )r   r  s     r/   __exit__zCSVBase.__exit__V  s    r1   N)r   r   r   r5  defaultsr  r  rD   r1   r/   r  r  L  s_        SXXSXX#d)) H      r1   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   ru   r  )	r   r   r   r   r   r  csvr  r  )r   r  r   s      r/   r   zCSVReader.__init__\  s    vH%F"a''2)'226:: DKK#F6NC88DKj>>>>r1   c                     | S r   rD   r  s    r/   __iter__zCSVReader.__iter__g  r  r1   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*   rk   r  s       r/   r  zCSVReader.nextj  sl    dk""A""$V,, 5 54!$	22 5 $G 4 4F1Ir1   N)r   r   r   r   r  r  __next__rD   r1   r/   r  r  Z  sB        	? 	? 	?     HHHr1   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      r/   r   zCSVWriter.__init__w  s4    C((j>>>>r1   c                     t           j        d         dk     rHg }|D ]A}t          |t                    r|                    d          }|                    |           B|}| j                            |           d S r  )r   r   r   r   r0  r$   r  writerow)r   rowr  r  s       r/   r  zCSVWriter.writerow{  s~    A""A  dI.. 0;;w//DCS!!!!!r1   N)r   r   r   r   r  rD   r1   r/   r  r  u  s2        ? ? ?" " " " "r1   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   rt   r   r   )r   configr   	__class__s      r/   r   zConfigurator.__init__  s7    lD!!**6222'BIKK			r1   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 rD   rD   )rY   rk   converts     r/   r[   zBConfigurator.configure_custom.<locals>.convert.<locals>.<listcomp>  s!    !8!8!8''!**!8!8!8r1   ())r   r]  r  typedictconfigure_customr  )or*   r   r  r   s      r/   r  z.Configurator.configure_custom.<locals>.convert  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Mr1   r   ri  z[]rD   c                 &    g | ]} |          S rD   rD   )rY   r  r  s     r/   r[   z1Configurator.configure_custom.<locals>.<listcomp>  s!    333''!**333r1   c                 T    g | ]$}t          |          | |                   f%S rD   )r   )rY   r   r  r  s     r/   r[   z1Configurator.configure_custom.<locals>.<listcomp>  s7    KKKQKNNK!WWVAY''(KKKr1   )rz   r}  ro  r  r  r   setattr)r   r  r   propsr  r   r  r*   r  rS   r  s   ``        @r/   r  zConfigurator.configure_custom  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::....r1   c                     | j         |         }t          |t                    r#d|v r|                     |          x| j         |<   }|S )Nr   )r  r   r  r  )r   r   r*   s      r/   __getitem__zConfigurator.__getitem__  sM    S!fd## 	F(,(=(=f(E(EEDKvr1   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)	rt   ru   isabsr&   r   r   r'  r   r   )r   r   r-  r*   s       r/   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   @r/   r  r    s        t,=>>+U( ( ( ( ( (  @        r1   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      r/   r   zSubprocessMixin.__init__  s     r1   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.
        TNri  r   )	r  r  readliner   stderrr   r)  flushr   )r   r   r  r  r  r.   s         r/   r  zSubprocessMixin.reader  s    
 =,	#!!A #G$$$$ 8J$$S))))J$$QXXg%6%6777
  """	# 	r1   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         r/   run_commandzSubprocessMixin.run_command  s    S[[[TZ[[T[(7KLLL



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


	
			
			=$MM'6****\ 	(JY'''r1   )FN)r   r   r   r  r   r  r$  rD   r1   r/   r  r    sP         ! ! ! !  *    r1   r  c                 R    t          j        dd|                                           S )z,Normalize a python package name a la PEP 503z[-_.]+r  )r  subr   )r\   s    r/   normalize_namer'    s$     6(C&&,,...r1   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)rt   ru   r&   r  r  r_   )r   r  r_   s      r/   r   zPyPIRCFile.__init__  s>    :bg0055yAABr1   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  )rY   servers     r/   r[   z#PyPIRCFile.read.<locals>.<listcomp>  s8    kkkvV\VbVbVdVdhjVjVjFLLNNVjVjVjr1   r  r*  r/  r  
repositoryrealm)r  Nzserver-loginr  )r  r  r0  r/  r1  )rt   ru   r  r  r_   DEFAULT_REPOSITORYr   RawConfigParserr   r   r  r   DEFAULT_REALM
has_option)
r   r*   r0  r  r   index_servers_serversr/  r   r   s
             r/   r   zPyPIRCFile.read  s<   7>>$-(( /	<T%<J!133FKK&&&((Hh&& &

; H Hkk9L9LT9R9Rkkkr>>))$*8"* ( ("*F!3-3ZZ
-K-Kz* /;D<S-TW^`d`rVs-?-A 6 6LC%00== 6.4jj.E.Es.5s
 #f,,@WY_?`1`1`373JF<00$X.*<<AUYcAcAc%'F%(&  8++'$$V\:: 9!'FL!A!AJJ!%!8J &

6: > > &

6: > >",$!/  r1   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   r3  r  r   has_sectionr   r   r'  r   )r   r  r  r  r  r-  s         r/   rb  zPyPIRCFile.updateB  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   r2  r4  r   r   rb  rD   r1   r/   r)  r)    sR        :M   3 3 3j
 
 
 
 
r1   r)  c                 P    t          | j                                                  S )zG
    Read the PyPI access configuration as supported by distutils.
    )r_   )r)  r_   r   r  s    r/   _load_pypircr=  O  s#     %)$$$))+++r1   c                 ^    t                                          | j        | j                   d S r   )r)  rb  r  r  r<  s    r/   _store_pypircr?  V  s&    LL77777r1   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|                                }n\| dd          d#k    rNddl}		 dd$lm}
 n# t,          $ r ddl}
Y nw xY w|	                    |
                                | ||          \  } }}| 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_PLATFORMr3  unamers   r   rV   rm   r  N   linuxsunosr   5solarisz%d.%sr      32bit64bit)il    z.%saix)aix_platform   cygwinz[\d.]+darwin)	sysconfig)rt   r\   r   r  r   platformr  r   rE  r#   intmaxsize_aix_supportrO  r  rF  ASCIIr   r   _osx_supportr-  rS  ImportErrorget_platform_osxget_config_vars)osnamer  releaser  machinebitnessrO  rel_rer)   rY  rS  s              r/   get_host_platformrb  `  s   ( 
w$ck''))));ck''))));))++++;| "*,,z122	w'W!5!5 | 13

-VT7GW \\^^##C,,Fooc3''//S99GbqbzW !&&''**	w		1:FWQZ1!4gabbk BBG $+IIGuws{333G	u		------|~~	x		Irx00LL!! 	 ggiiG	x			+++++++ 	 	 		#/#@#@AZAZA\A\^dfmov#w#w ''22s   ?I IIwin32rB  rC  )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)rt   r\   rb  r  r  _TARGET_TO_PLAT)cross_compilation_targets    r/   get_platformrk    sQ    	w$ """!z~~.BCC66 """344r1   r:  )r   r   rf  rh  )r   collectionsr   
contextlibr  globr   r  rD  r   loggingrt   rD  r  r   r  rZ  r  r   r2  r   r   r  dummy_threadingr_  r   r   compatr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   	getLoggerr   r  rF  r   rP   rO   r:   rC   r?   rd   r%   rF   ro   r   r   r   r   r   r   r   contextmanagerr   r   r   r   r   r   r   ro  rq  VERBOSEr  r   r  r  r  r  r  r  Ir  r  r  r  r  r  r  r  r  r  r  r  r  ARCHIVE_EXTENSIONSrB  rL  ry  rS  r  r}  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r'  r)  r=  r?  rb  ri  rk  rD   r1   r/   <module>rw     s	  
            



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



   ( ( ( (''''''(       2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 
	8	$	$ RZ)**
RZ 344 RZ566
BJDEE	RZbjBJ{##	rzEFFW! W! W!tyt yt ytx  4    $      , , ,^  &       & & & &    f         6w w w w w6 w w wt      &   4 2: :	' '  >&( &( &( &(R   "  & & &     &2: '89;? ? ,--   4 "* 9 : :/ / /   8  * D   # # #) ) ) ) )F ) ) )XC C C C C C C CRF! F! F! F! F! F! F! F!Z U A A A AH  $ 	&W+ W+ W+ W+ W+v W+ W+ W+| BJ~&&	"
#?@@  bj!566     8  V3\\\\\\\\\\    '1   B    '   T3 3 3 3 3< 3 3 3# # # # #	# # # #  '' ' ' ' '	/ ' ' '"< < < < <)' < < <2$ $ $    f          6" " " " " " " ",5 5 5 5 5# 5 5 5p+ + + + +f + + +\/ / /"J J J J J J J JZ, , ,8 8 8P3 P3 P3h  5 5 5 5 5s!   ; AAA" "	A.-A.