
    g                    &   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d dlZd dlZd dlZd dlZd dlZ	 d dlZd dlZddlmZ ddl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
j`                  e1      Z2 ejf                  d      Z4 ejf                  d      Z5 ejf                  d	      Z6 ejf                  d
      Z7 ejf                  d      Z8 ejf                  d      Z9 ejf                  d      Z: ejf                  d      Z;d Z<d Z=d Z>d Z?d Z@didZAd ZBd ZCd ZDej                  d        ZFej                  d        ZGej                  djd       ZH G d deI      ZJd ZK G d deI      ZLd  ZM G d! d"eI      ZN ejf                  d#ej                        ZPd$ ZQdkd%ZRd& ZSd' ZTd( ZUd) ZVd* ZW ejf                  d+ej                        ZY ejf                  d,      ZZdkd-Z[ ejf                  d.      Z\d/ Z]d0 Z^d1 Z_d2Z`d3 Zad4 Zb G d5 d6eI      Zc G d7 d8eI      Zd G d9 d:eI      Zed;Zfdld<Zgd= Zhd>Zi G d? d@eI      Zj ejf                  dA      Zk ejf                  dB      Zl ejf                  dC      ZmdD ZdE Zner6ddFlmoZpmqZqmrZr  G dG dHe$j                        Zs G dI dJep      Zo G dK dLeoe&      Zt G dM dNe%j                        Zuer G dO dPe%j                        Zv G dQ dRe%j                        ZwdS Zx G dT dUeI      Zy G dV dWey      Zz G dX dYey      Z{ G dZ d[e'      Z| G d\ d]eI      Z}d^ Z~ G d_ d`eI      Zda Zdb Zdc ZdddedfdgZdh Zy# e$ r dZY Ew xY w# e$ r d dlZY <w xY w)m    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                 @    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         j                  |       }|r*|j                         d   }| |j                         d  } || fS | st	        d      | d   }|dvrt	        d| z        dj                  |d      }| dd  } |g}| r| d   |k(  rn| d   |k(  r|j                  |       | dd  } nZt        j                  |       }|st	        d| z        |j                  |j                         d          | |j                         d  } | rdj                  |      }t	        d|z        |j                  |       dj                  |      }| dd  j                         } || 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          U/var/www/django_project/virt/lib/python3.12/site-packages/pip/_vendor/distlib/util.py
marker_varz parse_marker.<locals>.marker_varB   s{   Y'XXZ]F!!%%'(+I< y  ; 788!A~!":Y"FGGq"%B!!"ICEQ<1$q\R'LL$ )!"I$**95A)*G*3+4 5 5LLA/ )!%%'( 3I  GGEN!";a"?@@LLOWWU^F!!",,.Iy      c                 t   | rQ| d   dk(  rI | dd  j                               \  }} | d   dk7  rt        d| z        | dd  j                         } || fS  |       \  }} | rRt        j                  |       }|sn:|j	                         d   }| |j                         d  }  |       \  }} |||d}| rR|}|| 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_exprg   s    1, &y}';';'= >FI|s"!"@9"LMM!!",,.I y   (	2NCOOI.XXZ]%aeegh/	!+I!6YC8  Fy  r1   c                      |       \  }} | rCt         j                  |       }|s	 || fS | |j                         d  }  |       \  }} d||d}| rC|| fS )Nandr6   )ANDr   r!   )r(   r8   r)   r9   r<   s       r/   
marker_andz parse_marker.<locals>.marker_andz   ss    $Y/Y		)$A I~ "!%%'(+I(3NCs37C  I~r1   c                      |       \  }} | rCt         j                  |       }|s	 || fS | |j                         d  }  |       \  }} d||d}| rC|| fS )Norr6   )ORr   r!   )r(   r8   r)   r9   r@   s       r/   r;   zparse_marker.<locals>.marker   ss    #I.Y#A I~ "!%%'(+I'	2NCc#6C  I~r1    )marker_stringr;   r@   r<   r0   s    @@@@r/   parse_markerrF   8   s%    #!J!&		 -  r1   c           	         | j                         }|r|j                  d      ryt        j                  |      }|st	        d|z        |j                         d   }||j                         d }dx}x}x}}|r|d   dk(  r|j                  dd      }|dk  rt	        d|z        |d| }	||dz   d j                         }g }|	rt        j                  |	      }|st	        d	|	z        |j                  |j                         d          |	|j                         d }	|	sn,|	d   d
k7  rt	        d|	z        |	dd j                         }	|	r|sd}|r|d   dk(  r|dd j                         }t        j                  |      }|st	        d|z        |j                         d   }t        |      }
|
j                  r|
j                  st	        d|z        ||j                         d j                         }nd }|d   dk7  r ||      \  }}n|j                  dd      }|dk  rt	        d|z        |d| }	||dz   d j                         }t        j                  |	      r ||	      \  }}nnt        j                  |	      }|st	        d|	z        |j                         d   }|	|j                         d j                         }	|	rt	        d|	z        d|fg}|r7|d   dk7  rt	        d|z        |dd j                         }t!        |      \  }}|r|d   dk7  rt	        d|z        |s|}n'|ddj#                  |D cg c]  }d|z  	 c}      }t%        ||||||      S c c}w )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         j                  |       }d}|rg }	 |j                         d   }| |j                         d } t        j                  |       }|st        d| z        |j                         d   }|j                  ||f       | |j                         d } | r| d   dk7  rn<| dd j                         } | sn&t         j                  |       }|st        d| z        |sd}|| fS )z|
                Return a list of operator, version tuples if any are
                specified, else None.
                Nr   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   s   
 $$]3!HXXZ](5aeegh(?.44]C "-.C.;/< #= =HHJqM Q0(5aeegh(?,a0@C0G!(5ab(9(@(@(B  -!&,,]; "-.F.;/< #= =' * $#'..r1   r3   r4   r5   rN   z~=;zinvalid requirement: %szunexpected trailing data: %s , z%s %s)nameextrasconstraintsr;   urlrequirement)strip
startswithr   r   r"   r    r!   findr'   r$   	NON_SPACEr   schemenetlocrO   rP   rF   r&   r   )reqr(   r)   distnamerY   	mark_exprrR   uriir.   trT   _rS   rscons                   r/   parse_requirementrl      s   
 		I	,,S1#A-	9::xxz!}H!%%'(#I*..F.Y.CYq\S(NN3"q56BCCaNa!ef%,,.	  #A!"7!";<<MM!((*Q-(!%%'(Ats{!"@1"DEE!"A  FQ<3!!",,.I	*A!"3i"?@@((*Q-CA
 HH!"3c"9::!!%%'(+224I /D |s"&29&=#)NN3*q5%&D&/'0 1 1aN%a!ef-446	 ##A&".q/KHa*003A)*BQ*FGG
1A!%%'(**,A)*BQ*FGG!%q	{HQ<37)CDDabM((*	+I6	9Yq\S(89DEE $))&./sWs]/#1 2("!)%!#% % 0s   
M0c                    d }i }|D ]  \  }}}t         j                  j                  | |      }t        |      D ]  }t         j                  j                  ||      }	t        |	      D ]m  }
 || |
      }||j	                  |d       ! |||
      }|j                  t         j                  j                  d      j                  d      }|dz   |z   ||<   o   |S )z%Find destinations for resources filesc                 
   | j                  t        j                  j                  d      } |j                  t        j                  j                  d      }|j	                  |       sJ |t        |       d  j                  d      S N/)r#   ospathsepr^   lenr'   )rootrr   s     r/   get_rel_pathz)get_resources_dests.<locals>.get_rel_path  s`    ||BGGKK-||BGGKK-t$$$CIJ&&s++r1   Nrp   )rq   rr   r&   r   popr#   rs   rstrip)resources_rootrulesrv   destinationsbasesuffixdestprefixabs_baseabs_globabs_pathresource_filerel_pathrel_dests                 r/   get_resources_destsr     s    , L# Lfdnd3f 		LHww||Hf5H!(O L ,^X F< $$]D9+Hh?H#||BGGKK=DDSIH2:S.82KL/L		LL r1   c                      t        t        d      rd} | S t        j                  t        t        dt        j                        k7  } | S )Nreal_prefixTbase_prefix)hasattrsysr   getattrr*   s    r/   in_venvr   2  s:    sM" M wsM3::FFMr1   c                  \    t         j                  } t        | t              st	        |       } | S N)r   
