U 淀gz@sddlZddlmZddlZddlZddlmZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZz ddlZWnek rdZYnXddlZddlZddlZddlZddlZz ddlZWnek rddlZYnXddlZddlmZddlmZmZmZmZm 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 0e1Z2e 3dZ4e 3dZ5e 3d Z6e 3d Z7e 3d Z8e 3d Z9e 3d Z:e 3dZ;ddZddZ?ddZ@dddZAddZBddZCdd ZDejEd!d"ZFejEd#d$ZGejEdd&d'ZHGd(d)d)eIZJd*d+ZKGd,d-d-eIZLd.d/ZMGd0d1d1eIZNe 3d2e jOZPd3d4ZQdd5d6ZRdd8d9ZSd:d;ZTdd?ZVd@dAZWe 3dBe jXZYe 3dCZZddDdEZ[e 3dFZ\dGdHZ]dIdJZ^dKdLZ_dMZ`dNdOZadPdQZbGdRdSdSeIZcGdTdUdUeIZdGdVdWdWeIZedXZfddYdZZgd[d\Zhd]ZiGd^d_d_eIZje 3d`Zke 3daZle 3dbZmdcddZdedfZnerddglmoZpmqZqmrZrGdhdidie$jsZsGdjdkdkepZoGdldmdmeoe&ZtGdndodoe%juZuerGdpdqdqe%jvZvGdrdsdse%jwZwdtduZxGdvdwdweIZyGdxdydyeyZzGdzd{d{eyZ{Gd|d}d}e'Z|Gd~ddeIZ}ddZ~GdddeIZddZddZddZddddZddZdS)N)deque)iglob)DistlibException) string_types text_typeshutil raw_inputStringIOcache_from_sourceurlopenurljoinhttplib xmlrpclib 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}|dkrVtd|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) remainingmresultqoqpartssr,F/opt/hc_python/lib/python3.8/site-packages/pip/_vendor/distlib/util.py marker_var@s:               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_exprds       z!parse_marker..marker_exprcsR|\}}|rJt|}|s qJ||d}|\}}d||d}q ||fS)Nandr2)ANDrrr%r4r&r5)r8r,r- marker_andws   z parse_marker..marker_andcsR|\}}|rJt|}|s qJ||d}|\}}d||d}q ||fS)Norr2)ORrrr;)r<r,r-r7s   zparse_marker..markerr,) marker_stringr,)r7r<r8r.r- parse_marker6s $ 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: %srDrinvalid constraint: %s) COMPARE_OPrrrVERSION_IDENTIFIERrr!r$) ver_remainingr&versionsr3vr,r,r- get_versionss.      z'parse_requirement..get_versionsr/r0r1rFz~=;zinvalid requirement: %szunexpected trailing data: %s%s %s, cSsg|] }d|qS)rNr,).0conr,r,r- sz%parse_requirement..)nameextras constraintsr7url requirement)strip startswithrrrrrfindr$r! NON_SPACErschemenetlocrGrHr@r#r)reqr%r&distnamerT mark_exprrJuriir+trL_rKrsr,r,r-parse_requirements                           rfcCsdd}i}|D]\}}}tj||}t|D]p}tj||} t| D]T} ||| } |dkrn|| dqJ||| } |tjjdd} | d| || <qJq0q|S)z%Find destinations for resources filescSsD|tjjd}|tjjd}||s.t|t|ddSN/)r ospathseprYAssertionErrorlenr$)rootrjr,r,r- get_rel_pathsz)get_resources_dests..get_rel_pathNrh)rirjr#rpopr rkrstrip)resources_rootrulesro destinationsbasesuffixdestprefixabs_baseabs_globabs_path resource_filerel_pathrel_destr,r,r-get_resources_dests s    rcCs(ttdrd}ntjttdtjk}|S)N real_prefixT base_prefix)hasattrsysrxgetattrr'r,r,r-in_venv&s rcCstj}t|tst|}|SN)r executable isinstancerrrr,r,r-get_executable0s  rcCsN|}t|}|}|s|r|}|r|d}||kr6qJ|rd|||f}q|S)Nrz %c: %s %s)r lower)prompt allowed_chars error_promptdefaultpr+cr,r,r-proceedBs rcCs8t|tr|}i}|D]}||kr||||<q|Sr)rrsplit)dkeysr'keyr,r,r-extract_by_keyRs rcCsztjddkrtd|}|}t|}zlt|}|ddd}|D]B\}}|D]0\}}d||f}t |} | dk st | ||<q`qP|WSt k r| ddYnXdd } t } z| | |Wn<t jk r|t|}t|}| | |YnXi}| D]R} i|| <}| | D]4\} }d| |f}t |} | dk sft | || <q<q"|S) Nrutf-8 extensionszpython.exportsexportsz%s = %scSs$t|dr||n ||dS)N read_file)rrreadfp)cpstreamr,r,r- read_streamps  z!read_exports..read_stream)r version_infocodecs getreaderreadr jsonloaditemsget_export_entryrl Exceptionseekr ConfigParserMissingSectionHeaderErrorclosetextwrapdedentsections)rdatajdatar'groupentrieskrKr+entryrrrrSvaluer,r,r- read_exports\sD        rcCstjddkrtd|}t}|D]l\}}|||D]P}|j dkr\|j }nd|j |j f}|j rd|d |j f}| ||j|qFq,||dS)Nrrrz%s:%sz%s [%s]rO)rrr getwriterrrr add_sectionvaluesrvrxflagsr#setrSwrite)rrrrrKrr+r,r,r- write_exportss   rc cs$t}z |VW5t|XdSr)tempfilemkdtemprrmtree)tdr,r,r-tempdirs rc cs.t}zt|dVW5t|XdSr)rigetcwdchdir)rcwdr,r,r-rs   rc cs.t}zt|dVW5t|XdSr)socketgetdefaulttimeoutsetdefaulttimeout)secondsctor,r,r-socket_timeouts   rc@seZdZddZdddZdS)cached_propertycCs ||_dSr)func)selfrr,r,r-__init__szcached_property.__init__NcCs,|dkr |S||}t||jj||Sr)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|krh|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. rhrzpath '%s' cannot be absolutezpath '%s' cannot end with '/')rirk ValueErrorrcurdirremoverjr#)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-rszFileOperator.__init__cCsd|_t|_t|_dSNF)recordr files_written dirs_createdrr,r,r-rszFileOperator._init_recordcCs|jr|j|dSr)rradd)rrjr,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)rirjexistsrabspathstatst_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_dirrirjdirnameloggerinforislinkrisfilerrcopyfiler)rinfileoutfilecheckmsgr,r,r- copy_file s    zFileOperator.copy_fileNcCstj|rt|tj|td|||jsv|dkrJt |d}nt j |d|d}zt ||W5| X||dS)NzCopying stream %s to %swbwencoding)rirjisdirrlrrrrropenrrr copyfileobjr)rinstreamrr outstreamr,r,r- copy_streams  zFileOperator.copy_streamc Cs\|tj||jsNtj|r.t|t|d}||W5QRX| |dS)Nr) rrirjrrrrrrr)rrjrfr,r,r-write_binary_file)s   zFileOperator.write_binary_filecCs||||dSr)r encode)rrjrrr,r,r-write_text_file2szFileOperator.write_text_filecCsntjdkstjdkrjtjdkrj|D]F}|jr:td|q"t|j|B|@}td||t||q"dS)Nposixjavazchanging mode of %szchanging mode of %s to %o) rirS_namerrrrst_modechmod)rbitsmaskfilesr moder,r,r-set_mode5szFileOperator.set_modecCs|dd|S)Nimi)r)r+r r,r,r-AzFileOperator.cCs|tj|}||jkrxtj|sx|j|tj|\}}||t d||j sft ||j rx|j |dS)Nz Creating %s)rirjrrrrrrrrrmkdirrr)rrjrr r,r,r-rCs    zFileOperator.ensure_dirc Cst|| }td|||js|s0|||rX|s:d}n||sHt|t|d}i}|rtt drt |t j s~t j j }||d<t j |||df||||S)NzByte-compiling %s to %sPycInvalidationModeinvalidation_modeT)r rrrrrYrlrmr py_compilerr CHECKED_HASHcompiler) rrjoptimizeforcerxhashed_invalidationdpathdiagpathcompile_kwargsr,r,r- byte_compileOs    zFileOperator.byte_compilecCstj|rtj|r^tj|s^td||js@t ||j r||j kr|j |nPtj|rpd}nd}td|||jst ||j r||j kr|j |dS)NzRemoving directory tree at %slinkfilezRemoving %s %s)rirjrrrrdebugrrrrrrr)rrjr+r,r,r-ensure_removedbs"       zFileOperator.ensure_removedcCsDd}|s@tj|r$t|tj}q@tj|}||kr:q@|}q|Sr)rirjraccessW_OKr)rrjr'parentr,r,r- is_writablews  zFileOperator.is_writablecCs"|js t|j|jf}||S)zV Commit recorded changes, turn off recording, return changes. )rrlrrr)rr'r,r,r-commits  zFileOperator.commitcCs|jst|jD]}tj|rt|qt|jdd}|D]F}t |}|rz|dgks^t tj ||d}t |t |q>| dS)NT)reverse __pycache__r)rlistrrirjrrsortedrlistdirrlr#rmdirr)rr dirsrflistsdr,r,r-rollbacks     zFileOperator.rollback)F)T)N)FFNF)rrrrrrrrr r r rset_executable_moderr&r*r.r/r9r,r,r,r-rs         rcCs^|tjkrtj|}nt|}|dkr,|}n.|d}t||d}|D]}t||}qJ|S)N.r)rmodules __import__rrrp) module_name dotted_pathmodr'r*rr,r,r-resolves    rAc@s6eZdZddZeddZddZddZej Z d S) ExportEntrycCs||_||_||_||_dSrrSrxrvr)rrSrxrvrr,r,r-rszExportEntry.__init__cCst|j|jSr)rArxrvrr,r,r-rszExportEntry.valuecCsd|j|j|j|jfS)NzrCrr,r,r-__repr__szExportEntry.__repr__cCsDt|tsd}n0|j|jko>|j|jko>|j|jko>|j|jk}|Sr)rrBrSrxrvr)rotherr'r,r,r-__eq__s  $ zExportEntry.__eq__N) rrrrrrrDrFr__hash__r,r,r,r-rBs  rBz(?P([^\[]\S*)) \s*=\s*(?P(\w+)([:\.]\w+)*) \s*(\[\s*(?P[\w-]+(=\w+)?(,\s*\w+(=\w+)?)*)\s*\])? c Cst|}|s0d}d|ks"d|krtd|n|}|d}|d}|d}|dkrf|d}}n"|dkrztd||d\}}|d } | dkrd|ksd|krtd|g} nd d | d D} t|||| }|S) NrBrCzInvalid specification '%s'rScallable:rrrcSsg|] }|qSr,rX)rPr r,r,r-rRsz$get_export_entry..rD)ENTRY_REsearchr groupdictcountrrB) specificationr&r'rrSrjcolonsrxrvrr,r,r-rs8   rcCs|dkr d}tjdkr.dtjkr.tjd}n tjd}tj|rft|tj}|st d|n|dd\}}d|kr.|}n|dd\}}|rJt|}|rVt|}|||fS)NrErrI)rsplitrr)r]usernamepasswordrxr,r,r-parse_credentials/srecCstd}t||S)N)riumaskrr,r,r-get_process_umask>s  rhcCs<d}d}t|D]\}}t|tsd}q,q|dk s8t|S)NTF) enumeraterrrl)seqr'rbr+r,r,r-is_string_sequenceDs  rkz3([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}|dkrt |}|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_VERSIONrLrstartrmrerescaperPROJECT_NAME_AND_VERSION)filename project_namer'pyverr&nr,r,r-split_filenameTs"   rwz-(?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'rSver)NAME_VERSION_RErrrMrXr)rr&rr,r,r-parse_name_and_versionrs  rzcCst}t|pg}t|pg}d|kr8|d||O}|D]x}|dkrT||q<|dr|dd}||krtd|||kr||q<||krtd|||q<|S)N*rmrzundeclared extra: %s)rrrrYrrX) requested availabler'runwantedr,r,r- get_extrass&        rc Csi}zNt|}|}|d}|ds8td|ntd|}t |}Wn0t k r}zt d||W5d}~XYnX|S)Nz Content-Typezapplication/jsonz(Unexpected response for JSON request: %srz&Failed to get external data for %s: %s) r rgetrYrr)rrrrr exception)rVr'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)rSrVr'r,r,r-get_project_datas rcCs(d|d||f}tt|}t|S)Nz%s/%s/package-%s.jsonrr)rSversionrVr,r,r-get_package_datas rc@s*eZdZdZddZd ddZddZd S) Cachez A class implementing a cache for resources that need to live in the file system e.g. shared libraries. This class was moved from resources to here because it could be used by other modules, e.g. the wheel module. 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) rirjrrYrrrrXrnormpathru)rrur,r,r-rs    zCache.__init__TcCs t||dS)zN Converts a resource prefix to a directory name in the cache. )r^)r_)rrxr^r,r,r- prefix_to_dirszCache.prefix_to_dirc Csg}t|jD]r}tj|j|}z>tj|s>tj|rJt|ntj|r`t |Wqt k r| |YqXq|S)z" Clear the cache. ) rir4rurjr#rrrrrrrr!)r not_removedfnr,r,r-clears  z Cache.clearN)T)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-rszEventMixin.__init__TcCsD|j}||krt|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)rrr! appendleft)revent subscriberr!subssqr,r,r-rs  zEventMixin.addcCs,|j}||krtd||||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-r s 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 Oslg}||D]F}z||f||}Wn"tk rHtdd}YnX||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!r))rrargskwargsr'rrr,r,r-publishs    zEventMixin.publishN)T) 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:szSequencer.__init__cCs|j|dSr)rrrnoder,r,r-add_node?szSequencer.add_nodeFcCs||jkr|j||rt|j|dD]}|||q,t|j|dD]}|||qPt|jD]\}}|sp|j|=qpt|jD]\}}|s|j|=qdS)Nr,)rrrrrrr2r)rredgesrr+rrKr,r,r- remove_nodeBs   zSequencer.remove_nodecCs<||ks t|j|t||j|t|dSr)rlr setdefaultrrr)rpredsuccr,r,r-rRs z Sequencer.addcCs||ks tz|j|}|j|}Wn tk rDtd|YnXz||||Wn$tk rtd||fYnXdS)Nz%r not a successor of anythingz%r not a successor of %r)rlrrKeyErrorrr)rrrpredssuccsr,r,r-rWs   zSequencer.removecCs||jkp||jkp||jkSr)rrr)rstepr,r,r-is_stepdszSequencer.is_stepcCs||std|g}g}t}|||r|d}||krb||kr||||q.|||||j|d}| |q.t |S)Nz Unknown: %rrr,) rrrr!rprrrrextendreversed)rfinalr'todoseenrrr,r,r- get_stepsgs"         zSequencer.get_stepscsRdggiig|jfddD]}|kr8|q8S)Nrcsd|<d|<dd7<|z |}Wntk rVg}YnX|D]J}|kr|t|||<q\|kr\t|||<q\||krg}}||||krqqt|}|dSNrr)r!rminrptuple)r successors successorconnected_component componentgraphindex index_counterlowlinksr'stack strongconnectr,r-rs,      z3Sequencer.strong_connections..strongconnect)rrr,rr-strong_connectionss# 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.dotN)F) rrrrrrrrrrpropertyrrr,r,r,r-r8s   3r).tar.gz.tar.bz2.tar.zip.tgz.tbz.whlc sZfdd}tjtd}|dkr|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| _qdd} | |_|W5|rT|XdS)NcsRt|ts|d}tjtj|}|rB|tjkrNt d|dS)Nrzpath outside destination: %r) rrdecoderirjrr#rYrkr)rjrdest_dirplenr,r- check_paths   zunarchive..check_path)rrzip)rrtgzzr:gz)rrtbzzr:bz2rtarr~zUnknown format for %rrrrc SsDzt||WStjk r>}ztt|W5d}~XYnXdS)z9Run tarfile.tar_filter, but raise the expected ValueErrorN)tarfile tar_filter FilterErrorrstr)memberrjexcr,r,r-extraction_filtersz$unarchive..extraction_filter)rirjrrmr`rrrnamelistrrgetnamesrr getmembersrrSrrr extractall) archive_filenamerformatrrarchivernamesrStarinforr,rr- unarchivesL           rc Cs~t}t|}t|dZ}t|D]H\}}}|D]8}tj||}||d} tj| |} ||| q4q&W5QRX|S)z*zip a directory tree into a BytesIO objectrN) ioBytesIOrmrriwalkrjr#r) directoryr'dlenzfrnr6rrSfullrelrwr,r,r-zip_dir s  r)rKMGTPc@sreZdZdZdddZddZdd Zd d Zd d Ze ddZ e ddZ ddZ e ddZ e ddZdS)ProgressUNKNOWNrdcCs<|dks||kst||_|_||_d|_d|_d|_dS)NrF)rlrcurmaxstartedelapseddone)rminvalmaxvalr,r,r-r$s  zProgress.__init__cCsV|j|kst|jdks&||jks&t||_t}|jdkrF||_n ||j|_dSr)rrlrrtimerr)rcurvalnowr,r,r-update,s zProgress.updatecCs |dks t||j|dS)Nr)rlr r)rincrr,r,r- increment6s zProgress.incrementcCs||j|Sr)r rrr,r,r-ro:s zProgress.startcCs |jdk r||jd|_dS)NT)rr rrr,r,r-stop>s  z Progress.stopcCs|jdkr|jS|jSr)runknownrr,r,r-maximumCszProgress.maximumcCsD|jr d}n4|jdkrd}n$d|j|j|j|j}d|}|S)Nz100 %z ?? %gY@z%3d %%)rrrr)rr'rKr,r,r- percentageGs zProgress.percentagecCs:|dkr|jdks|j|jkr$d}ntdt|}|S)Nrz??:??:??z%H:%M:%S)rrrrstrftimegmtime)rdurationr'r,r,r-format_durationRszProgress.format_durationcCs|jrd}|j}n^d}|jdkr&d}nJ|jdks<|j|jkrBd}n.t|j|j}||j|j}|d|j}d|||fS)NDonezETA rrrz%s: %s)rrrrrfloatr)rrxrcr,r,r-ETA[s z Progress.ETAcCsL|jdkrd}n|j|j|j}tD]}|dkr6q@|d}q&d||fS)Nrgig@@z%d %sB/s)rrrUNITS)rr'unitr,r,r-speedns  zProgress.speedN)rr)rrrr rr r ror rrrrrrr,r,r,r-r!s      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_GLOBrLr_CHECK_MISMATCH_SET_iglob) path_globrr,r,r-rs    rc cst|d}t|dkrht|dks,t||\}}}|dD]$}td|||fD] }|VqXq@nd|krt|D] }|Vqxn~|dd\}}|dkrd}|dkrd}n|d}|d }t |D]4\}}} tj |}ttj ||D] } | VqqdS) NrrrDrz**r;r{rh\) RICH_GLOBrrmrlrr# std_iglobr$rirrjr) rrich_path_globrxrrvitemrjradicaldirrrr,r,r-rs*         r) HTTPSHandlermatch_hostnameCertificateErrorc@seZdZdZdZddZdS)HTTPSConnectionNTcCs"t|j|jf|j}t|ddr0||_|t tj }t tdrV|j tj O_ t|ddrr||j|ji}|jrtj|_|j|jdttddr|j|d<|j|f||_|jr|jrz$t|j|jtd|jWn0tk r|jtj|jYnXdS) N _tunnel_hostF OP_NO_SSLv2 cert_file)cafileHAS_SNIserver_hostnamezHost verified: %s)rcreate_connectionhostporttimeoutrsock_tunnelssl SSLContextPROTOCOL_SSLv23roptionsr*load_cert_chainr+key_fileca_certs CERT_REQUIRED verify_modeload_verify_locations wrap_socket check_domainr& getpeercertrr)r'shutdown SHUT_RDWRr)rr3contextrr,r,r-connects0       zHTTPSConnection.connect)rrrr;r@rEr,r,r,r-r(sr(c@s&eZdZd ddZddZddZdS) r%TcCst|||_||_dSr)BaseHTTPSHandlerrr;r@)rr;r@r,r,r-rs zHTTPSHandler.__init__cOs$t||}|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(r;r@)rrrr'r,r,r- _conn_makers zHTTPSHandler._conn_makerc CsXz||j|WStk rR}z$dt|jkr@td|jnW5d}~XYnXdS)Nzcertificate verify failedz*Unable to verify server certificate for %s)do_openrGrrreasonr'r0)rr^rr,r,r- https_openszHTTPSHandler.https_openN)T)rrrrrGrJr,r,r,r-r%s r%c@seZdZddZdS)HTTPSOnlyHandlercCstd|dS)NzAUnexpected HTTP request on what should be a secure connection: %s)r)rr^r,r,r- http_openszHTTPSOnlyHandler.http_openN)rrrrLr,r,r,r-rKsrKc@seZdZdddZddZdS) TransportrcCs||_tj||dSr)r2rrMrrr2 use_datetimer,r,r-r szTransport.__init__cCsD||\}}}|jr$||jdkr:||_|t|f|_|jdSr) get_host_info _connection_extra_headersrHTTPConnection)rr0hehx509r,r,r-make_connection s zTransport.make_connectionN)rrrrrrWr,r,r,r-rMs rMc@seZdZdddZddZdS) SafeTransportrcCs||_tj||dSr)r2rrYrrNr,r,r-rszSafeTransport.__init__cCs\||\}}}|si}|j|d<|jr6||jdkrR||_|tj|df|f|_|jdS)Nr2rr)rPr2rQrRrr()rr0rTrUrr,r,r-rWs zSafeTransport.make_connectionN)rrXr,r,r,r-rYs rYc@seZdZddZdS) ServerProxycKst|dd|_}|dk r^t|d}|dd}|dkr@t}nt}|||d|d<}||_tjj ||f|dS)Nr2rrOhttps)rO transport) rpr2rrrYrMr\rrZr)rrarr2r\rOtclsrcr,r,r-r*s  zServerProxy.__init__N)rrrrr,r,r,r-rZ(srZcKs6tjddkr|d7}nd|d<d|d<t||f|S)Nrrbrnewlinerr)rrr)rrrr,r,r- _csv_openAs  r`c@s4eZdZedededdZddZddZd S) CSVBaserD"r) delimiter quotecharlineterminatorcCs|Srr,rr,r,r- __enter__SszCSVBase.__enter__cGs|jdSr)rr)rrTr,r,r-__exit__VszCSVBase.__exit__N)rrrrdefaultsrfrgr,r,r,r-raLs rac@s(eZdZddZddZddZeZdS) CSVReadercKs\d|kr4|d}tjddkr,td|}||_nt|dd|_tj|jf|j|_dS)Nrrrrrjr~) rrrrrr`csvrrh)rrrr,r,r-r\szCSVReader.__init__cCs|Srr,rr,r,r-__iter__gszCSVReader.__iter__cCsFt|j}tjddkrBt|D] \}}t|ts |d||<q |SNrrr)nextrrrrirrr)rr'rbr"r,r,r-rmjs   zCSVReader.nextN)rrrrrkrm__next__r,r,r,r-riZs ric@seZdZddZddZdS) CSVWritercKs$t|d|_tj|jf|j|_dS)Nr)r`rrjwriterrh)rrrr,r,r-rws zCSVWriter.__init__cCsNtjddkr>g}|D]"}t|tr.|d}||q|}|j|dSrl)rrrrr r!rpwriterow)rrowr~r"r,r,r-rq{s   zCSVWriter.writerowN)rrrrrqr,r,r,r-rousrocsHeZdZeejZded<d fdd ZddZdd Zd d Z Z S) Configurator inc_convertincNcs"tt|||pt|_dSr)superrsrrirru)rconfigru __class__r,r-rszConfigurator.__init__c sfddd}t|s*|}dd}dd}|r\tfdd|D}fd dD}t|}|||}|r|D]\}} t||| q|S) Ncsvt|ttfr*t|fdd|D}nHt|trhd|krH|}qri}|D]}||||<qPn |}|S)Ncsg|] }|qSr,r,)rPrbconvertr,r-rRszBConfigurator.configure_custom..convert..())rr2rtypedictconfigure_customr{)or'r)r{rr,r-r{s   z.Configurator.configure_custom..convertr|r;z[]r,csg|] }|qSr,r,)rPrrzr,r-rRsz1Configurator.configure_custom..cs$g|]}t|r||fqSr,)r)rPr)rwr{r,r-rRs)rprHrArr~rsetattr) rrwrpropsrrrr'rvrKr,)rwr{rr-rs     zConfigurator.configure_customcCs4|j|}t|tr0d|kr0|||j|<}|S)Nr|)rwrr~r)rrr'r,r,r- __getitem__s zConfigurator.__getitem__c CsFtj|stj|j|}tj|ddd}t|}W5QRX|S)z*Default converter for the inc:// protocol.r~rr) rirjisabsr#rurrrr)rrr r'r,r,r-rts  zConfigurator.inc_convert)N) rrrr~rvalue_convertersrrrrt __classcell__r,r,rxr-rss   rsc@s*eZdZdZd ddZddZdd ZdS) SubprocessMixinzC Mixin for running subprocesses and capturing their output FNcCs||_||_dSr)verboseprogress)rrrr,r,r-rszSubprocessMixin.__init__cCsj|j}|j}|}|sq^|dk r.|||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. Nr;r) rrreadlinerstderrrrflushr)rrrDrrr+r,r,r-rs  zSubprocessMixin.readercKstj|ftjtjd|}tj|j|jdfd}|tj|j|jdfd}|| | | |j dk r| ddn|j rt jd|S)N)stdoutrr)rrrzdone.mainzdone. ) subprocessPopenPIPE threadingThreadrrrorwaitr#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[-_.]+rm)rpsubr)rSr,r,r-normalize_namesrc@s.eZdZdZdZd ddZddZdd ZdS) PyPIRCFilezhttps://upload.pypi.org/legacy/pypiNcCs.|dkrtjtjdd}||_||_dS)NrSz.pypirc)rirjr#rWrsrV)rrrVr,r,r-rszPyPIRCFile.__init__c Csi}tj|jr||jp|j}t}||j| }d|kr*| dd}dd| dD}|gkr~d|kr|dg}n|D]}d|i}| |d|d<d |jfd |j fd fD].\}} | ||r| ||||<q| ||<q|dkr ||jdfkr |j|d <q|d|kr|d |kri}qnRd |kr|d }| |d rT| |d }n|j}| |d| |d |||j d}|S)N distutilsz index-serverscSs g|]}|dkr|qS)rrJ)rPserverr,r,r-rRs z#PyPIRCFile.read..rrrrc repositoryrealm)rdNz server-loginrd)rcrdrrr)rirjrrsrVDEFAULT_REPOSITORYrRawConfigParserrrrr DEFAULT_REALM has_option) rr'rrwr index_servers_serversrrrr,r,r-r sJ           zPyPIRCFile.readc Cslt}|j}|||ds,|d|dd||dd|t|d}||W5QRXdS)Nrrcrdr) rrrsr has_sectionrrrr)rrcrdrwrr r,r,r-r Bs    zPyPIRCFile.update)NN)rrrrrrrr r,r,r,r-rs  5rcCst|jdS)zG Read the PyPI access configuration as supported by distutils. )rV)rrVrrr,r,r- _load_pypircOsrcCst|j|jdSr)rr rcrdrr,r,r- _store_pypircVsrc CstjdkrFdtjkrdSdtjkr.dSdtjkr@dStjSdtjkrZtjdStjd 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|}nd|dd!d$krddl} zdd%lm} Wntk rddl} YnX| | |||\}}}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'. rQamd64 win-amd64z(arm) win-arm32z(arm64)z win-arm64_PYTHON_HOST_PLATFORMrunamerhrrlrdrmNlinuxz%s-%ssunosr5solarisz%d.%sr32bit64bit)ilz.%saix) aix_platformcygwinz[\d.]+darwin) sysconfigz%s-%s-%s)rirSrrrplatformrUrrr intmaxsize _aix_supportrrprASCIIrr _osx_supportrr ImportErrorget_platform_osxget_config_vars) osnamer0releasermachinebitnessrrel_rer&rrr,r,r-get_host_platform`sP         rwin32rr)x86x64armcCs2tjdkrtStjd}|tkr*tSt|S)NrQVSCMD_ARG_TGT_ARCH)rirSrrUr_TARGET_TO_PLAT)cross_compilation_targetr,r,r- get_platforms   r)NN)r)N)T)N)NT)r collectionsr contextlibrjglobrr rrloggingrirrprr5rrrrrrrZdummy_threadingrrrcompatrrrr r r r r rrrrrrrrrrrr getLoggerrrrrrHrGr6r>r:r[r"r@rfrrrrrrrcontextmanagerrrrrrrrrArBVERBOSErKrr\r_rarerhrkIrrrnrwryrzrrrrrrrrARCHIVE_EXTENSIONSrrrrrrrrr%rFr&r'r(rKrMrYrZr`rarirorsrrrrrrrrr,r,r,r-s      X         Z|   /   ; )     ,I D^    !*  8.M T