o ƚRe@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) remainingmresultqoqpartssr-/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-3.el8.x86_64/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)Nandr3)ANDrrr&r5r'r6)r9r-r. marker_andx    z parse_marker..marker_andcr:)Norr3)ORrrr=)r>r-r.r8r?zparse_marker..markerr-) marker_stringr-)r8r>r9r/r. parse_marker8s  $   rCcCs|}|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: %srGrinvalid constraint: %s) COMPARE_OPrrrVERSION_IDENTIFIERr r"r%) ver_remainingr'versionsr4vr-r-r. get_versionss2       z'parse_requirement..get_versionsr0r1r2rIz~=;zinvalid requirement: %szunexpected trailing data: %s%s %s, cSsg|]}d|qS)rQr-).0conr-r-r. z%parse_requirement..)nameextras constraintsr8url requirement)strip startswithrrr rrfindr%r" NON_SPACErschemenetlocrJrKrCr$r)reqr&r'distnamerX mark_exprrMuriir,trO_rNrsr-r-r.parse_requirements                              rjcCsdd}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!ospathsepr]lenr%)rootrnr-r-r. get_rel_pathsz)get_resources_dests..get_rel_pathNrl)rmrnr$rpopr!rorstrip)resources_rootrulesrr destinationsbasesuffixdestprefixabs_baseabs_globabs_path resource_filerel_pathrel_destr-r-r.get_resources_destss      rcCs*ttdr d}|Stjttdtjk}|S)N real_prefixT base_prefix)hasattrsysr{getattrr(r-r-r.in_venv(s rcCstj}t|ts t|}|SN)r executable isinstancerrrr-r-r.get_executable2s rcCsP|} t|}|}|s|r|}|r'|d}||vr |S|r'd|||f}q)NTrz %c: %s %s)r lower)prompt allowed_chars error_promptdefaultpr,cr-r-r.proceedDs rcCs8t|tr |}i}|D] }||vr||||<q |Sr)rrsplit)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)rrreadfp)cpstreamr-r-r. read_streamqs z!read_exports..read_stream)r version_infocodecs getreaderreadr jsonloaditemsget_export_entry Exceptionseekr ConfigParserMissingSectionHeaderErrorclosetextwrapdedentsections)rdatajdatar(groupentrieskrNr,entryrrrrWvaluer-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]rR)rrr getwriterrrr add_sectionvaluesryr{flagsr$setrWwrite)rrrrrNrr,r-r-r. write_exportss   rc cs.t}z |VWt|dSt|wr)tempfilemkdtemprrmtree)tdr-r-r.tempdirs rc c8t}zt|dVWt|dSt|wr)rmgetcwdchdir)rcwdr-r-r.r  rc crr)socketgetdefaulttimeoutsetdefaulttimeout)secondsctor-r-r.socket_timeoutrrc@seZdZddZdddZdS)cached_propertycCs ||_dSr)func)selfrr-r-r.__init__ zcached_property.__init__NcCs,|dur|S||}t||jj||Sr)robject __setattr____name__)robjclsrr-r-r.__get__s  zcached_property.__get__r)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. rlrzpath '%s' cannot be absolutezpath '%s' cannot end with '/')rmro ValueErrorrcurdirremovernr$)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|_|dSr)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|dSdSr)rradd)rrnr-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)rmrnexistsrabspathstatst_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_dirrmrndirnameloggerinforislinkrisfilerrcopyfiler)rinfileoutfilecheckmsgr-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)rmrnisdirrrrrropenrr copyfileobjrr)rinstreamrr  outstreamr-r-r. copy_streams zFileOperator.copy_streamcCsp|tj||js1tj|rt|t|d }||Wdn1s,wY| |dS)Nr) rrmrnrrrrr rr)rrnrfr-r-r.write_binary_file's    zFileOperator.write_binary_filecCs||||dSr)rencode)rrnrr r-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) rmrW_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)rmrnrrrrrrrrrmkdirrr)rrnrrr-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 rrrrr]rpr py_compiler" CHECKED_HASHcompiler) rrnoptimizeforcer{hashed_invalidationdpathdiagpathcompile_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)rmrnrr rrdebugrrrrrrr)rrnr,r-r-r.ensure_removed^s,       zFileOperator.ensure_removedcCsNd}|s%tj|rt|tj} |Stj|}||kr! |S|}|r|Sr)rmrnraccessW_OKr)rrnr(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) rlistrrmrnrrsortedrlistdirr$rmdirr)rrdirsrflistsdr-r-r.rollbacks      zFileOperator.rollbackFTr)FFNF)rrrrrrrrrrrrset_executable_moderr-r1r5r6r@r-r-r-r.rs"       rcCs`|tjvr tj|}nt|}|dur|}|S|d}t||d}|D]}t||}q&|S)N.r)rmodules __import__rrrs) module_name dotted_pathmodr(r+rr-r-r.resolves    rJc@s6eZdZddZeddZddZddZej Z d S) ExportEntrycCs||_||_||_||_dSrrWr{ryr)rrWr{ryrr-r-r.rs zExportEntry.__init__cCst|j|jSr)rJr{ryrr-r-r.rszExportEntry.valuecCsd|j|j|j|jfS)NzrLrr-r-r.__repr__s zExportEntry.__repr__cCsFt|ts d}|S|j|jko |j|jko |j|jko |j|jk}|Sr)rrKrWr{ryr)rotherr(r-r-r.__eq__s    zExportEntry.__eq__N) rrrrrrrMrOr__hash__r-r-r-r.rKs  rKz(?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) NrErFzInvalid specification '%s'rWcallable:rrrcSsg|]}|qSr-r\)rSrr-r-r.rUrVz$get_export_entry..rG)ENTRY_REsearchr groupdictcountrrK) specificationr'r(rrWrncolonsr{ryrr-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.distlibnt LOCALAPPDATAz $localappdata~z(Directory exists but is not writable: %sTzUnable to create %s)exc_infoFz#Default location unusable, using %s)rmrWenvironrn expandvars expanduserr r2r3rwarningmakedirsOSErrorrrr$)ryr(usabler-r-r.get_cache_bases*      recCsBtjtj|\}}|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. rRz---z--z.cache)rmrn splitdriverr!ro)rnrrr-r-r.path_to_cache_dirs    rgcCs|ds |dS|Srk)endswith)r,r-r-r. ensure_slash$s ricCs`d}}d|vr|dd\}}d|vr|}n|dd\}}|r%t|}|r+t|}|||fS)NrHrrR)rsplitrr)rausernamepasswordr{r-r-r.parse_credentials*s rmcCstd}t||S)N)rmumaskrr-r-r.get_process_umask9s  rpcCs<d}d}t|D] \}}t|tsd}nq|dusJ|S)NTF) enumeraterr)seqr(rfr,r-r-r.is_string_sequence>s  rsz3([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_VERSIONrUrstartrprerescaperPROJECT_NAME_AND_VERSION)filename project_namer(pyverr'nr-r-r.split_filenameMs"   rz-(?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'rWver)NAME_VERSION_RErrrVr\r)rr'rr-r-r.parse_name_and_versionis  rcCst}t|pg}t|p g}d|vr|d||O}|D]<}|dkr*||q|drJ|dd}||vr@td|||vrI||q||vrUtd|||q|S)N*rurzundeclared extra: %s)rrrr]rra) requested availabler(runwantedr-r-r. get_extrasxs(        rc 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 rgetr]rr0rrrrr exception)rZr(respheadersctreaderer-r-r._get_external_datas    rz'https://www.red-dove.com/pypi/projects/cCs*d|d|f}tt|}t|}|S)Nz%s/%s/project.jsonrupperr _external_data_base_urlr)rWrZr(r-r-r.get_project_datas rcCs(d|d||f}tt|}t|S)Nz%s/%s/package-%s.jsonrr)rWversionrZr-r-r.get_package_datas rc@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) rmrnr rbrrrrarnormpathrx)rrxr-r-r.rs   zCache.__init__cCst|S)zN Converts a resource prefix to a directory name in the cache. )rg)rr{r-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. ) rmr;rxrnr$rrrr rrrr")r not_removedfnr-r-r.clears    z Cache.clearN)rrr__doc__rrrr-r-r-r.rs  rc@s:eZdZdZddZdddZddZd d Zd d Zd S) EventMixinz1 A very simple publish/subscribe system. cCs i|_dSr) _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)rrr" appendleft)revent subscriberr"subssqr-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)rrr)rrrrr-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-)iterrr)rrr-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)rrrrr"r0)rrargskwargsr(rrr-r-r.publish s    zEventMixin.publishNrB) rrrrrrrrrr-r-r-r.rs  rc@s^eZdZddZddZdddZdd Zd d Zd d ZddZ e ddZ e ddZ dS) SequencercCsi|_i|_t|_dSr)_preds_succsr_nodesrr-r-r.r(s zSequencer.__init__cCs|j|dSr)rrrnoder-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-)rrrrrrr9r)rredgesrr,rrNr-r-r. remove_node0s"   zSequencer.remove_nodecCs<||ksJ|j|t||j|t|dSr)r setdefaultrrr)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)rrKeyErrorrr)rrrpredssuccsr-r-r.rEs      zSequencer.removecCs||jvp||jvp||jvSr)rrr)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"rsrrrrextendreversed)rfinalr(todoseenrrr-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"rminrstuple)r successors successorconnected_component componentgraphindex index_counterlowlinksr(stack strongconnectr-r.rzs4       z3Sequencer.strong_connections..strongconnect)rrr-rr.strong_connectionsos"zSequencer.strong_connectionscCsfdg}|jD]}|j|}|D] }|d||fqq|jD] }|d|q|dd|S)Nz digraph G {z %s -> %s;z %s;} )rr"rr$)rr(rrrrr-r-r.dots     z Sequencer.dotNrA) rrrrrrrrrrpropertyrrr-r-r-r.r's   2r).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) rrdecodermrnrr$r]ror)rnrdest_dirplenr-r. check_paths   zunarchive..check_path)rrzip)rrtgzzr:gz)rrtbzzr:bz2rtarrzUnknown format for %rrrr)rmrnrrprhrrnamelisttarfiler getnamesrr getmembersrrWrr extractallr) archive_filenamerformatrrarchivernamesrWtarinfor-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) ioBytesIOrprrmwalkrnr$r) directoryr(dlenzfrqr=rrWfullrelrzr-r-r.zip_dirs   r)rKMGTPc@sreZdZdZdddZddZdd Zd d Zd d Ze ddZ e ddZ ddZ e ddZ e ddZdS)ProgressUNKNOWNrdcCs<|dus ||ks J||_|_||_d|_d|_d|_dS)NrF)rcurmaxstartedelapseddone)rminvalmaxvalr-r-r.rs   zProgress.__init__cCsX|j|ksJ|jdus||jksJ||_t}|jdur$||_dS||j|_dSr)rrrtimerr)rcurvalnowr-r-r.update s  zProgress.updatecCs |dksJ||j|dSNr)r r)rincrr-r-r. increments zProgress.incrementcCs||j|Sr)r rrr-r-r.rws zProgress.startcCs |jdur ||jd|_dSNT)rr rrr-r-r.stops   z Progress.stopcCs|jdur|jS|jSr)runknownrr-r-r.maximum!szProgress.maximumcCsH|jrd}|S|jdurd}|Sd|j|j|j|j}d|}|S)Nz100 %z ?? %gY@z%3d %%)rrrr)rr(rNr-r-r. percentage%s zProgress.percentagecCs<|dkr |jdus|j|jkrd}|Stdt|}|S)Nrz??:??:??z%H:%M:%S)rrrrstrftimegmtime)rdurationr(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)NDonezETA rrrz%s: %s)rrrrrfloatr)rr{rgr-r-r.ETA9s z Progress.ETAcCsL|jdkrd}n |j|j|j}tD] }|dkrn|d}qd||fS)Nrgig@@z%d %sB/s)rrrUNITS)rr(unitr-r-r.speedLs   zProgress.speedN)rr)rrrrrr r rwrrrrrrrr-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_GLOBrUr_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) NrrrGrz**rDrrl\) RICH_GLOBrrprr$ std_iglobr%rmrrnr) r rich_path_globr{rryitemrnradicaldirrrr-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) N _tunnel_hostF SSLContext) cert_reqs ssl_versionca_certs OP_NO_SSLv2)cafileHAS_SNIserver_hostnamezHost verified: %s) rcreate_connectionhostporttimeoutrsock_tunnelrsslr0 CERT_REQUIRED CERT_NONE wrap_socketkey_file cert_filePROTOCOL_SSLv23r-optionsr1load_cert_chain verify_modeload_verify_locations check_domainr) getpeercertrr0r*shutdown SHUT_RDWRr)rr9r.contextrr-r-r.connectsF         zHTTPSConnection.connect)rrrr0rFrKr-r-r-r.r+s r+c@s&eZdZd ddZddZddZdS) r(TcCst|||_||_dSr)BaseHTTPSHandlerrr0rF)rr0rFr-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. )r+r0rF)rrrr(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)do_openrMrstrreasonr*r6)rrbrr-r-r. https_openszHTTPSHandler.https_openNrB)rrrrrMrQr-r-r-r.r(s  r(c@eZdZddZdS)HTTPSOnlyHandlercCs td|)NzAUnexpected HTTP request on what should be a secure connection: %s)r)rrbr-r-r. http_openszHTTPSOnlyHandler.http_openN)rrrrTr-r-r-r.rS rSrVc@eZdZdddZdS)HTTPrNcK*|dkrd}||j||fi|dSr _setupZ_connection_classrr6r7rr-r-r.rz HTTP.__init__rNrrrrr-r-r-r.rZrZc@rY)HTTPSrNcKr[r r\r^r-r-r.rr_zHTTPS.__init__r`rar-r-r-r.rcrbrcc@eZdZdddZddZdS) TransportrcC||_tj||dSr)r8rrerrr8 use_datetimer-r-r.rzTransport.__init__cCsb||\}}}tdkrt||jd}|S|jr||jdkr*||_|t|f|_|jd}|S)NrW)r8rr) get_host_info _ver_inforZr8 _connection_extra_headersrHTTPConnection)rr6hehx509r(r-r-r.make_connections zTransport.make_connectionNrrrrrrrr-r-r-r.re  rec@rd) SafeTransportrcCrfr)r8rrvrrgr-r-r.rrizSafeTransport.__init__cCs||\}}}|s i}|j|d<tdkr t|dfi|}|S|jr*||jdkr:||_|tj|dfi|f|_|jd}|S)Nr8rWrr)rjr8rkrcrlrmrr+)rr6rorprr(r-r-r.rrs  zSafeTransport.make_connectionNrsrtr-r-r-r.rvrurvc@rR) ServerProxycKsx|dd|_}|dur/t|d}|dd}|dkr t}nt}|||d|d<}||_tjj ||fi|dS)Nr8rrhhttps)rh transport) rsr8rrrvreryrrwr)rrerr8r`rhtclsrgr-r-r.r&s  zServerProxy.__init__Nrar-r-r-r.rw%rUrwcKs:tjddkr |d7}nd|d<d|d<t||fi|S)Nrrbrnewlinerr )rrr )rrrr-r-r. _csv_open;s  r}c@s4eZdZedededdZddZddZd S) CSVBaserG"r) delimiter quotecharlineterminatorcC|Srr-rr-r-r. __enter__MzCSVBase.__enter__cGs|jdSr)rr)rr]r-r-r.__exit__PszCSVBase.__exit__N)rrrrOdefaultsrrr-r-r-r.r~Fs r~c@s(eZdZddZddZddZeZdS) CSVReadercKs`d|vr|d}tjddkrtd|}||_nt|dd|_tj|jfi|j|_dS)Nrrrrrnr) rrrrrr}csvrr)rrrr-r-r.rUszCSVReader.__init__cCrrr-rr-r-r.__iter__`rzCSVReader.__iter__cCsFt|j}tjddkr!t|D]\}}t|ts |d||<q|SNrrr)nextrrrrqrrr)rr(rfr%r-r-r.rcs  zCSVReader.nextN)rrrrrr__next__r-r-r-r.rTs  rc@seZdZddZddZdS) CSVWritercKs(t|d|_tj|jfi|j|_dS)Nr)r}rrwriterr)rrrr-r-r.rns zCSVWriter.__init__cCsNtjddkrg}|D]}t|tr|d}||q |}|j|dSr)rrrrrr"rwriterow)rrowrr%r-r-r.rrs   zCSVWriter.writerowN)rrrrrr-r-r-r.rms rcsHeZdZeejZded<d fdd ZddZdd Zd d Z Z S) Configurator inc_convertincNcs"tt|||p t|_dSr)superrrrmrrx)rconfigrx __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-)rSrfconvertr-r.rUrVzBConfigurator.configure_custom..convert..())rr9rtypedictconfigure_customr)or(r)rrr-r.rs   z.Configurator.configure_custom..convertrrDz[]r-crr-r-)rSrrr-r.rUrVz1Configurator.configure_custom..cs$g|]}t|r||fqSr-)r)rSr)rrr-r.rUs$)rsrQrJrrrsetattr) rrrpropsrrrr(r~rNr-)rrrr.rs    zConfigurator.configure_customcCs4|j|}t|trd|vr|||j|<}|S)Nr)rrrr)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.rrr N) rmrnisabsr$rxrr rr)rrrr(r-r-r.rs   zConfigurator.inc_convertr) rrrrrvalue_convertersrrrr __classcell__r-r-rr.rs rc@s*eZdZdZd ddZddZdd ZdS) SubprocessMixinzC Mixin for running subprocesses and capturing their output FNcCs||_||_dSr)verboseprogress)rrrr-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. TNrDr) rrreadlinerstderrrrflushr)rrrJrrr,r-r-r.rs   zSubprocessMixin.readercKstj|ftjtjd|}tj|j|jdfd}|tj|j|jdfd}|| | | |j durE| dd|S|j rNt jd|S)N)stdoutrr)rrrzdone.mainzdone. ) subprocessPopenPIPE threadingThreadrrrwrwaitr$rrrr)rcmdrrt1t2r-r-r. run_commands$    zSubprocessMixin.run_command)FN)rrrrrrrr-r-r-r.rs   rcCstdd|S)z,Normalize a python package name a la PEP 503z[-_.]+ru)rxsubr)rWr-r-r.normalize_namesrc@s.eZdZdZdZd ddZddZdd ZdS) PyPIRCFilezhttps://upload.pypi.org/legacy/pypiNcCs.|durtjtjdd}||_||_dS)Nr\z.pypirc)rmrnr$r`r{rZ)rrrZr-r-r.rs zPyPIRCFile.__init__c Csxi}tj|jr|jp|j}t}||j| }d|vr| dd}dd| dD}|gkr>d|vr.rrrrk repositoryrealm)rlNz server-loginrl)rkrlrrr)rmrnrr{rZDEFAULT_REPOSITORYrRawConfigParserrrrr DEFAULT_REALM has_option) rr(rrr index_servers_serversrrrr-r-r.rsZ   &        zPyPIRCFile.readcCst}|j}|||ds|d|dd||dd|t|d}||WddS1s:wYdS)Nrrkrlr) rrr{r has_sectionrrr r)rrkrlrrrr-r-r.r 9s     "zPyPIRCFile.updateNN)rrrrrrrr r-r-r-r.rs   :rcCst|jdS)zG Read the PyPI access configuration as supported by distutils. )rZ)rrZrrr-r-r. _load_pypircEsrcCst|j|jdSr)rr rkrlrr-r-r. _store_pypircKrrc 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'. rZamd64 win-amd64z(arm) win-arm32z(arm64)z win-arm64_PYTHON_HOST_PLATFORMrunamerlrrtrhruNlinuxz%s-%ssunosr5solarisz%d.%srrV32bit64bit)ilz.%saix) aix_platformrXcygwinz[\d.]+darwinz%s-%s-%s)rmrWrrrplatformr^rrr!intmaxsize _aix_supportrrxr&ASCIIrr _osx_supportdistutils.sysconfigget_platform_osx sysconfigget_config_vars) osnamer6releasermachinebitnessrrel_rer'rrr-r-r.get_host_platformSsR          rwin32rr)x86x64armcCs2tjdkrtStjd}|tvrtSt|S)NrZVSCMD_ARG_TGT_ARCH)rmrWrr^r_TARGET_TO_PLAT)cross_compilation_targetr-r-r. get_platforms  rr)rrr)r collectionsr contextlibrglobrr#rrloggingrmr$rxrr; ImportErrorrrrrrrZdummy_threadingrrrcompatrrrr r r r r rrrrrrrrrrrrr getLoggerrrr&rrKrJr7rAr<r_r#rCrjrrrrrrrcontextmanagerrrrrrrrrJrKVERBOSErTrrergrirmrprsIrzrvrrrrrrrrrrrARCHIVE_EXTENSIONSrrrrr"rrrr(rLr)r*r+rSrrkrZrcrervrwr}r~rrrrrrrrrrrr-r-r-r.s        \         Y}  /    8 )    ,H 6 ]   +)  7.QR