executable
isinstancer   r   r   s    r/   get_executabler   <  s&     ^^Ffi(&!Mr1   c                 |    | }	 t        |      }| }|s|r|}|r$|d   j                         }||v r	 |S |rd||| fz  }:)Nr   z	%c: %s
%s)r
   lower)promptallowed_charserror_promptdefaultpr.   cs          r/   proceedr   N  sa    A
aLWA!

AM! H  A|V#<< r1   c                 r    t        |t              r|j                         }i }|D ]  }|| v s| |   ||<    |S r   )r   r   split)dkeysr*   keys       r/   extract_by_keyr   ^  sF    $%zz|F !!8C&F3K! Mr1   c                 H   t         j                  d   dk\  r t        j                  d      |       } | j	                         }t        |      } 	 t        j                  |       }|d   d   d   }|j                         D ]8  \  }}|j                         D ]   \  }}|d|}t        |      }	|	J |	||<   " : |S # t        $ r | j                  dd       Y nw xY wd }
t        j                         }	  |
||        nR# t        j                  $ r< | j                          t!        j"                  |      }t        |      }  |
||        Y nw xY wi }|j%                         D ]=  }i x||<   }|j                  |      D ]   \  }}|d|}t        |      }	|	J |	||<   " ? |S )	Nr      utf-8
extensionszpython.exportsexports = c                 b    t        | d      r| j                  |       y | j                  |       y )N	read_file)r   r   readfp)cpstreams     r/   read_streamz!read_exports.<locals>.read_stream|  s$    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   rX   values                  r/   read_exportsr   h  s   
a*!!'*62;;=Dd^F		&!|$%56yA$lln 	#NE7 #1!"A&(+((("
	#	#  Aq 
	"	"	$B B11  t$$B	  F{{} " ""sg88C= 	"KD%!5)A$Q'E$$$!GDM	"" Ms&   A,B; ;CC4	C> >AEEc                 (   t         j                  d   dk\  r t        j                  d      |      }t	        j
                         }| j                         D ]  \  }}|j                  |       |j                         D ]  }|j                  |j                  }n|j                  d|j                  }|j                  r!|ddj                  |j                        d}|j                  ||j                  |         |j                  |       y )Nr   r   r   :z [rW   rJ   )r   r   r   	getwriterr   r   r   add_sectionvaluesr}   r   flagsr&   setrX   write)r   r   r   r   rS   r   r.   s          r/   write_exportsr     s    
a*!!'*62		"	"	$B 
%1
qXXZ 	%E||#LL$||U\\:{{!"DIIekk$:;FF1ejj!$	%
% HHVr1   c               #      K   t        j                         } 	 |  t        j                  |        y # t        j                  |        w xY wwr   )tempfilemkdtempr	   rmtree)tds    r/   tempdirr     s6     				Bbbs   A2 AA		Ac              #      K   t        j                         }	 t        j                  |        d  t        j                  |       y # t        j                  |       w xY wwr   )rq   getcwdchdir)r   cwds     r/   r   r     s:     
))+C

   A!A A!AA!c              #      K   t        j                         }	 t        j                  |        d  t        j                  |       y # t        j                  |       w xY wwr   )socketgetdefaulttimeoutsetdefaulttimeout)secondsctos     r/   socket_timeoutr     sF     

"
"
$C&  )  %  %r   c                       e Zd Zd ZddZy)cached_propertyc                     || _         y r   )func)selfr   s     r/   __init__zcached_property.__init__  s	    	r1   Nc                     || S | j                  |      }t        j                  || j                   j                  |       |S r   )r   object__setattr____name__)r   objclsr   s       r/   __get__zcached_property.__get__  s:    ;K		#3		 2 2E:r1   r   )r   
__module____qualname__r   r   rD   r1   r/   r   r     s    
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        | j                  d      }t         j                  |v r2|j                  t         j                         t         j                  |v r2|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.
    rp   r   zpath '%s' cannot be absolutezpath '%s' cannot end with '/')rq   rs   
