o Ec@sddlZddlmZddlZddlZddlmZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZzddlZWn eyEdZYnwddlZddlZddlZddlZddlZzddlZWn eymddlZYnwddlZddlmZddlmZmZmZmZm 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'ZuejvddnZwewdokr Gdpdqdqe$jxZxer Gdrdsdse$jyZyGdtdudue%jzZzerGdvdwdwe%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). cSs0t|}|r|d}||d}||fS|std|d}|dvr-td|d|d}|dd}|g}|rw|d|krEn=|d|krW|||dd}nt|}|sdtd|||d||d}|s>d|}td|||d|}|dd }||fS) Nrzunexpected end of inputz'"zinvalid expression: %srzerror in string literal: %szunterminated string: %s) IDENTIFIERmatchgroupsend SyntaxErrorreplaceappend STRING_CHUNKjoinlstrip) remainingmresultqZoqpartssr,K/opt/alt/python310/lib/python3.10/site-packages/pip/_vendor/distlib/util.py marker_varAs>              z parse_marker..marker_varcs|r,|ddkr,|dd\}}|ddkr td||dd}||fS|\}}|rXt|}|s.marker_exprc\|\}}|r*t|}|s ||fS||d}|\}}d||d}|s||fS)Nandr2)ANDrrr&r4r'r5)r8r,r- marker_andx    z parse_marker..marker_andcr9)Norr2)ORrrr<)r=r,r-r7r>zparse_marker..markerr,)Z marker_stringr,)r7r=r8r.r- parse_marker8s  $   rAcCs|}|r |dr dSt|}|std||d}||d}d}}}}|r|ddkr|dd}|dkrHtd||d|} ||dd}g}| rt| }|sitd | | |d| |d} | s}n| dd krtd | | dd} | s\|sd}|r@|dd kr|dd}t |}|std ||d}t |} | j r| j std|||d}njdd} |ddkr| |\}}nY|dd}|dkrtd||d|} ||dd}t| r| | \}} n,t| }|s"td| |d} | |d} | r;td| d| fg}|r^|ddkrPtd||dd}t|\}}|rn|ddkrntd||st|}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}|rbg} |d}||d}t|}|s'td||d}|||f||d}|rD|ddkrEn|dd}|sPnt|}|s]td|q |sbd}||fS)z| Return a list of operator, version tuples if any are specified, else None. NTrzinvalid version: %srErinvalid constraint: %s) COMPARE_OPrrrVERSION_IDENTIFIERr r"r%)Z ver_remainingr'versionsr3vr,r,r- get_versionss2       z'parse_requirement..get_versionsr/r0r1rGz~=;zinvalid requirement: %szunexpected trailing data: %s%s %s, cSsg|]}d|qS)rNr,).0Zconr,r,r- z%parse_requirement..)nameextrasZ constraintsr7urlZ requirement)strip startswithrrr rrfindr%r" NON_SPACErschemenetlocrHrIrAr$r)reqr&r'ZdistnamerTZ mark_exprrJuriir+trL_rKZrsr,r,r-parse_requirements                              racCsdd}i}|D]I\}}}tj||}t|D]8}tj||} t| D]*} ||| } |dur7|| dq%||| } |tjjdd} | d| || <q%qq|S)z%Find destinations for resources filescSsD|tjjd}|tjjd}||sJ|t|ddSN/)r!ospathseprWlenr%)rootrer,r,r- get_rel_pathsz)get_resources_dests..get_rel_pathNrc)rdrer$rpopr!rfrstrip)Zresources_rootZrulesriZ destinationsbasesuffixdestprefixZabs_baseZabs_globZabs_pathZ resource_fileZrel_pathZrel_destr,r,r-get_resources_destss      rpcCs*ttdr d}|Stjttdtjk}|S)NZ real_prefixT base_prefix)hasattrsysrogetattrr(r,r,r-in_venv(s rvcCstj}t|ts t|}|SN)rs executable isinstancerrrur,r,r-get_executable2s rzcCsP|} t|}|}|s|r|}|r'|d}||vr |S|r'd|||f}q)NTrz %c: %s %s)r lower)promptZ allowed_charsZ error_promptdefaultpr+cr,r,r-proceedDs rcCs8t|tr |}i}|D] }||vr||||<q |Srw)ryrsplit)dkeysr(keyr,r,r-extract_by_keyTs  rcCsntjddkrtd|}|}t|}z6t|}|ddd}|D]!\}}|D]\}}d||f}t |} | dusDJ| ||<q0q(|WSt y[| ddYnwdd } t } z| | |Wnt jy|t|}t|}| | |Ynwi}| D]&} i|| <}| | D]\} }d| |f}t |} | dusJ| || <qq|S) Nrutf-8 extensionszpython.exportsexportsz%s = %scSs&t|dr ||dS||dS)N read_file)rrrZreadfp)cpstreamr,r,r- read_streamqs z!read_exports..read_stream)rs version_infocodecs getreaderreadr jsonloaditemsget_export_entry Exceptionseekr ConfigParserZMissingSectionHeaderErrorclosetextwrapdedentsections)rdataZjdatar(groupentrieskrKr+entryrrrrSvaluer,r,r- read_exports]sL           rcCstjddkrtd|}t}|D]6\}}|||D](}|j dur.|j }nd|j |j f}|j rCd|d |j f}| ||j|q#q||dS)Nrrrz%s:%sz%s [%s]rO)rsrr getwriterrrr add_sectionvaluesrmroflagsr$setrSwrite)rrrrrKrr+r,r,r- write_exportss   rc cs.t}z |VWt|dSt|wrw)tempfilemkdtemprrmtree)Ztdr,r,r-tempdirs rc c8t}zt|dVWt|dSt|wrw)rdgetcwdchdir)rcwdr,r,r-r  rc crrw)socketZgetdefaulttimeoutZsetdefaulttimeout)ZsecondsZctor,r,r-socket_timeoutrrc@seZdZddZdddZdS)cached_propertycCs ||_dSrw)func)selfrr,r,r-__init__ zcached_property.__init__NcCs,|dur|S||}t||jj||Srw)robject __setattr____name__)robjclsrr,r,r-__get__s  zcached_property.__get__rw)r __module__ __qualname__rrr,r,r,r-rsrcCstjdkr|S|s |S|ddkrtd||ddkr#td||d}tj|vr8|tjtj|vs-|s=tjStjj|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. rcrzpath '%s' cannot be absolutezpath '%s' cannot end with '/')rdrf ValueErrorrcurdirremoverer$)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|_|dSrw)dry_runrensured _init_record)rrr,r,r-r zFileOperator.__init__cCsd|_t|_t|_dSNF)recordr files_written dirs_createdrr,r,r-rrzFileOperator._init_recordcCs|jr |j|dSdSrw)rradd)rrer,r,r-record_as_writtenszFileOperator.record_as_writtencCsHtj|stdtj|tj|sdSt|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)rdreexistsrabspathstatst_mtime)rsourcetargetr,r,r-newers   zFileOperator.newerTcCs|tj|td|||js@d}|r2tj|r"d|}ntj|r2tj |s2d|}|r:t |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_dirrdredirnameloggerinforislinkrisfilerrZcopyfiler)rZinfileoutfilecheckmsgr,r,r- copy_files    zFileOperator.copy_fileNcCstj|rJ|tj|td|||js?|dur%t|d}nt j|d|d}z t ||W| n| w| |dS)NzCopying stream %s to %swbwencoding)rdreisdirrrrrropenrrZ copyfileobjrr)rZinstreamrrZ outstreamr,r,r- copy_streams zFileOperator.copy_streamcCsp|tj||js1tj|rt|t|d }||Wdn1s,wY| |dS)Nr) rrdrerrrrrrr)rrerfr,r,r-write_binary_file's    zFileOperator.write_binary_filecCs||||dSrw)rencode)rrerrr,r,r-write_text_file0zFileOperator.write_text_filecCsvtjdkstjdkr5tjdkr7|D]'}|jrtd|qt|j|B|@}td||t||qdSdSdS)Nposixjavazchanging mode of %szchanging mode of %s to %o) rdrS_namerrrrst_modechmod)rbitsmaskfilesrmoder,r,r-set_mode3szFileOperator.set_modecCs|dd|S)Nimi)r)r+rr,r,r-?szFileOperator.cCstj|}||jvr>tj|s@|j|tj|\}}||t d||j s3t ||j rB|j |dSdSdSdS)Nz Creating %s)rdrerrrrrrrrrmkdirrr)rrerrr,r,r-rAs    zFileOperator.ensure_dirc Cst|| }td|||jsG|s|||r,|sd}n||s$J|t|d}i}|r;ttdr;tj j |d<tj |||dfi|| ||S)NzByte-compiling %s to %sPycInvalidationModeinvalidation_modeT) r rrrrrWrgrr py_compiler CHECKED_HASHcompiler) rreoptimizeforceroZhashed_invalidationZdpathZdiagpathZcompile_kwargsr,r,r- byte_compileMs   zFileOperator.byte_compilecCstj|r^tj|r4tj|s4td||js t ||j r0||j vr2|j |dSdSdStj|r=d}nd}td|||jsNt ||j r`||j vrb|j |dSdSdSdS)NzRemoving directory tree at %slinkfilezRemoving %s %s)rdrerrrrdebugrrrrrrr)rrer+r,r,r-ensure_removed^s,       zFileOperator.ensure_removedcCsNd}|s%tj|rt|tj} |Stj|}||kr! |S|}|r|Sr)rdreraccessW_OKr)rrer(parentr,r,r- is_writabless  zFileOperator.is_writablecCs"|jsJ|j|jf}||S)zV Commit recorded changes, turn off recording, return changes. )rrrr)rr(r,r,r-commits  zFileOperator.commitcCs|jsCt|jD] }tj|rt|qt|jdd}|D]#}t |}|r=|dgks/Jtj ||d}t |t |q| dS)NT)reverse __pycache__r) rlistrrdrerrsortedrlistdirr$rmdirr)rrdirsrflistsdr,r,r-rollbacks      zFileOperator.rollbackFTrw)FFNF)rrrrrrrrrrrrZset_executable_moderrr rrrr,r,r,r-rs"       rcCs`|tjvr tj|}nt|}|dur|}|S|d}t||d}|D]}t||}q&|S)N.r)rsmodules __import__rrtrj)Z module_nameZ dotted_pathmodr(r*r~r,r,r-resolves    r!c@s6eZdZddZeddZddZddZej Z d S) ExportEntrycCs||_||_||_||_dSrwrSrormr)rrSrormrr,r,r-rs zExportEntry.__init__cCst|j|jSrw)r!rormrr,r,r-rszExportEntry.valuecCsd|j|j|j|jfS)Nzr#rr,r,r-__repr__s zExportEntry.__repr__cCsFt|ts d}|S|j|jko |j|jko |j|jko |j|jk}|Sr)ryr"rSrormr)rotherr(r,r,r-__eq__s    zExportEntry.__eq__N) rrrrrrr$r&r__hash__r,r,r,r-r"s  r"z(?P(\w|[-.+])+) \s*=\s*(?P(\w+)([:\.]\w+)*) \s*(\[\s*(?P[\w-]+(=\w+)?(,\s*\w+(=\w+)?)*)\s*\])? c Cst|}|sd}d|vsd|vrtd||S|}|d}|d}|d}|dkr4|d}}n|dkr>td||d\}}|d } | dur^d|vsUd|vr[td|g} n d d | d D} t|||| }|S) NrCrDzInvalid specification '%s'rScallable:rrrcSsg|]}|qSr,rV)rPrr,r,r-rQrRz$get_export_entry..rE)ENTRY_REsearchr groupdictcountrr") Z specificationr'r(rrSreZcolonsrormrr,r,r-rs:   rcCs|durd}tjdkrdtjvrtjd}ntjd}tj|r3t|tj}|s2t d|nz t |d}Wnt yOt j d |dd d }Ynw|s\t }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)rdrSenvironre expandvars expanduserrr r rwarningmakedirsOSErrorrrr$)rmr(Zusabler,r,r-get_cache_bases*      r8cCsBtjtj|\}}|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)rdre splitdriverr!rf)rerr~r,r,r-path_to_cache_dirs    r:cCs|ds |dS|Srb)endswith)r+r,r,r- ensure_slash$s r<cCs`d}}d|vr|dd\}}d|vr|}n|dd\}}|r%t|}|r+t|}|||fS)NrFrr))rsplitrr)r[usernamepasswordror,r,r-parse_credentials*s r@cCstd}t||S)N)rdumaskrur,r,r-get_process_umask9s  rCcCs<d}d}t|D] \}}t|tsd}nq|dusJ|S)NTF) enumerateryr)seqr(r^r+r,r,r-is_string_sequence>s  rFz3([a-z0-9_]+([.-][a-z_][a-z0-9_]*)*)-([a-z0-9_.+-]+)z -py(\d\.?\d?)cCsd}d}t|dd}t|}|r |d}|d|}|rLt|t|dkrLtt |d|}|rL| }|d|||dd|f}|durbt |}|rb|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,rstartrgrerescaperPROJECT_NAME_AND_VERSION)filenameZ project_namer(Zpyverr'nr,r,r-split_filenameMs"   rPz-(?P[\w .-]+)\s*\(\s*(?P[^\s)]+)\)$cCs:t|}|s td||}|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'rSZver)NAME_VERSION_RErrr-rVr{)r~r'rr,r,r-parse_name_and_versionis  rRcCst}t|pg}t|p g}d|vr|d||O}|D]<}|dkr*||q|drJ|dd}||vr@td|||vrI||q||vrUtd|||q|S)N*rHrzundeclared extra: %s)rrrrWrr5)Z requestedZ availabler(rZunwantedr,r,r- get_extrasxs(        rUc Csi}z*t|}|}|d}|dstd|W|Std|}t |}W|St yF}zt d||WYd}~|Sd}~ww)Nz Content-Typezapplication/jsonz(Unexpected response for JSON request: %srz&Failed to get external data for %s: %s) r rgetrWrr rrrrr exception)rUr(ZrespZheadersZctreaderer,r,r-_get_external_datas    rZz'https://www.red-dove.com/pypi/projects/cCs*d|d|f}tt|}t|}|S)Nz%s/%s/project.jsonrupperr _external_data_base_urlrZ)rSrUr(r,r,r-get_project_datas r^cCs(d|d||f}tt|}t|S)Nz%s/%s/package-%s.jsonrr[)rSversionrUr,r,r-get_package_datas r`c@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|s t|t|jd@dkrtd|tjtj ||_ dS)zu Initialise an instance. :param base: The base directory where the cache should be located. ?rzDirectory '%s' is not privateN) rdrerr6rrrr5rnormpathrl)rrlr,r,r-rs   zCache.__init__cCst|S)zN Converts a resource prefix to a directory name in the cache. )r:)rror,r,r- prefix_to_dirszCache.prefix_to_dirc Csg}t|jD]7}tj|j|}ztj|stj|r%t|n tj|r0t |Wqt y?| |Yqw|S)z" Clear the cache. ) rdrrlrer$rrrrrrrr")rZ not_removedfnr,r,r-clears    z Cache.clearN)rrr__doc__rrdrfr,r,r,r-ras  rac@s:eZdZdZddZdddZddZd d Zd d Zd S) EventMixinz1 A very simple publish/subscribe system. cCs i|_dSrw) _subscribersrr,r,r-rrzEventMixin.__init__TcCsH|j}||vrt|g||<dS||}|r||dS||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)rirr" appendleft)revent subscriberr"subsZsqr,r,r-rs zEventMixin.addcCs,|j}||vr td||||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)rirr)rrkrlrmr,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,)iterrirV)rrkr,r,r-get_subscribersszEventMixin.get_subscribersc Ospg}||D]%}z ||g|Ri|}Wnty&tdd}Ynw||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)rorrrWr"r )rrkargskwargsr(rlrr,r,r-publish s    zEventMixin.publishNr) rrrrgrrrrorrr,r,r,r-rhs  rhc@s^eZdZddZddZdddZdd Zd d Zd d ZddZ e ddZ e ddZ dS) SequencercCsi|_i|_t|_dSrw)_preds_succsr_nodesrr,r,r-r(s zSequencer.__init__cCs|j|dSrw)rvrrnoder,r,r-add_node-szSequencer.add_nodeFcCs||jvr |j||rUt|j|dD]}|||qt|j|dD]}|||q(t|jD] \}}|sB|j|=q8t|jD] \}}|sT|j|=qJdSdS)Nr,)rvrrrtrVrurr)rrxZedgesr~r+rrKr,r,r- remove_node0s"   zSequencer.remove_nodecCs<||ksJ|j|t||j|t|dSrw)rt setdefaultrrru)rpredsuccr,r,r-r@s z Sequencer.addcCsz||ksJz |j|}|j|}Wn tytd|wz ||||WdSty<td||fw)Nz%r not a successor of anythingz%r not a successor of %r)rtruKeyErrorrr)rr|r}predsZsuccsr,r,r-rEs      zSequencer.removecCs||jvp||jvp||jvSrw)rtrurv)rstepr,r,r-is_stepRszSequencer.is_stepcCs||s td|g}g}t}|||rI|d}||vr1||kr0||||n|||||j|d}| ||st |S)Nz Unknown: %rrr,) rrrr"rjrrrtrVextendreversed)rfinalr(Ztodoseenrrr,r,r- get_stepsVs&         zSequencer.get_stepscsRdggiig|jfddD] }|vr&|qS)Nrcsd|<d|<dd7<|z|}Wn ty*g}Ynw|D]%}|vrC|t|||<q-|vrRt|||<q-||krxg} }||||krlnq^t|}|dSdS)Nrr)r"rminrjtuple)rxZ successors successorZconnected_componentZ componentZgraphindexZ index_counterZlowlinksr(stack strongconnectr,r-rzs4       z3Sequencer.strong_connections..strongconnect)rurwr,rr-strong_connectionsos"zSequencer.strong_connectionscCsfdg}|jD]}|j|}|D] }|d||fqq|jD] }|d|q|dd|S)Nz digraph G {z %s -> %s;z %s;} )rtr"rvr$)rr(r}rr|rxr,r,r-dots     z Sequencer.dotNr) rrrrryrzrrrrpropertyrrr,r,r,r-rs's   2rs).tar.gz.tar.bz2.tar.zip.tgz.tbz.whlTc sRfdd}tjtd}|durC|drd}n$|dr)d}d}n|dr3d }d }n|d r=d }d }ntd|z]|dkr]t|d }|r\|}|D]}||qUnt ||}|rr| }|D]}||qk|dkrt j ddkr| D]} t| jts| jd| _q|W|r|dSdS|r|ww)NcsRt|ts |d}tjtj|}|r!|tjkr't d|dS)Nrzpath outside destination: %r) ryrdecoderdrerr$rWrfr)rer~dest_dirZplenr,r- check_paths   zunarchive..check_path)rrzip)rrZtgzzr:gz)rrZtbzzr:bz2rZtarrTzUnknown format for %rrrr)rdrerrgr;rrZnamelisttarfilerZgetnamesrsrZ getmembersryrSrrZ extractallr) Zarchive_filenamerformatrrarchivernamesrSZtarinfor,rr- unarchivesR               rc Cst}t|}t|d3}t|D]$\}}}|D]}tj||}||d} tj| |} ||| qqWd|S1sCwY|S)z*zip a directory tree into a BytesIO objectrN) ioBytesIOrgrrdwalkrer$r) Z directoryr(ZdlenZzfrhrrrSZfullrelrnr,r,r-zip_dirs   r)rKMGTPc@sreZdZdZdddZddZdd Zd d Zd d Ze ddZ e ddZ ddZ e ddZ e ddZdS)ProgressZUNKNOWNrdcCs<|dus ||ks J||_|_||_d|_d|_d|_dS)NrF)rcurmaxstartedelapseddone)rZminvalZmaxvalr,r,r-rs   zProgress.__init__cCsX|j|ksJ|jdus||jksJ||_t}|jdur$||_dS||j|_dSrw)rrrtimerr)rZcurvalZnowr,r,r-update s  zProgress.updatecCs |dksJ||j|dSNr)rr)rZincrr,r,r- increments zProgress.incrementcCs||j|Srw)rrrr,r,r-rJs zProgress.startcCs |jdur ||jd|_dSNT)rrrrr,r,r-stops   z Progress.stopcCs|jdur|jS|jSrw)runknownrr,r,r-maximum!szProgress.maximumcCsH|jrd}|S|jdurd}|Sd|j|j|j|j}d|}|S)Nz100 %z ?? %gY@z%3d %%)rrrr)rr(rKr,r,r- percentage%s zProgress.percentagecCs<|dkr |jdus|j|jkrd}|Stdt|}|S)Nrz??:??:??z%H:%M:%S)rrrrstrftimegmtime)rZdurationr(r,r,r-format_duration0s zProgress.format_durationcCs|jr d}|j}n/d}|jdurd}n%|jdks|j|jkr!d}nt|j|j}||j|j}|d|j}d|||fS)NZDonezETA rrrz%s: %s)rrrrrfloatr)rror_r,r,r-ETA9s z Progress.ETAcCsL|jdkrd}n |j|j|j}tD] }|dkrn|d}qd||fS)Nrgig@@z%d %sB/s)rrrUNITS)rr(Zunitr,r,r-speedLs   zProgress.speedN)rr)rrrrrrrrJrrrrrrrr,r,r,r-rs       rz \{([^}]*)\}z[^/\\,{]\*\*|\*\*[^/\\,}]z^[^{]*\}|\{[^}]*$cCs<t|r d}t||t|rd}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|dkr6t|dksJ||\}}}|dD]}td|||fD]}|Vq-q!dSd|vrFt|D]}|Vq>dS|dd\}}|dkrTd}|dkr[d}n |d}|d }t|D]\}}} tj |}ttj ||D]} | Vq~qjdS) NrrrErz**rrSrc\) RICH_GLOBrrgrr$ std_iglobr%rdrrerc) rZrich_path_globrorrmitemreZradicaldirrrer,r,r-rls6       r) HTTPSHandlermatch_hostnameCertificateErrorc@seZdZdZdZddZdS)HTTPSConnectionNTcCsZt|j|jf|j}t|ddr||_|tt ds8|j r$t j }nt j }t j ||j|j|t j|j d|_nCt t j}tt drK|jt jO_|jrV||j|ji}|j rqt j |_|j|j dtt ddrq|j|d<|j |fi||_|j r|jrzt|j|jtd |jWdSty|jtj|jwdSdS) NZ _tunnel_hostF SSLContext) cert_reqsZ ssl_versionca_certs OP_NO_SSLv2)ZcafileZHAS_SNIZserver_hostnamezHost verified: %s) rZcreate_connectionhostporttimeoutrtsockZ_tunnelrrsslrZ CERT_REQUIREDZ CERT_NONEZ wrap_socketZkey_fileZ cert_fileZPROTOCOL_SSLv23roptionsrZload_cert_chainZ verify_modeZload_verify_locations check_domainrZ getpeercertrr rZshutdownZ SHUT_RDWRr)rrrcontextrqr,r,r-connectsF         zHTTPSConnection.connect)rrrrrrr,r,r,r-rs rc@s&eZdZd ddZddZddZdS) rTcCst|||_||_dSrw)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)rrprqr(r,r,r- _conn_makers  zHTTPSHandler._conn_makerc CsHz||j|WSty#}zdt|jvrtd|jd}~ww)Nzcertificate verify failedz*Unable to verify server certificate for %s)Zdo_openrrstrreasonrr)rr\rYr,r,r- https_openszHTTPSHandler.https_openNr)rrrrrrr,r,r,r-rs  rc@eZdZddZdS)HTTPSOnlyHandlercCs td|)NzAUnexpected HTTP request on what should be a secure connection: %s)r)rr\r,r,r- http_openszHTTPSOnlyHandler.http_openN)rrrrr,r,r,r-r rrc@eZdZdddZdS)HTTPrNcK*|dkrd}||j||fi|dSr_setupZ_connection_classrrrrqr,r,r-rz HTTP.__init__rNrrrrr,r,r,r-rrc@r)HTTPSrNcKrrrrr,r,r-rrzHTTPS.__init__rrr,r,r,r-rrrc@eZdZdddZddZdS) TransportrcC||_tj||dSrw)rrrrrr use_datetimer,r,r-rzTransport.__init__cCsb||\}}}tdkrt||jd}|S|jr||jdkr*||_|t|f|_|jd}|S)Nr)rrr) get_host_info _ver_inforr _connection_extra_headersrZHTTPConnection)rrhehZx509r(r,r,r-make_connections zTransport.make_connectionNrrrrrrr,r,r,r-r  rc@r) SafeTransportrcCrrw)rrrrrr,r,r-rrzSafeTransport.__init__cCs||\}}}|s i}|j|d<tdkr t|dfi|}|S|jr*||jdkr:||_|tj|dfi|f|_|jd}|S)Nrrrr)rrrrrrrr)rrrrrqr(r,r,r-rs  zSafeTransport.make_connectionNrrr,r,r,r-rrrc@r) ServerProxycKsx|dd|_}|dur/t|d}|dd}|dkr t}nt}|||d|d<}||_tjj ||fi|dS)Nrrrhttps)r transport) rjrrrVrrr rrr)rr]rqrrZrZtclsr_r,r,r-r&s  zServerProxy.__init__Nrr,r,r,r-r%rrcKs:tjddkr |d7}nd|d<d|d<t||fi|S)Nrrbrnewlinerr)rsrr)rerrqr,r,r- _csv_open;s  r c@s4eZdZedededdZddZddZd S) CSVBaserE"r)Z delimiterZ quotecharZlineterminatorcC|Srwr,rr,r,r- __enter__MzCSVBase.__enter__cGs|jdSrw)rr)rr1r,r,r-__exit__PszCSVBase.__exit__N)rrrrdefaultsrrr,r,r,r-r Fs r c@s(eZdZddZddZddZeZdS) CSVReadercKs`d|vr|d}tjddkrtd|}||_nt|dd|_tj|jfi|j|_dS)NrrrrrerT) rsrrrrr csvrXr)rrqrr,r,r-rUszCSVReader.__init__cCrrwr,rr,r,r-__iter__`rzCSVReader.__iter__cCsFt|j}tjddkr!t|D]\}}t|ts |d||<q|SNrrr)nextrXrsrrDryrr)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)r rrwriterr)rrerqr,r,r-rns zCSVWriter.__init__cCsNtjddkrg}|D]}t|tr|d}||q |}|j|dSr)rsrryrrr"rwriterow)rrowrTrr,r,r-rrs   zCSVWriter.writerowN)rrrrrr,r,r,r-rms rcsHeZdZeejZded<d fdd ZddZdd Zd d Z Z S) Configurator inc_convertZincNcs"tt|||p t|_dSrw)superrrrdrrl)rconfigrl __class__r,r-rszConfigurator.__init__c sfddd}t|s|}dd}dd}|r.tfdd|D}fd dD}t|}||i|}|rV|D] \}} t||| qI|S) Ncs|t|ttfrt|fdd|D}|St|tr7d|vr&|}|Si}|D] }||||<q*|S|}|S)Ncg|]}|qSr,r,)rPr^convertr,r-rQrRzBConfigurator.configure_custom..convert..())ryrrtypedictconfigure_customr&)or(r)r&rr,r-r&s   z.Configurator.configure_custom..convertr'rz[]r,cr$r,r,)rPr+r%r,r-rQrRz1Configurator.configure_custom..cs$g|]}t|r||fqSr,)r)rPr)r!r&r,r-rQs$)rjr(r!rr)rsetattr) rr!rZpropsrprrqr(rOrKr,)r!r&rr-r*s    zConfigurator.configure_customcCs4|j|}t|trd|vr|||j|<}|S)Nr')r!ryr)r*)rrr(r,r,r- __getitem__s zConfigurator.__getitem__cCs\tj|stj|j|}tj|ddd}t|}Wd|S1s'wY|S)z*Default converter for the inc:// protocol.rTrrN) rdreisabsr$rlrrrr)rrrr(r,r,r-rs   zConfigurator.inc_convertrw) rrrr)rZvalue_convertersrr*r-r __classcell__r,r,r"r-rs rc@s*eZdZdZd ddZddZdd ZdS) SubprocessMixinzC Mixin for running subprocesses and capturing their output FNcCs||_||_dSrw)verboseprogress)rr1r2r,r,r-rs zSubprocessMixin.__init__cCsl|j}|j} |}|sn"|dur|||n|s!tjdn tj|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. TNrr) r2r1readlinersstderrrrflushr)rrrr2r1r+r,r,r-rXs   zSubprocessMixin.readercKstj|ftjtjd|}tj|j|jdfd}|tj|j|jdfd}|| | | |j durE| dd|S|j rNt jd|S)N)stdoutr4r6)rrpr4zdone.mainzdone. ) subprocessPopenPIPE threadingZThreadrXr6rJr4waitr$r2r1rsr)rcmdrqr~t1t2r,r,r- run_commands$    zSubprocessMixin.run_command)FN)rrrrgrrXr@r,r,r,r-r0s   r0cCstdd|S)z,Normalize a python package name a la PEP 503z[-_.]+rH)rKsubr{)rSr,r,r-normalize_namesrBc@s.eZdZdZdZd ddZddZdd ZdS) PyPIRCFilezhttps://upload.pypi.org/legacy/pypiNcCs.|durtjtjdd}||_||_dS)Nr0z.pypirc)rdrer$r4rNrU)rrerUr,r,r-rs zPyPIRCFile.__init__c Csxi}tj|jr|jp|j}t}||j| }d|vr| dd}dd| dD}|gkr>d|vr.rrDrFr> repositoryrealm)r?Nz server-loginr?)r>r?rGrFrH)rdrerrNrUDEFAULT_REPOSITORYrRawConfigParserrrrVr DEFAULT_REALMZ has_option) rr(rGr!rZ index_serversZ_serversrFrr}r,r,r-rs^   &         zPyPIRCFile.readcCst}|j}|||ds|d|dd||dd|t|d}||WddS1s:wYdS)NrDr>r?r) rrJrNrZ has_sectionrrrr)rr>r?r!rerr,r,r-r9s     "zPyPIRCFile.updateNN)rrrrIrKrrrr,r,r,r-rCs   :rCcCst|jdS)zG Read the PyPI access configuration as supported by distutils. )rU)rCrUrrr,r,r- _load_pypircEsrNcCst|j|jdSrw)rCrr>r?rMr,r,r- _store_pypircKrrOc Cstjdkr#dtjvrdSdtjvrdSdtjvr dStjSdtjvr-tjdStjd ks7ttd s:tjSt\}}}}}| d d }| d d d d}|dddkrcd||fS|dddkr|ddkrd}dt |dd|ddf}ddd}|d|tj 7}nL|dddkrdd 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_PLATFORMrunamercrrGr`rHNZlinuxz%s-%sZsunosr5Zsolarisz%d.%srrZ32bitZ64bit)ilz.%sZaix) aix_platformrcygwinz[\d.]+darwinz%s-%s-%s)rdrSrsr_r{platformr2rrrRr!intmaxsizeZ _aix_supportrUrKrASCIIrr _osx_supportZdistutils.sysconfigZget_platform_osxZ sysconfigZget_config_vars) Zosnamerreleaser_machineZbitnessrUZrel_rer'r\rEr,r,r-get_host_platformSsR          r_Zwin32rPrQ)Zx86Zx64ZarmcCs2tjdkrtStjd}|tvrtSt|S)Nr/ZVSCMD_ARG_TGT_ARCH)rdrSr_r2rV_TARGET_TO_PLAT)Zcross_compilation_targetr,r,r- get_platforms  rarL)rrwr)r collectionsr contextlibrglobrrrrZloggingrdrrKrr ImportErrorr8rsrrrr;Zdummy_threadingrrrcompatrrrr r r r r rrrrrrrrrrrrrZ getLoggerrrrrrIrHr6r@r;rYr#rArarprvrzrrrrcontextmanagerrrrrrrrr!r"VERBOSEr+rr8r:r<r@rCrFIrMrIrPrQrRrUrZr]r^r`rarhrsZARCHIVE_EXTENSIONSrrrrrrrrrrrrrrrrrrrrrr r rrrr0rBrCrNrOr_r`rar,r,r,r-s        \         Y}  /    8 )    ,H 6 ]   +)  7.QR