a Ra@sddlZddlmZddlZddlZddlmZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZz ddlZWneydZYn0ddlZddlZddlZddlZddlZz ddlZWneyddlZYn0ddlZddlmZddlmZmZmZmZm 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/m0Z0e 1e2Z3e 4dZ5e 4dZ6e 4d Z7e 4d Z8e 4d Z9e 4d Z:e 4d Z;e 4dZddZ?ddZ@ddZAdddZBddZCddZDdd ZEejFd!d"ZGejFd#d$ZHejFdd&d'ZIGd(d)d)eJZKd*d+ZLGd,d-d-eJZMd.d/ZNGd0d1d1eJZOe 4d2e jPZQd3d4ZRdd5d6ZSd7d8ZTd9d:ZUd;d<ZVd=d>ZWd?d@ZXe 4dAe jYZZe 4dBZ[ddCdDZ\e 4dEZ]dFdGZ^dHdIZ_dJdKZ`dLZadMdNZbdOdPZcGdQdRdReJZdGdSdTdTeJZeGdUdVdVeJZfdWZgddYdZZhd[d\Zid]ZjGd^d_d_eJZke 4d`Zle 4daZme 4dbZndcddZdedfZoerddglmpZqmrZrmsZsGdhdidie$jtZtGdjdkdkeqZpGdldmdmepe'ZuejvddnZwewdokrGdpdqdqe$jxZxerGdrdsdse$jyZyGdtdudue%jzZzer>Gdvdwdwe%j{Z{Gdxdydye%j|Z|dzd{Z}Gd|d}d}eJZ~Gd~dde~ZGddde~ZGddde(ZGdddeJZddZGdddeJZddZddZddZddddZddZdS)N)deque)iglob)DistlibException) string_types text_typeshutil raw_inputStringIOcache_from_sourceurlopenurljoinhttplib xmlrpclib splittype HTTPHandlerBaseConfigurator valid_ident Container configparserURLErrorZipFilefsdecodeunquoteurlparsez^([\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\.{}()*+#:;,/?!~`@$%^&=|<>\[\]-]+)cs6ddfddfddfdd|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). cSs.t|}|r,|d}||d}n|s:tdn|d}|dvrVtd|d|d}|dd}|g}|r|d|krqqt|d|kr|||dd}qtt|}|std|||d||d}qtd|}td|||d|}|dd }||fS) Nrzunexpected end of inputz'"zinvalid expression: %srzerror in string literal: %szunterminated string: %s) IDENTIFIERmatchgroupsend SyntaxErrorreplaceappend STRING_CHUNKjoinlstrip) remainingmresultqZoqpartssr,I/opt/alt/python39/lib/python3.9/site-packages/pip/_vendor/distlib/util.py marker_varAs:               z parse_marker..marker_varcs|rR|ddkrR|dd\}}|ddkr@td||dd}nZ|\}}|rt|}|srq|d}||d}|\}}|||d}q^|}||fS)Nr(r)unterminated parenthesis: %soplhsrhs)r%r MARKER_OPrrr)r&r(r4r'r3r5)markerr.r,r- marker_expres       z!parse_marker..marker_exprcsR|\}}|rJt|}|s qJ||d}|\}}d||d}q ||fS)Nandr2)ANDrrr&r4r'r5)r8r,r- marker_andxs   z parse_marker..marker_andcsR|\}}|rJt|}|s qJ||d}|\}}d||d}q ||fS)Norr2)ORrrr;)r<r,r-r7s   zparse_marker..markerr,)Z marker_stringr,)r7r<r8r.r- parse_marker8s $ r?cCs0|}|r|drdSt|}|s4td||d}||d}d}}}}|r:|ddkr:|dd}|dkrtd||d|} ||dd}g}| r0t| }|std | | |d| |d} | sq0| dd krtd | | dd} q|s:d}|r|dd kr|dd}t |}|sztd ||d}t |} | j r| j std|||d}ndd} |ddkr| |\}}n|dd}|dkrtd||d|} ||dd}t| r@| | \}} nXt| }|s\td| |d} | |d} | rtd| d| fg}|r|ddkrtd||dd}t|\}}|r|ddkrtd||s|}nd|ddd|Df}t||||||dS)z Parse a requirement passed in as a string. Return a Container whose attributes contain the various parts of the requirement. #Nzname expected: %sr[]rzunterminated extra: %szmalformed extra: %s,zcomma expected in extras: %s@zinvalid URI: %szInvalid URL: %scSst|}d}|rg}|d}||d}t|}|sLtd||d}|||f||d}|r|ddkrq|dd}|sqt|}|std|q|sd}||fS)z| Return a list of operator, version tuples if any are specified, else None. Nrzinvalid version: %srCrinvalid constraint: %s) COMPARE_OPrrrVERSION_IDENTIFIERr r"r%)Z ver_remainingr'versionsr3vr,r,r- get_versionss.      z'parse_requirement..get_versionsr/r0r1rEz~=;zinvalid requirement: %szunexpected trailing data: %s%s %s, cSsg|] }d|qS)rLr,).0Zconr,r,r- z%parse_requirement..)nameextras constraintsr7urlZ requirement)strip startswithrrr rrfindr%r" NON_SPACErschemenetlocrFrGr?r$r)reqr&r'ZdistnamerRZ mark_exprrHuriir+trJ_rIZrsr,r,r-parse_requirements                           r`cCsdd}i}|D]\}}}tj||}t|D]p}tj||} t| D]T} ||| } |durn|| dqJ||| } |tjjdd} | d| || <qJq0q|S)z%Find destinations for resources filescSsD|tjjd}|tjjd}||s.J|t|ddSN/)r!ospathseprVlenr%)rootrdr,r,r- get_rel_pathsz)get_resources_dests..get_rel_pathNrb)rcrdr$rpopr!rerstrip)Zresources_rootZrulesrhZ destinationsbasesuffixdestprefixZabs_baseZabs_globZabs_pathZ resource_fileZrel_pathZrel_destr,r,r-get_resources_destss    rocCs(ttdrd}ntjttdtjk}|S)NZ real_prefixT base_prefix)hasattrsysrngetattrr(r,r,r-in_venv(s rucCstj}t|tst|}|SN)rr executable isinstancerrrtr,r,r-get_executable2s  rycCsN|}t|}|}|s|r|}|r|d}||vr6qJ|rd|||f}q|S)Nrz %c: %s %s)r lower)promptZ allowed_charsZ error_promptdefaultpr+cr,r,r-proceedDs rcCs8t|tr|}i}|D]}||vr||||<q|Srv)rxrsplit)dkeysr(keyr,r,r-extract_by_keyTs rcCsvtjddkrtd|}|}t|}zlt|}|ddd}|D]B\}}|D]0\}}d||f}t |} | dusJ| ||<q`qP|WSt y| ddYn0dd } t } z| | |Wn:t jy|t|}t|}| | |Yn0i}| D]R} i|| <}| | D]4\} }d| |f}t |} | dusbJ| || <q8q|S) Nrutf-8 extensionszpython.exportsexportsz%s = %scSs$t|dr||n ||dS)N read_file)rqrZreadfp)cpstreamr,r,r- read_streamqs  z!read_exports..read_stream)rr version_infocodecs getreaderreadr jsonloaditemsget_export_entry Exceptionseekr ConfigParserZMissingSectionHeaderErrorclosetextwrapdedentsections)rdataZjdatar(groupentrieskrIr+entryrrrrQvaluer,r,r- read_exports]sD         rcCstjddkrtd|}t}|D]l\}}|||D]P}|j dur\|j }nd|j |j f}|j rd|d |j f}| ||j|qFq,||dS)Nrrrz%s:%sz%s [%s]rM)rrrr getwriterrrr add_sectionvaluesrlrnflagsr$setrQwrite)rrrrrIrr+r,r,r- write_exportss   rc cs.t}z|VWt|n t|0dSrv)tempfilemkdtemprrmtree)Ztdr,r,r-tempdirsrc cs8t}zt|dVWt|n t|0dSrv)rcgetcwdchdir)rcwdr,r,r-rs  rc cs8t}zt|dVWt|n t|0dSrv)socketZgetdefaulttimeoutZsetdefaulttimeout)ZsecondsZctor,r,r-socket_timeouts  rc@seZdZddZdddZdS)cached_propertycCs ||_dSrv)func)selfrr,r,r-__init__szcached_property.__init__NcCs,|dur |S||}t||jj||Srv)robject __setattr____name__)robjclsrr,r,r-__get__s  zcached_property.__get__)N)r __module__ __qualname__rrr,r,r,r-rsrcCs~tjdkr|S|s|S|ddkr.td||ddkrFtd||d}tj|vrh|tjqP|srtjStjj|S)aReturn '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. rbrzpath '%s' cannot be absolutezpath '%s' cannot end with '/')rcre ValueErrorrcurdirremoverdr$)pathnamepathsr,r,r- convert_paths       rc@seZdZd$ddZddZddZdd Zd%d d Zd&ddZddZ ddZ ddZ ddZ ddZ d'ddZddZddZd d!Zd"d#Zd S)( FileOperatorFcCs||_t|_|dSrv)dry_runrensured _init_record)rrr,r,r-rszFileOperator.__init__cCsd|_t|_t|_dSNF)recordr files_written dirs_createdrr,r,r-rszFileOperator._init_recordcCs|jr|j|dSrv)rradd)rrdr,r,r-record_as_writtenszFileOperator.record_as_writtencCsHtj|s tdtj|tj|s0dSt|jt|jkS)aTell 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". zfile '%r' does not existT)rcrdexistsrabspathstatst_mtime)rsourcetargetr,r,r-newers   zFileOperator.newerTcCs|tj|td|||jsd}|rdtj|rDd|}n tj|rdtj |sdd|}|rtt |dt ||| |dS)z8Copy a file respecting dry-run and force flags. zCopying %s to %sNz%s is a symlinkz%s is a non-regular filez which would be overwritten) ensure_dirrcrddirnameloggerinforislinkrisfilerrZcopyfiler)rZinfileoutfilecheckmsgr,r,r- copy_files    zFileOperator.copy_fileNcCstj|rJ|tj|td|||js~|durJt|d}nt j|d|d}zt ||W| n | 0| |dS)NzCopying stream %s to %swbwencoding)rcrdisdirrrrrropenrrZ copyfileobjrr)rZinstreamrrZ outstreamr,r,r- copy_streams zFileOperator.copy_streamcCsp|tj||jsbtj|r.t|t|d}||Wdn1sX0Y| |dS)Nr) rrcrdrrrrrrr)rrdrfr,r,r-write_binary_file's   (zFileOperator.write_binary_filecCs||||dSrv)rencode)rrdrrr,r,r-write_text_file0szFileOperator.write_text_filecCsntjdkstjdkrjtjdkrj|D]F}|jr:td|q"t|j|B|@}td||t||q"dS)Nposixjavazchanging mode of %szchanging mode of %s to %o) rcrQ_namerrrrst_modechmod)rbitsmaskfilesrmoder,r,r-set_mode3szFileOperator.set_modecCs|dd|S)Nimi)r)r+rr,r,r-?rPzFileOperator.cCs|tj|}||jvrxtj|sx|j|tj|\}}||t d||j sft ||j rx|j |dS)Nz Creating %s)rcrdrrrrrrrrrmkdirrr)rrdrrr,r,r-rAs    zFileOperator.ensure_dirc Cst|| }td|||js|s0|||rX|s:d}n||sHJ|t|d}i}|rvttdrvtj j |d<tj |||dfi|| ||S)NzByte-compiling %s to %sPycInvalidationModeinvalidation_modeT) r rrrrrVrfrq py_compiler CHECKED_HASHcompiler) rrdoptimizeforcernZhashed_invalidationZdpathZdiagpathZcompile_kwargsr,r,r- byte_compileMs   zFileOperator.byte_compilecCstj|rtj|r^tj|s^td||js@t ||j r||j vr|j |nPtj|rpd}nd}td|||jst ||j r||j vr|j |dS)NzRemoving directory tree at %slinkfilezRemoving %s %s)rcrdrrrrdebugrrrrrrr)rrdr+r,r,r-ensure_removed^s"       zFileOperator.ensure_removedcCsDd}|s@tj|r$t|tj}q@tj|}||kr:q@|}q|Sr)rcrdraccessW_OKr)rrdr(parentr,r,r- is_writabless  zFileOperator.is_writablecCs"|js J|j|jf}||S)zV Commit recorded changes, turn off recording, return changes. )rrrr)rr(r,r,r-commits  zFileOperator.commitcCs|jst|jD]}tj|rt|qt|jdd}|D]F}t |}|rz|dgks^Jtj ||d}t |t |q>| dS)NT)reverse __pycache__r) rlistrrcrdrrsortedrlistdirr$rmdirr)rrdirsrflistsdr,r,r-rollbacks     zFileOperator.rollback)F)T)N)FFNF)rrrrrrrrrrrrZset_executable_moderrrr r rr,r,r,r-rs         rcCs^|tjvrtj|}nt|}|dur,|}n.|d}t||d}|D]}t||}qJ|S)N.r)rrmodules __import__rrsri)Z module_nameZ dotted_pathmodr(r*r}r,r,r-resolves    rc@s6eZdZddZeddZddZddZej Z d S) ExportEntrycCs||_||_||_||_dSrvrQrnrlr)rrQrnrlrr,r,r-rszExportEntry.__init__cCst|j|jSrv)rrnrlrr,r,r-rszExportEntry.valuecCsd|j|j|j|jfS)Nzrrr,r,r-__repr__s zExportEntry.__repr__cCsDt|tsd}n0|j|jko>|j|jko>|j|jko>|j|jk}|Sr)rxrrQrnrlr)rotherr(r,r,r-__eq__s     zExportEntry.__eq__N) rrrrrrrrr__hash__r,r,r,r-rs   rz(?P(\w|[-.+])+) \s*=\s*(?P(\w+)([:\.]\w+)*) \s*(\[\s*(?P[\w-]+(=\w+)?(,\s*\w+(=\w+)?)*)\s*\])? c Cst|}|s0d}d|vs"d|vrtd|n|}|d}|d}|d}|dkrf|d}}n"|dkrztd||d\}}|d } | durd|vsd|vrtd|g} nd d | d D} t|||| }|S) NrArBzInvalid specification '%s'rQcallable:rrrcSsg|] }|qSr,rU)rNrr,r,r-rOrPz$get_export_entry..rC)ENTRY_REsearchr groupdictcountrr) Z specificationr'r(rrQrdZcolonsrnrlrr,r,r-rs8   rcCs|dur d}tjdkr.dtjvr.tjd}n tjd}tj|rft|tj}|st d|n:zt |d}Wn&t yt j d |dd d }Yn0|st }t d |tj||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.distlibntZ LOCALAPPDATAz $localappdata~z(Directory exists but is not writable: %sTzUnable to create %s)exc_infoFz#Default location unusable, using %s)rcrQenvironrd expandvars expanduserrrrrwarningmakedirsOSErrorrrr$)rlr(Zusabler,r,r-get_cache_bases&      r0cCsBtjtj|\}}|r(|dd}|tjd}||dS)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)rcrd splitdriverr!re)rdrr}r,r,r-path_to_cache_dirs  r2cCs|ds|dS|Sra)endswith)r+r,r,r- ensure_slash$s r4cCs`d}}d|vr>|dd\}}d|vr.|}n|dd\}}|rJt|}|rVt|}|||fS)NrDrr!)rsplitrr)rZusernamepasswordrnr,r,r-parse_credentials*sr8cCstd}t||S)N)rcumaskrtr,r,r-get_process_umask9s  r;cCs<d}d}t|D]\}}t|tsd}q,q|dus8J|S)NTF) enumeraterxr)seqr(r]r+r,r,r-is_string_sequence>s  r>z3([a-z0-9_]+([.-][a-z_][a-z0-9_]*)*)-([a-z0-9_.+-]+)z -py(\d\.?\d?)cCsd}d}t|dd}t|}|r@|d}|d|}|rt|t|dkrtt |d|}|r| }|d|||dd|f}|durt |}|r|d|d|f}|S)zw Extract name, version, python version from a filename (no extension) Return name, version, pyver or None N -rz\br) rr!PYTHON_VERSIONr$rstartrfrerescaperPROJECT_NAME_AND_VERSION)filenameZ project_namer(Zpyverr'nr,r,r-split_filenameMs"   rHz-(?P[\w .-]+)\s*\(\s*(?P[^\s)]+)\)$cCs:t|}|std||}|d|dfS)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'rQZver)NAME_VERSION_RErrr%rUrz)r}r'rr,r,r-parse_name_and_versionis  rJcCst}t|pg}t|pg}d|vr8|d||O}|D]x}|dkrT||q<|dr|dd}||vrtd|||vr||q<||vrtd|||q<|S)N*r@rzundeclared extra: %s)rrrrVrr-)Z requestedZ availabler(rZunwantedr,r,r- get_extrasxs&        rMc Csi}zNt|}|}|d}|ds8td|ntd|}t |}Wn2t y}zt d||WYd}~n d}~00|S)Nz Content-Typezapplication/jsonz(Unexpected response for JSON request: %srz&Failed to get external data for %s: %s) r rgetrVrrrrrrr exception)rTr(ZrespZheadersZctreaderer,r,r-_get_external_datas  $rRz'https://www.red-dove.com/pypi/projects/cCs*d|d|f}tt|}t|}|S)Nz%s/%s/project.jsonrupperr _external_data_base_urlrR)rQrTr(r,r,r-get_project_datas rVcCs(d|d||f}tt|}t|S)Nz%s/%s/package-%s.jsonrrS)rQversionrTr,r,r-get_package_datas rXc@s(eZdZdZddZddZddZdS) 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. cCsPtj|st|t|jd@dkr6td|tjtj ||_ dS)zu Initialise an instance. :param base: The base directory where the cache should be located. ?rzDirectory '%s' is not privateN) rcrdrr.rrrr-rnormpathrk)rrkr,r,r-rs    zCache.__init__cCst|S)zN Converts a resource prefix to a directory name in the cache. )r2)rrnr,r,r- prefix_to_dirszCache.prefix_to_dirc Csg}t|jD]p}tj|j|}z>tj|s>tj|rJt|ntj|r`t |Wqt y~| |Yq0q|S)z" Clear the cache. ) rcrrkrdr$rrrrrrrr")rZ not_removedfnr,r,r-clears   z Cache.clearN)rrr__doc__rr\r^r,r,r,r-rYsrYc@s:eZdZdZddZdddZddZd d Zd d Zd S) EventMixinz1 A very simple publish/subscribe system. cCs i|_dSrv) _subscribersrr,r,r-rszEventMixin.__init__TcCsD|j}||vrt|g||<n"||}|r6||n ||dS)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)rarr" appendleft)revent subscriberr"subsZsqr,r,r-rs  zEventMixin.addcCs,|j}||vrtd||||dS)z Remove a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be removed. zNo subscribers: %rN)rarr)rrcrdrer,r,r-rs zEventMixin.removecCst|j|dS)z Return an iterator for the subscribers for an event. :param event: The event to return subscribers for. r,)iterrarN)rrcr,r,r-get_subscribersszEventMixin.get_subscribersc Ospg}||D]J}z||g|Ri|}Wn tyLtdd}Yn0||qtd|||||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)rgrrrOr"r)rrcargskwargsr(rdrr,r,r-publish s     zEventMixin.publishN)T) rrrr_rrrrgrjr,r,r,r-r`s   r`c@s^eZdZddZddZdddZdd Zd d Zd d ZddZ e ddZ e ddZ dS) SequencercCsi|_i|_t|_dSrv)_preds_succsr_nodesrr,r,r-r(szSequencer.__init__cCs|j|dSrv)rnrrnoder,r,r-add_node-szSequencer.add_nodeFcCs||jvr|j||rt|j|dD]}|||q,t|j|dD]}|||qPt|jD]\}}|sp|j|=qpt|jD]\}}|s|j|=qdS)Nr,)rnrrrlrNrmr r)rrpZedgesr}r+rrIr,r,r- remove_node0s   zSequencer.remove_nodecCs<||ks J|j|t||j|t|dSrv)rl setdefaultrrrm)rpredsuccr,r,r-r@s z Sequencer.addcCs||ks Jz|j|}|j|}WntyBtd|Yn0z||||Wn"ty~td||fYn0dS)Nz%r not a successor of anythingz%r not a successor of %r)rlrmKeyErrorrr)rrtrupredsZsuccsr,r,r-rEs     zSequencer.removecCs||jvp||jvp||jvSrv)rlrmrn)rstepr,r,r-is_stepRszSequencer.is_stepcCs||std|g}g}t}|||r|d}||vrb||kr||||q.|||||j|d}| |q.t |S)Nz Unknown: %rrr,) ryrrr"rirrrlrNextendreversed)rfinalr(Ztodoseenrxrwr,r,r- get_stepsVs"         zSequencer.get_stepscsRdggiig|jfddD]}|vr8|q8S)Nrcsd|<d|<dd7<|z |}WntyTg}Yn0|D]J}|vr|t|||<qZ|vrZt|||<qZ||krg}}||||krqqt|}|dS)Nrr)r"rminrituple)rpZ successors successorZconnected_componentZ componentZgraphindexZ index_counterZlowlinksr(stack strongconnectr,r-rzs*        z3Sequencer.strong_connections..strongconnect)rmror,rr-strong_connectionsos" zSequencer.strong_connectionscCsfdg}|jD]*}|j|}|D]}|d||fqq |jD]}|d|q>|dd|S)Nz digraph G {z %s -> %s;z %s;} )rlr"rnr$)rr(rurwrtrpr,r,r-dots    z Sequencer.dotN)F) rrrrrqrrrrryr~propertyrrr,r,r,r-rk's   2rk).tar.gz.tar.bz2.tar.zip.tgz.tbz.whlTc sZfdd}tjtd}|dur|dr>d}nH|drRd}d}n4|drfd }d }n |d rzd }d }n td|z|dkrt|d }|r|}|D] }||qn*t ||}|r| }|D] }||q|dkr*t j ddkr*| D]"} t| jts| jd| _q|W|rV|n|rT|0dS)NcsRt|ts|d}tjtj|}|rB|tjkrNt d|dS)Nrzpath outside destination: %r) rxrdecodercrdrr$rVrer)rdr}dest_dirZplenr,r- check_paths   zunarchive..check_path)rrzip)rrZtgzzr:gz)rrZtbzzr:bz2rZtarrLzUnknown format for %rrrr)rcrdrrfr3rrZnamelisttarfilerZgetnamesrrrZ getmembersrxrQrrZ extractallr) Zarchive_filenamerformatrrarchivernamesrQZtarinfor,rr- unarchivesL             rc Cst}t|}t|dd}t|D]H\}}}|D]8}tj||}||d} tj| |} ||| q4q&Wdn1s0Y|S)z*zip a directory tree into a BytesIO objectrN) ioBytesIOrfrrcwalkrdr$r) Z directoryr(ZdlenZzfrgrrrQZfullrelrmr,r,r-zip_dirs  .r)rKMGTPc@sreZdZdZdddZddZdd Zd d Zd d Ze ddZ e ddZ ddZ e ddZ e ddZdS)ProgressZUNKNOWNrdcCs<|dus||ksJ||_|_||_d|_d|_d|_dS)NrF)rcurmaxstartedelapseddone)rZminvalZmaxvalr,r,r-rs  zProgress.__init__cCsV|j|ksJ|jdus&||jks&J||_t}|jdurF||_n ||j|_dSrv)rrrtimerr)rZcurvalZnowr,r,r-update s zProgress.updatecCs |dks J||j|dSNr)rr)rZincrr,r,r- increments zProgress.incrementcCs||j|Srv)rrrr,r,r-rBs zProgress.startcCs |jdur||jd|_dS)NT)rrrrr,r,r-stops  z Progress.stopcCs|jdur|jS|jSrv)runknownrr,r,r-maximum!szProgress.maximumcCsD|jr d}n4|jdurd}n$d|j|j|j|j}d|}|S)Nz100 %z ?? %gY@z%3d %%)rrrr)rr(rIr,r,r- percentage%s zProgress.percentagecCs:|dkr|jdus|j|jkr$d}ntdt|}|S)Nrz??:??:??z%H:%M:%S)rrrrstrftimegmtime)rZdurationr(r,r,r-format_duration0szProgress.format_durationcCs|jrd}|j}n^d}|jdur&d}nJ|jdks<|j|jkrBd}n.t|j|j}||j|j}|d|j}d|||fS)NZDonezETA rrrz%s: %s)rrrrrfloatr)rrnr^r,r,r-ETA9s z Progress.ETAcCsL|jdkrd}n|j|j|j}tD]}|dkr6q@|d}q&d||fS)Nrgig@@z%d %sB/s)rrrUNITS)rr(Zunitr,r,r-speedLs  zProgress.speedN)rr)rrrrrrrrBrrrrrrrr,r,r,r-rs      rz \{([^}]*)\}z[^/\\,{]\*\*|\*\*[^/\\,}]z^[^{]*\}|\{[^}]*$cCs<t|rd}t||t|r4d}t||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_globrr,r,r-ras    rc cst|d}t|dkrht|dks,J||\}}}|dD]$}td|||fD] }|VqXq@nd|vrt|D] }|Vqxn~|dd\}}|dkrd}|dkrd}n|d}|d }t|D]4\}}} tj |}ttj ||D] } | VqqdS) NrrrCrz**rrKrb\) RICH_GLOBrrfrr$ std_iglobr%rcrrdr[) rZrich_path_globrnrrlitemrdZradicaldirrr]r,r,r-rls*         r) HTTPSHandlermatch_hostnameCertificateErrorc@seZdZdZdZddZdS)HTTPSConnectionNTcCs^t|j|jf|j}t|ddr0||_|tt dsp|j rHt j }nt j }t j ||j|j|t j|j d|_nt t j}tt dr|jt jO_|jr||j|ji}|j rt j |_|j|j dtt ddr|j|d<|j |fi||_|j rZ|jrZz$t|j|jtd |jWn.tyX|jtj|jYn0dS) NZ _tunnel_hostF SSLContext) cert_reqsZ ssl_versionca_certs OP_NO_SSLv2)ZcafileZHAS_SNIZserver_hostnamezHost verified: %s) rZcreate_connectionhostporttimeoutrssockZ_tunnelrqsslrZ CERT_REQUIREDZ CERT_NONEZ wrap_socketZkey_fileZ cert_fileZPROTOCOL_SSLv23roptionsrZload_cert_chainZ verify_modeZload_verify_locations check_domainrZ getpeercertrrrZshutdownZ SHUT_RDWRr)rrrcontextrir,r,r-connectsB        zHTTPSConnection.connect)rrrrrrr,r,r,r-rsrc@s&eZdZd ddZddZddZdS) rTcCst|||_||_dSrv)BaseHTTPSHandlerrrr)rrrr,r,r-rs zHTTPSHandler.__init__cOs(t|i|}|jr$|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. )rrr)rrhrir(r,r,r- _conn_makers zHTTPSHandler._conn_makerc CsZz||j|WStyT}z,dt|jvr>td|jnWYd}~n d}~00dS)Nzcertificate verify failedz*Unable to verify server certificate for %s)Zdo_openrrstrreasonrr)rr[rQr,r,r- https_openszHTTPSHandler.https_openN)T)rrrrrrr,r,r,r-rs rc@seZdZddZdS)HTTPSOnlyHandlercCstd|dS)NzAUnexpected HTTP request on what should be a secure connection: %s)r)rr[r,r,r- http_openszHTTPSOnlyHandler.http_openN)rrrrr,r,r,r-rsrrc@seZdZdddZdS)HTTPrNcKs*|dkr d}||j||fi|dSr_setupZ_connection_classrrrrir,r,r-rsz HTTP.__init__)rNrrrrr,r,r,r-rsrc@seZdZdddZdS)HTTPSrNcKs*|dkr d}||j||fi|dSrrrr,r,r-rszHTTPS.__init__)rNrr,r,r,r-rsrc@seZdZdddZddZdS) TransportrcCs||_tj||dSrv)rrrrrr use_datetimer,r,r-rszTransport.__init__cCs`||\}}}tdkr(t||jd}n4|jr<||jdkrR||_|t|f|_|jd}|S)Nr)rrr) get_host_info _ver_inforr _connection_extra_headersrZHTTPConnection)rrhehZx509r(r,r,r-make_connections zTransport.make_connectionN)rrrrrrr,r,r,r-rs rc@seZdZdddZddZdS) SafeTransportrcCs||_tj||dSrv)rrrrrr,r,r-rszSafeTransport.__init__cCs||\}}}|si}|j|d<tdkr>t|dfi|}n>|jrR||jdkrr||_|tj|dfi|f|_|jd}|S)Nrrrr)rrrrrrrr)rrrrrir(r,r,r-rs   zSafeTransport.make_connectionN)rrr,r,r,r-rs rc@seZdZddZdS) ServerProxycKsx|dd|_}|dur^t|d}|dd}|dkr@t}nt}|||d|d<}||_tjj ||fi|dS)Nrrrhttps)r transport) rirrrNrrrrrr)rr\rirrYrZtclsr^r,r,r-r&s  zServerProxy.__init__Nrr,r,r,r-r%srcKs:tjddkr|d7}nd|d<d|d<t||fi|S)Nrrbrnewlinerr)rrrr)r]rrir,r,r- _csv_open;s  rc@s4eZdZedededdZddZddZd S) CSVBaserC"r)Z delimiterZ quotecharZlineterminatorcCs|Srvr,rr,r,r- __enter__MszCSVBase.__enter__cGs|jdSrv)rr)rr)r,r,r-__exit__PszCSVBase.__exit__N)rrrrdefaultsrrr,r,r,r-rFs rc@s(eZdZddZddZddZeZdS) CSVReadercKs`d|vr4|d}tjddkr,td|}||_nt|dd|_tj|jfi|j|_dS)NrrrrrdrL) rrrrrrrcsvrPr)rrirr,r,r-rUszCSVReader.__init__cCs|Srvr,rr,r,r-__iter__`szCSVReader.__iter__cCsFt|j}tjddkrBt|D] \}}t|ts |d||<q |SNrrr)nextrPrrrr<rxrr)rr(r]rr,r,r-rcs   zCSVReader.nextN)rrrrrr__next__r,r,r,r-rTs rc@seZdZddZddZdS) CSVWritercKs(t|d|_tj|jfi|j|_dS)Nr)rrrwriterr)rr]rir,r,r-rns zCSVWriter.__init__cCsNtjddkr>g}|D]"}t|tr.|d}||q|}|j|dSr)rrrrxrrr"rwriterow)rrowrLrr,r,r-rrs   zCSVWriter.writerowN)rrrrrr,r,r,r-rmsrcsHeZdZeejZded<d fdd ZddZdd Zd d Z Z S) Configurator inc_convertZincNcs"tt|||pt|_dSrv)superrrrcrrk)rconfigrk __class__r,r-rszConfigurator.__init__c sfddd}t|s*|}dd}dd}|r\tfdd|D}fd dD}t|}||i|}|r|D]\}} t||| q|S) Ncsvt|ttfr*t|fdd|D}nHt|trhd|vrH|}qri}|D]}||||<qPn |}|S)Ncsg|] }|qSr,r,)rNr]convertr,r-rOrPzBConfigurator.configure_custom..convert..())rxr rtypedictconfigure_customr)or(r)rrr,r-rs   z.Configurator.configure_custom..convertrrz[]r,csg|] }|qSr,r,)rNrr r,r-rOrPz1Configurator.configure_custom..cs$g|]}t|r||fqSr,)r)rNr)r rr,r-rOrP)rir rrrrsetattr) rr r~Zpropsrhrrir(rGrIr,)r rrr-rs    zConfigurator.configure_customcCs4|j|}t|tr0d|vr0|||j|<}|S)Nr)r rxrr)rrr(r,r,r- __getitem__s zConfigurator.__getitem__cCsZtj|stj|j|}tj|ddd}t|}Wdn1sL0Y|S)z*Default converter for the inc:// protocol.rLrrN) rcrdisabsr$rkrrrr)rrrr(r,r,r-rs  (zConfigurator.inc_convert)N) rrrrrZvalue_convertersrrrr __classcell__r,r,r r-rs  rc@s*eZdZdZd ddZddZdd ZdS) SubprocessMixinzC Mixin for running subprocesses and capturing their output FNcCs||_||_dSrv)verboseprogress)rrrr,r,r-rszSubprocessMixin.__init__cCsj|j}|j}|}|sq^|dur.|||q |s@tjdntj|dtjq |dS)z Read lines from a subprocess' output stream and either pass to a progress callable (if specified) or write progress information to sys.stderr. Nrr) rrreadlinerrstderrrrflushr)rrrrrr+r,r,r-rPs  zSubprocessMixin.readercKstj|ftjtjd|}tj|j|jdfd}|tj|j|jdfd}|| | | |j dur| ddn|j rt jd|S)N)stdoutrr)rrhrzdone.mainzdone. ) subprocessPopenPIPE threadingZThreadrPrrBrwaitr$rrrrr)rcmdrir}t1t2r,r,r- run_commands"   zSubprocessMixin.run_command)FN)rrrr_rrPr(r,r,r,r-rs rcCstdd|S)z,Normalize a python package name a la PEP 503z[-_.]+r@)rCsubrz)rQr,r,r-normalize_namesr*c@s.eZdZdZdZd ddZddZdd ZdS) PyPIRCFilezhttps://upload.pypi.org/legacy/pypiNcCs.|durtjtjdd}||_||_dS)Nr(z.pypirc)rcrdr$r,rFrT)rr]rTr,r,r-rszPyPIRCFile.__init__c Csi}tj|jr||jp|j}t}||j| }d|vr*| dd}dd| dD}|gkr~d|vr|dg}n|D]}d|i}| |d|d<d |jfd |j fd fD].\}} | ||r| ||||<q| ||<q|dkr ||jdfvr |j|d <q|d|kr|d |kri}qnRd |vr|d }| |d rT| |d }n|j}| |d| |d |||j d}|S)N distutilsz index-serverscSs g|]}|dkr|qS)rr")rNserverr,r,r-rO s z#PyPIRCFile.read..rr,r.r6 repositoryrealm)r7Nz server-loginr7)r6r7r/r.r0)rcrdrrFrTDEFAULT_REPOSITORYrRawConfigParserrrrNr DEFAULT_REALMZ has_option) rr(r/r rZ index_serversZ_serversr.rr|r,r,r-rsX               zPyPIRCFile.readcCst}|j}|||ds,|d|dd||dd|t|d}||Wdn1sr0YdS)Nr,r6r7r) rr2rFrZ has_sectionrrrr)rr6r7r r]rr,r,r-r9s    zPyPIRCFile.update)NN)rrrr1r3rrrr,r,r,r-r+s  :r+cCst|jdS)zG Read the PyPI access configuration as supported by distutils. )rT)r+rTrrr,r,r- _load_pypircEsr5cCst|j|jdSrv)r+rr6r7r4r,r,r- _store_pypircKsr6c CstjdkrFdtjvrdSdtjvr.dSdtjvr@dStjSdtjvrZtjdStjd ksnttd sttjSt\}}}}}| d d }| d d d d}|dddkrd||fS|dddkr(|ddkrd}dt |dd|ddf}ddd}|d|tj 7}n|dddkrLdd l m }|S|dd!d"krd"}td#tj}||}|r|}n>|dd!d$krddl} ddl} | | j|||\}}}d%|||fS)&aReturn 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'Zamd64 win-amd64z(arm) win-arm32z(arm64)z win-arm64Z_PYTHON_HOST_PLATFORMrunamerbrr?r_r@NZlinuxz%s-%sZsunosr5Zsolarisz%d.%srrZ32bitZ64bit)ilz.%sZaix) aix_platformrcygwinz[\d.]+darwinz%s-%s-%s)rcrQrrrWrzplatformr*rqr9r!intmaxsizeZ _aix_supportr<rCrASCIIrr _osx_supportZdistutils.sysconfigZget_platform_osxZ sysconfigZget_config_vars) ZosnamerreleaserWmachineZbitnessr<Zrel_rer'rCr-r,r,r-get_host_platformSsN          rFZwin32r7r8)Zx86Zx64ZarmcCs2tjdkrtStjd}|tvr*tSt|S)Nr'ZVSCMD_ARG_TGT_ARCH)rcrQrFr*rN_TARGET_TO_PLAT)Zcross_compilation_targetr,r,r- get_platforms   rH)NN)r)N)N)NT)r collectionsr contextlibrglobrrrrZloggingrcrrCrr ImportErrorr rrrrrr#Zdummy_threadingrrrcompatrrrr r r r r rrrrrrrrrrrrrZ getLoggerrrrrrGrFr6r>r:rXr#r?r`roruryrrrrcontextmanagerrrrrrrrrrVERBOSEr#rr0r2r4r8r;r>IrErArHrIrJrMrRrUrVrXrYr`rkZARCHIVE_EXTENSIONSrrrrrrrrrrrrrrrrrrrrrrrrrrrr*r+r5r6rFrGrHr,r,r,r-s        \         Y}   /   8 )    ,H  6]    +)   7.QR