ValueErrorr   curdirremoverr   r&   )pathnamepathss     r/   convert_pathr     s     
vv}{c7(BCC|s88CDDNN3E
))u
RYY ))u
yy77<<r1   c                   |    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y)FileOperatorc                 P    || _         t               | _        | j                          y r   )dry_runr   ensured_init_record)r   r   s     r/   r   zFileOperator.__init__  s    ur1   c                 N    d| _         t               | _        t               | _        y NF)recordr   files_writtendirs_createdr   s    r/   r   zFileOperator._init_record  s     UEr1   c                 T    | j                   r| j                  j                  |       y y r   )r  r  add)r   rr   s     r/   record_as_writtenzFileOperator.record_as_written  s"    ;;""4( r1   c                 T   t         j                  j                  |      s+t        dt         j                  j	                  |      z        t         j                  j                  |      syt        j
                  |      j                  t        j
                  |      j                  kD  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)rq   rr   existsr   abspathstatst_mtime)r   sourcetargets      r/   newerzFileOperator.newer  ss     ww~~f%"#=#%77??6#:$; < <ww~~f%wwv''"''&/*B*BBBr1   c                    | j                  t        j                  j                  |             t        j                  d||       | j                  sd}|rht        j                  j                  |      rd|z  }nCt        j                  j                  |      r$t        j                  j                  |      sd|z  }|rt        |dz         t        j                  ||       | j                  |       y)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_dirrq   rr   dirnameloggerinfor   islinkr	  isfiler   r	   copyfiler  )r   infileoutfilecheckmsgs        r/   	copy_filezFileOperator.copy_file  s     	01&8||C77>>'*+g5CWW^^G,RWW^^G5L4w>C 'D!DEEOOFG,w'r1   Nc                    t         j                  j                  |      rJ | j                  t         j                  j	                  |             t
        j                  d||       | j                  sN|t        |d      }nt        j                  |d|      }	 t        j                  ||       |j                          | j                  |       y # |j                          w xY w)NzCopying stream %s to %swbwencoding)rq   rr   isdirr  r  r  r  r   openr   r	   copyfileobjr   r  )r   instreamr  r!  	outstreams        r/   copy_streamzFileOperator.copy_stream'  s    77==)))01-xA|| $/	"KKxH	"""8Y7!w' !s   C C%c                 f   | j                  t        j                  j                  |             | j                  sZt        j                  j                  |      rt        j                  |       t        |d      5 }|j                  |       d d d        | j                  |       y # 1 sw Y   xY w)Nr  )
r  rq   rr   r  r   r	  r   r#  r   r  )r   rr   r   fs       r/   write_binary_filezFileOperator.write_binary_file6  sw    -.||ww~~d#		$dD! Qt$ s   ;B''B0c                 F    | j                  ||j                  |             y r   )r*  encode)r   rr   r   r!  s       r/   write_text_filezFileOperator.write_text_file?  s    tT[[%:;r1   c                 r   t         j                  dk(  s&t         j                  dk(  rt         j                  dk(  r}|D ]w  }| j                  rt        j                  d|       &t        j                  |      j                  |z  |z  }t        j                  d||       t        j                  ||       y y y y )Nposixjavazchanging mode of %szchanging mode of %s to %o)	rq   rX   _namer   r  r  r  st_modechmod)r   bitsmaskfilesr)  modes         r/   set_modezFileOperator.set_modeB  s    77g"''V"3G8K  &<<KK 5q9GGAJ..5=DKK ;QEHHQ%& 9L"3r1   c                 (    | j                  dd|      S )Nim  i  )r8  )r.   r)  s     r/   <lambda>zFileOperator.<lambda>N  s    qzz%'C r1   c                    t         j                  j                  |      }|| j                  vrt         j                  j	                  |      s| j                  j                  |       t         j                  j                  |      \  }}| j                  |       t        j                  d|z         | j                  st        j                  |       | j                  r| j                  j                  |       y y y y )NzCreating %s)rq   rr   r
  r   r	  r  r   r  r  r  r   mkdirr  r  )r   rr   r   r)  s       r/   r  zFileOperator.ensure_dirP  s    wwt$t||#BGGNN4,@LLT"77==&DAqOOAKK,-<<{{!!%%d+  -A#r1   c                    t        ||       }t        j                  d||       | j                  s|s| j	                  ||      r&|sd }n!|j                  |      sJ |t        |      d  }i }|r-t        t        d      rt        j                  j                  |d<   t        j                  ||dfi | | j                  |       |S )NzByte-compiling %s to %sPycInvalidationModeinvalidation_modeT)r   r  r  r   r  r^   rt   r   
py_compiler>  CHECKED_HASHcompiler  )	r   rr   optimizeforcer   hashed_invalidationdpathdiagpathcompile_kwargss	            r/   byte_compilezFileOperator.byte_compile\  s     "$H5-tU;||

4/#H??6222#CKL1HN"wz/D(F ,6+I+I+V+V ')tUHd 1!/1u%r1   c                    t         j                  j                  |      rAt         j                  j                  |      rt         j                  j	                  |      sot
        j                  d|       | j                  st        j                  |       | j                  r+|| j                  v r| j                  j                  |       y y y t         j                  j	                  |      rd}nd}t
        j                  d||       | j                  st        j                  |       | j                  r+|| j                  v r| j                  j                  |       y y y y )NzRemoving directory tree at %slinkfilezRemoving %s %s)rq   rr   r	  r"  r  r  debugr   r	   r   r  r  r   r  )r   rr   r.   s      r/   ensure_removedzFileOperator.ensure_removedu  s    77>>$ww}}T"277>>$+?<dC||MM$';;t000))006 1  77>>$'AA-q$7||IIdO;;t111**11$7 2 !  r1   c                     d}|srt         j                  j                  |      r't        j                  |t         j                        }	 |S t         j                  j                  |      }||k(  r	 |S |}|sr|S r   )rq   rr   r	  accessW_OKr  )r   rr   r*   parents       r/   is_writablezFileOperator.is_writable  sn    ww~~d#41
 	 WW__T*F~ D  r1   c                 r    | j                   sJ | j                  | j                  f}| j                          |S )zV
        Commit recorded changes, turn off recording, return
        changes.
        )r  r  r  r   )r   r*   s     r/   commitzFileOperator.commit  s7    
 {{{##T%6%66r1   c                    | j                   st        | j                        D ]7  }t        j                  j                  |      s#t        j                  |       9 t        | j                  d      }|D ]n  }t        j                  |      }|r@|dgk(  sJ t        j                  j                  ||d         }t        j                  |       t        j                  |       p | j                          y )NT)reverse__pycache__r   )r   listr  rq   rr   r	  r   sortedr  listdirr&   rmdirr   )r   r)  dirsr   flistsds         r/   rollbackzFileOperator.rollback  s    ||$,,- !77>>!$IIaL! $++T:D 

1 ]O333aq2BHHRL 	r1   FTr   )FFNF)r   r   r   r   r   r  r  r  r'  r*  r-  r8  set_executable_moder  rI  rN  rS  rU  r`  rD   r1   r/   r   r     se    
"
)C(("(%<
& D
, $  ).28*
r1   r   c                     | t         j                  v rt         j                  |    }nt        |       }||}|S |j                  d      }t	        ||j                  d            }|D ]  }t	        ||      } |S )N.r   )r   modules
__import__r   r   rw   )module_namedotted_pathmodr*   r-   r   s         r/   resolverk    s~    ckk!kk+&% M	 !!#&eiil+ 	(AVQ'F	(Mr1   c                   F    e Zd Zd Zed        Zd Zd Zej                  Z	y)ExportEntryc                 <    || _         || _        || _        || _        y r   rX   r   r}   r   )r   rX   r   r}   r   s        r/   r   zExportEntry.__init__  s    	
r1   c                 B    t        | j                  | j                        S r   )rk  r   r}   r  s    r/   r   zExportEntry.value  s    t{{DKK00r1   c           	      p    d| j                   d| j                  d| j                  d| j                  d	S )Nz<ExportEntry r   r   rV   >ro  r  s    r/   __repr__zExportEntry.__repr__  s(    04		4;;04TZZI 	Ir1   c                    t        |t              sd}|S | j                  |j                  k(  xrO | j                  |j                  k(  xr4 | j                  |j                  k(  xr | j
                  |j
                  k(  }|S r   )r   rm  rX   r   r}   r   )r   otherr*   s      r/   __eq__zExportEntry.__eq__  st    %-F
  ii5::- 4$++2M 4++54**3  r1   N)
r   r   r   r   r   r   rs  rv  r   __hash__rD   r1   r/   rm  rm    s1     1 1I Hr1   rm  z(?P<name>([^\[]\S*))
                      \s*=\s*(?P<callable>(\w+)([:\.]\w+)*)
                      \s*(\[\s*(?P<flags>[\w-]+(=\w+)?(,\s*\w+(=\w+)?)*)\s*\])?
                      c                    t         j                  |       }|sd }d| v sd| v rt        d| z        |S |j                         }|d   }|d   }|j	                  d      }|dk(  r|d }}n'|dk7  rt        d| z        |j                  d      \  }}|d	   }	|	d| v sd| v rt        d| z        g }	n,|	j                  d
      D 
cg c]  }
|
j                          }	}
t        ||||	      }|S c c}
w )NrI   rJ   zInvalid specification '%s'rX   callabler   r   r   r   rK   )ENTRY_REsearchr   	groupdictcountr   r]   rm  )specificationr)   r*   r   rX   rr   colonsr   r}   r   r)  s              r/   r   r     s.   &A-3-#7" $*,9$: ; ;. M) KKMy}CQ;!4FF{& (.0=(> ? ?!ZZ_NFF'
=m#sm';& (.0=(> ? ?E(-C(891QWWY9E9T6659M :s   C*c                    | d} t         j                  dk(  r2dt         j                  v r t         j                  j	                  d      }nt         j                  j                  d      }t         j                  j                  |      r=t        j                  |t         j                        }|s/t        j                  d|       n	 t        j                  |       d}|s*t        j                         }t        j                  d|       t         j                  j                  ||       S # t        $ r t        j                  d|d	       d
}Y qw xY w)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``.
    z.distlibntLOCALAPPDATAz$localappdata~z(Directory exists but is not writable: %sTzUnable to create %s)exc_infoFz#Default location unusable, using %s)rq   rX   environrr   
expandvars
expanduserr"  rP  rQ  r  warningmakedirsOSErrorr   r   r&   )r}   r*   usables      r/   get_cache_baser    s     ~	ww$>RZZ7##O4 ##C( 
ww}}V6277+NNEvN	KKF !!#<fE77<<''  	NN0&4NHF	s   D) )#EEc                     t         j                  j                  t         j                  j                  |             \  }}|r|j	                  dd      }|j	                  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)rq   rr   
splitdriver
  r#   rs   )rr   r   r   s      r/   path_to_cache_dirr  -  s_     77bggood34DAqIIc5!			"&&$Aq58r1   c                 2    | j                  d      s| dz   S | S ro   )endswith)r.   s    r/   ensure_slashr  >  s    ::c?3wHr1   c                     d x}}d| v r1| j                  dd      \  }} d|vr|}n|j                  dd      \  }}|rt        |      }|rt        |      }||| fS )NrL   r   r   )rsplitr   r   )rb   usernamepasswordr   s       r/   parse_credentialsr  D  sp    Hx
f}sA.fH!'c1!5Hh8$8$Xv%%r1   c                  Z    t        j                  d      } t        j                  |        | S )N   )rq   umaskr   s    r/   get_process_umaskr  S  s     XXd^FHHVMr1   c                 d    d}d }t        |       D ]  \  }}t        |t              rd} n |J |S )NTF)	enumerater   r   )seqr*   rg   r.   s       r/   is_string_sequencer  Y  sF    FA# 1!\*F ==Mr1   z3([a-z0-9_]+([.-][a-z_][a-z0-9_]*)*)-([a-z0-9_.+-]+)z-py(\d\.?\d?)c                    d}d}t        |       j                  dd      } t        j                  |       }|r$|j	                  d      }| d|j                          } |rft        |       t        |      dz   kD  rLt        j                  t        j                  |      dz   |       }|r|j                         }| d| | |dz   d |f}|:t        j                  |       }|r#|j	                  d      |j	                  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   startrt   rer   escaper!   PROJECT_NAME_AND_VERSION)filenameproject_namer*   pyverr)   ns         r/   split_filenamer  j  s     FEx ((c2Hh'A
JQWWY'HL(9A(==HHRYY|,u4h?Abq\8AEF#3U:F~$**84WWQZU2FMr1   z-(?P<name>[\w .-]+)\s*\(\s*(?P<ver>[^\s)]+)\)$c                     t         j                  |       }|st        d| z        |j                         }|d   j	                         j                         |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'rX   ver)NAME_VERSION_REr   r   r|  r]   r   )r   r)   r   s      r/   parse_name_and_versionr    sV     	a AG!KLL	AV9??""$ah..r1   c                    t               }t        | xs g       } t        |xs g       }d| v r| j                  d       ||z  }| D ]  }|dk(  r|j                  |       |j                  d      r8|dd  }||vrt        j                  d|z         ||v sQ|j                  |       c||vrt        j                  d|z         |j                  |        |S )N*r  r   zundeclared extra: %s)r   r   r  r^   r  r  )	requested	availabler*   runwanteds        r/   
get_extrasr    s    UFIO$IIO$I
i) 8JJqM\\#uHy(5@A6!h'	!59:JJqM Mr1   c                 t   i }	 t        |       }|j                         }|j                  d      }|j                  d      st        j                  d|       |S  t        j                  d      |      }t        j                  |      }	 |S # t        $ r"}t        j                  d| |       Y d }~|S d }~ww xY w)NzContent-Typezapplication/jsonz(Unexpected response for JSON request: %sr   z&Failed to get external data for %s: %s)r   r  getr^   r  rM  r   r   r   r   r   	exception)r[   r*   respheadersctreaderes          r/   _get_external_datar    s    FK s|))+[[(}}/0LLCRH M /V%%g.t4F YYv&F M  KA3JJMKs   AB 0B 	B7B22B7z'https://www.red-dove.com/pypi/projects/c                 n    | d   j                         d| d}t        t        |      }t        |      }|S )Nr   rp   z/project.jsonupperr   _external_data_base_urlr  )rX   r[   r*   s      r/   get_project_datar    s2    "&q'--/4
8C
)3
/C$FMr1   c                 p    | d   j                         d| d|d}t        t        |      }t        |      S )Nr   rp   z	/package-z.jsonr  )rX   versionr[   s      r/   get_package_datar    s0    %)!W]]_dG
DC
)3
/Cc""r1   c                   "    e Zd ZdZd Zd Zd Zy)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                  j                  |      st        j                  |       t        j                  |      j
                  dz  dk7  rt        j                  d|       t         j                  j                  t         j                  j                  |            | _
        y)zu
        Initialise an instance.

        :param base: The base directory where the cache should be located.
        ?   r   zDirectory '%s' is not privateN)rq   rr   r"  r  r  r2  r  r  r
  normpathr|   )r   r|   s     r/   r   zCache.__init__  sm     ww}}T"KKGGDM!!D(Q.NN<dCGGOOBGG$4$4T$:;	r1   c                     t        |      S )zN
        Converts a resource prefix to a directory name in the cache.
        )r  )r   r   s     r/   prefix_to_dirzCache.prefix_to_dir  s     !((r1   c                    g }t        j                  | j                        D ]  }t         j                  j	                  | j                  |      }	 t         j                  j                  |      st         j                  j                  |      rt        j                  |       n4t         j                  j                  |      rt        j                  |        |S # t        $ r |j                  |       Y w xY w)z"
        Clear the cache.
        )rq   r[  r|   rr   r&   r  r  r   r"  r	   r   r   r$   )r   not_removedfns      r/   clearzCache.clear  s     **TYY' 	'Bdii,B'77>>"%);IIbMWW]]2&MM"%	'   '""2&'s   BCC98C9N)r   r   r   __doc__r   r  r  rD   r1   r/   r  r    s    <)r1   r  c                   0    e Zd ZdZd ZddZd Zd Zd Zy)	
EventMixinz1
    A very simple publish/subscribe system.
    c                     i | _         y r   )_subscribersr  s    r/   r   zEventMixin.__init__
  s
    r1   c                     | j                   }||vrt        |g      ||<   y||   }|r|j                  |       y|j                  |       y)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  sK       -DKeB		*%j)r1   c                 h    | j                   }||vrt        d|z        ||   j                  |       y)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!  s:       1E9::U:&r1   c                 L    t        | j                  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55r1   c                     g }| j                  |      D ]   }	  ||g|i |}|j	                  |       " t        j                  d||||       |S # t        $ r t        j                  d       d}Y Pw xY w)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$   rM  )r   r  argskwargsr*   r  r   s          r/   publishzEventMixin.publish4  s     ..u5 	!J"5:4:6: MM% 	! 	F66	+    !EFs   A A54A5Nrb  )	r   r   r   r  r   r  r   r  r  rD   r1   r/   r  r    s     *(
'6r1   r  c                   X    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y
)	Sequencerc                 >    i | _         i | _        t               | _        y r   )_preds_succsr   _nodesr  s    r/   r   zSequencer.__init__Q  s    er1   c                 :    | j                   j                  |       y r   )r  r  )r   nodes     r/   add_nodezSequencer.add_nodeV  s    r1   c                 8   || j                   v r| j                   j                  |       |rt        | j                  j	                  |d            D ]  }| j                  ||        t        | j
                  j	                  |d            D ]  }| j                  ||        t        | j                  j                               D ]  \  }}|r	| j                  |=  t        | j
                  j                               D ]  \  }}|r	| j
                  |=  y y )NrD   )r  r   r   r  r  r  rY  r   )r   r  edgesr   r.   r   rS   s          r/   remove_nodezSequencer.remove_nodeY  s    4;;KKt$r23 %At$%r23 %D!$% T[[..01 '1A' T[[..01 '1A' r1   c                     ||k7  sJ | j                   j                  |t                     j                  |       | j                  j                  |t                     j                  |       y r   )r  
setdefaultr   r  r  )r   predsuccs      r/   r  zSequencer.addi  sP    t||tSU+//5tSU+//5r1   c                    ||k7  sJ 	 | j                   |   }| j                  |   }	 |j	                  |       |j	                  |       y # t        $ r t        d|z        w xY w# 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.removen  s    t||	FKK%EKK%E	HLLLL	  	F=DEE	F
  	H4FGG	Hs   A "A& A#&B c                 ^    || j                   v xs || j                  v xs || j                  v S r   )r  r  r  )r   steps     r/   is_stepzSequencer.is_step{  s4    # 'tt{{': '4;;&	(r1   c                    | j                  |      st        d|z        g }g }t               }|j                  |       |r|j	                  d      }||v r(||k7  rr|j                  |       |j                  |       nO|j                  |       |j                  |       | j                  j                  |d      }|j                  |       |rt        |      S )NzUnknown: %rr   rD   )r  r   r   r$   rw   r   r  r  r  extendreversed)r   finalr*   todoseenr  r  s          r/   	get_stepszSequencer.get_steps  s    ||E"]U233uE88A;Dt| 5=MM$'MM$'d#b1E"   r1   c                     dgg i i g | j                   fdD ]  }|vs |        S )Nr   c                    d   | <   d   | <   dxx   dz  cc<   
j                  |        	 |    }|D ]>  }|vr |       t        |    |         | <   %|
v s*t        |    |         | <   @ |    |    k(  rHg }	 
j                         }|j                  |       || k(  rn(t	        |      }	j                  |       y y # t        $ r g }Y w xY wNr   r   )r$   r   minrw   tuple)r  
successors	successorconnected_component	componentgraphindexindex_counterlowlinksr*   stackstrongconnects        r/   r  z3Sequencer.strong_connections.<locals>.strongconnect  s    '*E$K*1-HTN!!LL "4[
 ( K	H,!),%($)9L%MHTN%' &)$y9I%JHTNK ~t,&(# %		I'..y9 D(	 
 ""56	i( -   
 s   C CC)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 ]  }|j                  d|d|d        2 | j                  D ]  }|j                  d|z          |j                  d       dj                  |      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    KK 	<DKK%E <tT:;<	< KK 	*DMM'D.)	*cyy  r1   Nra  )r   r   r   r   r  r  r  r   r  r  propertyr  r  rD   r1   r/   r  r  O  sO    
' 6
H( 2 1 1f 	! 	!r1   r  ).tar.gz.tar.bz2.tar.zip.tgz.tbz.whlc                 p   fd}t         j                  j                        t              d }|d| j	                  d      rd}nP| j	                  d      rd}d}n:| j	                  d      rd}d	}n$| j	                  d
      rd}d}nt        d| z        	 |dk(  r.t        | d      }|rW|j                         }|D ]
  } ||        n7t        j                  |       }|r|j                         }|D ]
  } ||        |dk7  rft        j                  d   dk  rP|j                         D ]=  }	t        |	j                  t               r|	j                  j#                  d      |	_        ? d }
|
|_        |j'                         |r|j)                          y y # |r|j)                          w w xY w)Nc                 ,   t        | t              s| j                  d      } t        j                  j                  t        j                  j                  |             }|j                        r|   t        j                  k7  rt        d|z        y )Nr   zpath outside destination: %r)
r   r   decoderq   rr   r
  r&   r^   rs   r   )rr   r   dest_dirplens     r/   
check_pathzunarchive.<locals>.check_path  sm    $	*;;w'DGGOOBGGLL489||H%4BFF):;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)memberrr   excs      r/   extraction_filterz$unarchive.<locals>.extraction_filter  s?    +))&$77&& + S**+s    A?A)rq   rr   r
  rt   r  r   r   namelistr+  r#  getnamesr   r   
getmembersr   rX   r   r"  r1  
extractallr   )archive_filenamer#  formatr  r%  archiver7  namesrX   tarinfor1  r$  s    `         @r/   	unarchiver;    s   A wwx(Hx=DG~$$%56F&&':;FD&&';<FD&&v.FD47GGHH'U?.4G((*! %Dt$% ll#3T:G((*! %Dt$%U?s//2Q6
 #--/ @!',,	:#*<<#6#6w#?GL@	+ %6!8$ MMO 7MMO s   B2F  =F   F5c                    t        j                         }t        |       }t        |d      5 }t	        j
                  |       D ]d  \  }}}|D ]Y  }t        j                  j                  ||      }||d }	t        j                  j                  |	|      }
|j                  ||
       [ f 	 ddd       |S # 1 sw Y   |S xY w)z*zip a directory tree into a BytesIO objectr  N)	ioBytesIOrt   r   rq   walkrr   r&   r   )	directoryr*   dlenzfru   r]  r6  rX   fullrelr~   s              r/   zip_dirrE  %  s    ZZ\Fy>D		 %!#!3 	%D$ %ww||D$/45kww||C.t$	%	%% M% Ms   A=B44B>)r   KMGTPc                   v    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y)ProgressUNKNOWNc                 j    |||k\  sJ |x| _         | _        || _        d | _        d| _        d| _        y )Nr   F)r  curmaxstartedelapseddone)r   minvalmaxvals      r/   r   zProgress.__init__=  s>    ~6!111$$48	r1   c                     | j                   |k  sJ | j                  || j                  k  sJ || _        t        j                         }| j                  || _        y || j                  z
  | _        y r   )r  rP  rO  timerQ  rR  )r   curvalnows      r/   updatezProgress.updateE  sb    xx6!!!xx6TXX#555iik<<DL-DLr1   c                 N    |dk\  sJ | j                  | j                  |z          y )Nr   )rZ  rO  )r   incrs     r/   	incrementzProgress.incrementO  s"    qyyDHHtO$r1   c                 <    | j                  | j                         | S r   )rZ  r  r  s    r/   r  zProgress.startS  s    DHHr1   c                 `    | j                   | j                  | j                          d| _        y NT)rP  rZ  rS  r  s    r/   stopzProgress.stopW  s#    88KK!	r1   c                 J    | j                   | j                  S | j                   S r   )rP  unknownr  s    r/   maximumzProgress.maximum\  s    #xx/t||=TXX=r1   c                     | j                   rd}|S | j                  d}|S d| j                  | j                  z
  z  | j                  | j                  z
  z  }d|z  }|S )Nz100 %z ?? %g      Y@z%3d %%)rS  rP  rO  r  )r   r*   rS   s      r/   
percentagezProgress.percentage`  sf    99F  XXF  DHH,-DHH1DEA\Fr1   c                     |dk  r| j                   | j                  | j                  k(  rd}|S t        j                  dt        j
                  |            }|S )Nr   z??:??:??z%H:%M:%S)rP  rO  r  rW  strftimegmtime)r   durationr*   s      r/   format_durationzProgress.format_durationk  sM    Mtxx/488txx3GF
  ]]:t{{8/DEFr1   c                 |   | j                   rd}| j                  }nd}| j                  d}n{| j                  dk(  s| j                  | j                  k(  rd}nPt        | j                  | j                  z
        }|| j                  | j                  z
  z  }|dz
  | j                  z  }|d| j                  |      S )NDonezETA r   r   r   z: )rS  rR  rP  rO  r  floatrk  )r   r   rh   s      r/   ETAzProgress.ETAt  s    99FA Fxx"txx488'; $((TXX-.TXX((Udll*!4#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)rR  rO  r  UNITS)r   r*   units      r/   speedzProgress.speed  sb    <<1Fhh)T\\9F 	D}fF	 VTN**r1   N)r   d   )r   r   r   rc  r   rZ  r]  r  ra  r  rd  rf  rk  ro  rs  rD   r1   r/   rL  rL  :  su    G.%
 > >   < <$ 	+ 	+r1   rL  z\{([^}]*)\}z[^/\\,{]\*\*|\*\*[^/\\,}]z^[^{]*\}|\{[^}]*$c                     t         j                  |       rd}t        || z        t        j                  |       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     sQ    ##I.Ky))!!),Fy)))r1   c              #     K   t         j                  | d      }t        |      dkD  rXt        |      dk(  sJ |       |\  }}}|j                  d      D ](  }t        dj	                  |||f            D ]  }|  * y d| vrt        |       D ]  }|  y | j                  dd      \  }}|dk(  rd}|dk(  rd}n"|j                  d      }|j                  d	      }t        j                  |      D ]W  \  }}}	t        j                  j                  |      }t        t        j                  j	                  ||            D ]  }
|
  Y y w)
Nr   r   rK   r   z**re  r  rp   \)	RICH_GLOBr   rt   rx  r&   	std_iglobr'   rq   r?  rr   r  )ry  rich_path_globr   r   r}   itemrr   radicaldirr6  r  s              r/   rx  rx    sP    __Y2N
>Q>"a'77',VIIcN 	Drwwf'=>? 
	 y !), 
 (oodA6OFG|"} "..-!...$&GGFO  c5ww''- dG!<= BHs   EE)HTTPSHandlermatch_hostnameCertificateErrorc                       e Zd ZdZdZd Zy)HTTPSConnectionNTc                 ,   t        j                  | j                  | j                  f| j                        }t        | dd      r|| _        | j                          t        j                  t        j                        }t        t        d      r#|xj                  t        j                  z  c_        t        | dd       r&|j                  | j                  | j                          i }| j"                  rQt        j$                  |_        |j)                  | j"                         t        t        dd      r| j                  |d<    |j*                  |fi || _        | j"                  r]| j,                  rP	 t/        | j                  j1                         | j                         t2        j5                  d| j                         y y y # t6        $ rE | j                  j9                  t         j:                         | j                  j=                           w xY w)	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  rM  r  shutdown	SHUT_RDWRr   )r   r  contextr  s       r/   connectzHTTPSConnection.connect  s~   ++TYY		,B,0LL:Dt^U3 	nnS%8%89GsM*3??2t[$/''FF}}&)&7&7#--T]]-C3	5104		F,-+++D;F;DI}}!2!2"499#8#8#:DIIFLL!4dii@ "3} ( II&&v'7'78IIOO%s   4AG AH)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y)r  c                 J    t        j                  |        || _        || _        y r   )BaseHTTPSHandlerr   r  r  )r   r  r  s      r/   r   zHTTPSHandler.__init__  s    %%d+$DM ,Dr1   c                 x    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  s8     %d5f5F}}"&--&*&7&7#Mr1   c                     	 | j                  | j                  |      S # t        $ r5}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   r.  reasonr  r  )r   rc   r  s      r/   
https_openzHTTPSHandler.https_open  sa    ||D$4$4c:: .#ahh-?*!#&88,- - s    	A0AANrb  )r   r   r   r   r  r  rD   r1   r/   r  r    s    	-
	 		r1   r  c                       e Zd Zd Zy)HTTPSOnlyHandlerc                     t        d|z        )NzAUnexpected HTTP request on what should be a secure connection: %s)r   )r   rc   s     r/   	http_openzHTTPSOnlyHandler.http_open  s    !#&'( (r1   N)r   r   r   r  rD   r1   r/   r  r    s    	(r1   r  c                       e Zd ZddZd Zy)	Transportc                 R    || _         t        j                  j                  | |       y r   )r  r   r  r   r   r  use_datetimes      r/   r   zTransport.__init__&  s    $$T<8r1   c                     | j                  |      \  }}}| j                  r|| j                  d   k7  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*  sd    ((.2t44+;+;A+>#>"$D#W%;%;A%>>D""r1   Nr   r   r   r   r   r  rD   r1   r/   r  r  $  s    9#r1   r  c                       e Zd ZddZd Zy)SafeTransportc                 R    || _         t        j                  j                  | |       y r   )r  r   r  r   r  s      r/   r   zSafeTransport.__init__6  s    "DL##,,T<@r1   c                     | j                  |      \  }}}|si }| j                  |d<   | j                  r|| j                  d   k7  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4MAr6 $F9##tt/?/?/B'B&(##')@)@t*'%*' $' ##A&&r1   Nr  r  rD   r1   r/   r  r  4  s    	A		'r1   r  c                       e Zd Zd Zy)ServerProxyc                    |j                  dd       x| _        }|Ht        |      d   }|j                  dd      }|dk(  rt        }nt
        } |||      x|d<   }|| _        t        j                  j                  | |fi | y )Nr  r   r  https)r  	transport)
rw   r  r   r  r  r  r  r   r  r   )r   rf   r  r  ra   r  tclsrh   s           r/   r   zServerProxy.__init__H  s    !'It!<<w c]1%F!::na8L $ &*7&NNF;!DN&&tS;F;r1   N)r   r   r   r   rD   r1   r/   r  r  F  s    <r1   r  c                 h    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  r7  r  s      r/   	_csv_openr  _  sF    
Qy %zD#F##r1   c                   H    e Zd Z ed       ed       ed      dZd Zd Zy)CSVBaserK   "r  )	delimiter	quotecharlineterminatorc                     | S r   rD   r  s    r/   	__enter__zCSVBase.__enter__q      r1   c                 8    | j                   j                          y r   )r   r   )r   r  s     r/   __exit__zCSVBase.__exit__t  s    r1   N)r   r   r   r.  defaultsr  r  rD   r1   r/   r  r  j  s(    XXd)Hr1   r  c                   "    e Zd Zd Zd Zd ZeZy)	CSVReaderc                    d|v r>|d   }t         j                  d   dk\  r t        j                  d      |      }|| _        nt        |d   d      | _        t        j                  | j                  fi | j                  | _        y )Nr   r   r   r   rr   r  )	r   r   r   r   r   r  csvr  r  )r   r  r   s      r/   r   zCSVReader.__init__z  st    vH%F"a'2))'26: DK#F6NC8DKjj>>r1   c                     | S r   rD   r  s    r/   __iter__zCSVReader.__iter__  r  r1   c                     t        | j                        }t        j                  d   dk  r8t	        |      D ]*  \  }}t        |t              r|j                  d      ||<   , |S Nr   r   r   )nextr  r   r   r  r   r   r"  )r   r*   rg   r  s       r/   r  zCSVReader.next  s^    dkk"A"$V, 54!$	2 $G 4F1I5 r1   N)r   r   r   r   r  r  __next__rD   r1   r/   r  r  x  s    	? Hr1   r  c                       e Zd Zd Zd Zy)	CSVWriterc                     t        |d      | _        t        j                  | j                  fi | j                  | _        y )Nr  )r  r   r  writerr  )r   r  r  s      r/   r   zCSVWriter.__init__  s-    C(jj>>r1   c                     t         j                  d   dk  r=g }|D ]4  }t        |t              r|j	                  d      }|j                  |       6 |}| j                  j                  |       y r  )r   r   r   r   r,  r$   r  writerow)r   rowr  r  s       r/   r  zCSVWriter.writerow  se    A"A dI.;;w/D CS!r1   N)r   r   r   r   r  rD   r1   r/   r  r    s    ?"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incc                 f    t         t        |   |       |xs t        j                         | _        y r   )superr  r   rq   r   r|   )r   configr|   	__class__s      r/   r   zConfigurator.__init__  s$    lD*62'BIIK	r1   c                      fd|j                  d      }t        |      s j                  |      }|j                  dd       }|j                  dd      }|rt        |D cg c]
  } |       c}      }|D cg c]  }t	        |      s| ||         f }}t        |      } ||i |}	|r+|j                         D ]  \  }
}t        |	|
 |              |	S c c}w c c}w )Nc                 .   t        | t        t        f      r' t        |       | D cg c]
  } |       c}      }|S t        | t              r0d| v rj                  |       }|S i }| D ]  } | |         ||<    |S j                  |       }|S c c}w N())r   rY  r  typedictconfigure_customconvert)org   r*   r   r  r   s       r/   r  z.Configurator.configure_custom.<locals>.convert  s    !dE]+ aa!8'!*!89 M At$19!2215F M  F 2$+AaDMq	2 M aM "9s   Br  re  z[]rD   )rw   ry  rk  r  r   r  r   setattr)r   r  r   propsr  r  r   r   r  r*   r  rS   r  s   `           @r/   r  zConfigurator.configure_custom  s    	 JJt{QA

3%zz$#d3'!*34D28KQKN!WVAY'(KKeD#F# /171:./ 4Ks   %C#?C(C(c                     | j                   |   }t        |t              r$d|v r | j                  |      x| j                   |<   }|S r  )r  r   r  r  )r   r   r*   s      r/   __getitem__zConfigurator.__getitem__  sC    S!fd#(,(=(=f(EEDKKvr1   c                    t         j                  j                  |      s*t         j                  j                  | j                  |      }t        j                  |dd      5 }t        j                  |      }ddd       |S # 1 sw Y   S xY w)z*Default converter for the inc:// protocol.r  r   r   N)	rq   rr   isabsr&   r|   r   r#  r   r   )r   r   r)  r*   s       r/   r  zConfigurator.inc_convert  sc    ww}}U#GGLLE2E[[g6 	"!YYq\F	"	"s   "BBr   )r   r   r   r  r   value_convertersr   r  r  r  __classcell__)r  s   @r/   r  r    s5    ,==>+U(@r1   r  c                   $    e Zd ZdZddZd Zd Zy)SubprocessMixinzC
    Mixin for running subprocesses and capturing their output
    Nc                      || _         || _        y r   )verboseprogress)r   r	  r
  s      r/   r   zSubprocessMixin.__init__  s     r1   c                 r   | j                   }| j                  }	 |j                         }|sn{|
 |||       nn|s t        j                  j                  d       n.t        j                  j                  |j                  d             t        j                  j                          |j                          y)z
        Read lines from a subprocess' output stream and either pass to a progress
        callable (if specified) or write progress information to sys.stderr.
        Nre  r   )	r
  r	  readliner   stderrr   r"  flushr   )r   r   r  r
  r	  r.   s         r/   r  zSubprocessMixin.reader  s    
 ==,,!A#G$JJ$$S)JJ$$QXXg%67

  "  	r1   c                 Z   t        j                  |ft         j                  t         j                  d|}t        j                  | j
                  |j                  df      }|j                          t        j                  | j
                  |j                  df      }|j                          |j                          |j                          |j                          | j                  | j                  dd       |S | j                  rt        j                  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 '$.OO$.OO'  &' T[[(7KL

T[[(7KL

	
	
	==$MM'6*  \\JJY'r1   )FN)r   r   r   r  r   r  r  rD   r1   r/   r  r    s    !*r1   r  c                 L    t        j                  dd|       j                         S )z,Normalize a python package name a la PEP 503z[-_.]+r  )r  subr   )rX   s    r/   normalize_namer    s      66(C&,,..r1   c                   (    e Zd ZdZdZddZd Zd Zy)
PyPIRCFilezhttps://upload.pypi.org/legacy/pypiNc                     |=t         j                  j                  t         j                  j                  d      d      }|| _        || _        y )Nr  z.pypirc)rq   rr   r&   r  r  r[   )r   r  r[   s      r/   r   zPyPIRCFile.__init__(  s8    :bgg005yABr1   c                    i }t         j                  j                  | j                        r| j                  xs | j
                  }t        j                         }|j                  | j                         |j                         }d|v r|j                  dd      }|j                  d      D cg c]%  }|j                         dk7  r|j                         ' }}|g k(  r	d|v rdg}|S |D ]  }d|i}|j                  |d      |d<   d| j
                  fd	| j                  fd
fD ]2  \  }}	|j                  ||      r|j                  ||      ||<   .|	||<   4 |dk(  r || j
                  dfv r| j
                  |d<   |d   |k7  s|d   |k7  si } |S d|v red}|j                  |d      r|j                  |d      }n| j
                  }|j                  |d      |j                  |d      ||| j                  d}|S c c}w )N	distutilszindex-serversr  r   r!  serverr  
repositoryrealm)r  Nzserver-loginr  )r  r  r&  r%  r'  )rq   rr   r	  r  r[   DEFAULT_REPOSITORYr   RawConfigParserr   r   r  r   r]   DEFAULT_REALM
has_option)
r   r*   r&  r  r   index_serversr%  _serversr   r   s
             r/   r   zPyPIRCFile.read.  s8   77>>$--(<T%<%<J!113FKK&(Hh& &

; H1>1D1DT1J'-||~+ LLN  r>)$*8N K #+ ("*F!3-3ZZ
-Kz* /;.2.E.E.G.5t7I7I-J-?-A 6LC  &00=.4jj.Es.5s6 #f,$($;$;V#D2E373J3JF<0$X.*<"("6*"D%'F-(J   8+'$$V\:!'FL!AJ!%!8!8J &

6: > &

6: >",$!// ]s   0*Hc                 Z   t        j                         }| j                  }|j                  |       |j	                  d      s|j                  d       |j                  dd|       |j                  dd|       t        |d      5 }|j                  |       d d d        y # 1 sw Y   y xY w)Nr!  r  r  r  )	r   r)  r  r   has_sectionr   r   r#  r   )r   r  r  r  r  r)  s         r/   rZ  zPyPIRCFile.updatej  s    --/]]B!!&)v&

6:x0

6:x0"c] 	aLLO	 	 	s   B!!B*NN)r   r   r   r(  r*  r   r   rZ  rD   r1   r/   r   r   #  s    :M:x
r1   r   c                 J    t        | j                        j                         S )zG
    Read the PyPI access configuration as supported by distutils.
    )r[   )r   r[   r   r  s    r/   _load_pypircr3  w  s     %))$))++r1   c                 `    t               j                  | j                  | j                         y r   )r   rZ  r  r  r2  s    r/   _store_pypircr5  ~  s    L7r1   c                     t         j                  dk(  rsdt        j                  j	                         v rydt        j                  j	                         v rydt        j                  j	                         v ryt        j
                  S dt         j                  v rt         j                  d   S t         j                  d	k7  st        t         d
      st        j
                  S t        j                         \  } }}}}| j	                         j                  dd      } |j                  dd      j                  dd      }| dd dk(  r| d|S | dd dk(  rB|d   dk\  rd} 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(  rJd!} t        j                  d"t        j                         }|j#                  |      }|rJ|j%                         }n9| dd  d#k(  r1ddl}		 dd$lm}
 |	j/                  |
j1                         | ||      \  } }}| d|d|S # t,        $ r ddl}
Y ?w xY w)%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_PLATFORMr/  unamerp   r   rV   ri   r  N   linuxsunosr   5solarisz%d.%sr      32bit64bit)il    z.%saix)aix_platform   cygwinz[\d.]+darwin)	sysconfig)rq   rX   r   r  r   platformr  r   r;  r#   intmaxsize_aix_supportrE  r  rB  ASCIIr   r   _osx_supportr$  rI  ImportErrorget_platform_osxget_config_vars)osnamer  releaser  machinebitnessrE  rel_rer)   rO  rI  s              r/   get_host_platformrX    s3   ( 
ww$ckk''))ckk''))))++|| "**,zz122	ww'W!5 || 13
-VT7GW \\^##C,Fooc3'//S9GbqzW !'**	w	1:FWQZ1!4gabk BBG $+IGuws{{333G	u	-~	x	Irxx0LL!ggiG	x		+ $0#@#@%%''$C   '22  		s   H> >IIwin32r8  r9  )x86x64armc                      t         j                  dk7  r
t               S t         j                  j	                  d      } | t
        vr
t               S t
        |    S )Nr  VSCMD_ARG_TGT_ARCH)rq   rX   rX  r  r  _TARGET_TO_PLAT)cross_compilation_targets    r/   get_platformra    sG    	ww$ ""!zz~~.BC6 ""344r1   r0  )   r   r`  )r   collectionsr   
contextlibr  globr   r}  r=  r   loggingrq   r@  r  r   r  rP  r  r   r+  r   r   r  dummy_threadingrW  r   r   compatr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   	getLoggerr   r  rB  r   rP   rO   r:   rC   r?   r`   r%   rF   rl   r   r   r   r   r   r   r   contextmanagerr   r   r   r   r   r   r   rk  rm  VERBOSErz  r   r  r  r  r  r  r  Ir  r  r  r  r  r  r  r  r  r  r  r  r  ARCHIVE_EXTENSIONSr;  rE  rq  rL  r|  rv  rw  rx  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r3  r5  rX  r_  ra  rD   r1   r/   <module>rn     s+  
    
 # 	   	  	   
   (  ( ( ( ( ( ( 
		8	$ RZZ)*
RZZ 34 RZZ56
BJJDE	RZZbjjBJJ{#	rzzEFX!vB%J4$ ,^&     & &f   6~6 ~B& 8 2:: ::	'>&(R"& &2::tt  ,-4 "** 9 :/ 8* D #)F )XD DTG! G!\ AH$ 	&W+v W+| BJJ~&	"

#?@  bjj!56 8 + + '11  D '  V(< (#	## # '	// '$<)'' <2$f  6" ",5# 5p.f .b/"Q Qh,8Q3j 5a>  
C  ('(s#   M5 N 5N ?N 	NN