h/ xUdZddlmZddlZejdkr edddlZddlZddlZddl Z ddl Z ddl m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZddlZddlZddlZddlZddl Z ddl!Z!ddl"Z"ddl#Z#ddl$Z$ddl%Z%ddl&Z'ddl(Z(ddl)Z)ddl*Z*ddl+Z+ddl,Z,ddl-Z-ddl.Z.ddl/Z.ddl0Z.ddl!m1Z1ddl2Z2ddlm3Z3dd lm4Z5dd l6m7Z7m8Z8 dd lm9Z9m:Z:m;Z;d Zm?Z?m@Z@mAZAddlBmCZDddlBmEZFddlBmGZHddlBmIZJddlKmLZMerddlNmOZOmPZPmQZQddlRmSZSedZTeddZUeeVeeeVedffZWedgdfZXedgedfZYeeVdfZZedeZfZ[edZ\e Z]e Z^ee_e j`fZaee gdfZbeeTeVecgedfZdeeTeVeVe j`geeVdffZeedede ebeee ZfGd d!eZgGd"d#eZhe jid$e jjZkGd%d&elZmeJjnZoiZpd'eqd(<d d.Zrd d0Zsd d2Ztd3Zud4Zvd5Zwd6Zxd7xZyZzd8Z{gd9Z|Gd:d;e}Z~Gd<d=e~ZGd>d?eZGd@dAe~ZGdBdCe~ZiZdDeqdE<dFjejZdGZdHZdIZdZdJZddOZeddQZeddRZddUZe jdVdWZdXZdYZe jidZZe jid[ZeZdd_ZeddaZeddcZddeZddjZe dddmZeddoZdddpZddqZGdrdseZGdtdeeZGdudvZGdwdxedeeVdyffZGdzd{ZeZGd|d}eZGd~dZddZddZddZdZdZddZddZd dZdd!dZGddZee_edZGddeZGddeZeGddeZeZGddeeVdfZGddeZGddeZeejeGddeZGddeZGddeZerddiZdeqd<d"dZd#d$dZ d#d%dZeeje d#d&dZee_ed#d'dZdZGddZd(dZd)dZdZdZee!dree!jeee.jjeerddiZdeqd<erddiZdeqd<d*dƄZdDŽZːd+dʄZ̐d,d̄Z͐dd-d΄Zΐd.dфZee!dree!jeϦeejeϦee.jjeϦd/dӄZee_eЦed0dՄZed1d؄Zѐd2dلZѐd2dڄZer ed0dۄZed1d܄ZӐd3dބZne jdVd߄ZdZdZdZdZe jidjZe jide je jzjZGddZdZGddZGddeߦZGddeߦZeeedZdZd4dZGddeFjZGddeFjZdZd5dZd(dZdZd6dZdZejdemd GddeZejdkrdndZefd7dZdZeefd Zed Zer{eZejZejZejZejZejZejZejZejZeZejZejZejZejZeZdSdS(8a Package resource API -------------------- A resource is a logical file contained within a package, or a logical subdirectory thereof. The package resource API expects resource names to have their path parts separated with ``/``, *not* whatever the local path separator is. Do not use os.path operations to manipulate resource names being passed into the API. The package resource API is designed to work with normal filesystem packages, .egg files, and unpacked .egg files. It can also work in a limited way with .zip files and with custom PEP 302 loaders that support the ``get_data()`` method. This module is deprecated. Users are directed to :mod:`importlib.resources`, :mod:`importlib.metadata` and :pypi:`packaging` instead. ) annotationsN)zPython 3.8 or later is required)AnyLiteralDictIteratorMappingMutableSequence NamedTupleNoReturnTupleUnion TYPE_CHECKINGProtocolCallableIterableTypeVaroverload) get_importer)utime)open)isdirsplit)mkdirrenameunlinkTF) yield_lines drop_commentjoin_continuation)markers) requirements)utilsversion)user_cache_dir) BytesPathStrPathStrOrBytesPath)Self_T_DistributionT Distribution)bound _NestedStr Requirement)r-N)IResourceProviderNr1 _AdapterTceZdZddZdS)_LoaderProtocolfullnamestrreturntypes.ModuleTypecdSN)selfr5s /builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/pkg_resources/__init__.py load_modulez_LoaderProtocol.load_moduleN)r5r6r7r8)__name__ __module__ __qualname__r>r;r@r=r4r4sDDDDDDr@r4ceZdZUded<dS)_ZipLoaderModulezipimport.zipimporter __loader__NrArBrC__annotations__r;r@r=rErEs%%%%%%r@rEz,^v?(?P(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)ceZdZdZdS) PEP440Warningza Used when there is an issue with a version or specifier not complying with PEP 440. NrArBrC__doc__r;r@r=rKrKsr@rKzdict[str, str] _state_varsvartyper6varname initial_valuer7c|t|<|Sr:)rN)rOrPrQs r=_declare_staterSs"K r@dict[str, Any]ci}t}tD]"\}}|d|z||||<#|S)N_sget_)globalsrNitemsstategkvs r= __getstate__r^sU E A!!##))1"1X\?1Q4((a Lr@rZct}|D],\}}|dt|z||||-|S)N_sset_)rWrXrNrYs r= __setstate__rasT A 111$([^ #$Q!a0000 Lr@c*|Sr:)copyvals r= _sget_dictrfs 88::r@cX|||dSr:)clearupdatekeyobrZs r= _sset_dictrms'HHJJJIIer@c*|Sr:)r^rds r= _sget_objectros     r@c0||dSr:)rarjs r= _sset_objectrqsOOEr@cdSr:r;argss r=rusr@c t}t|}|ctjdkrSddt ddd|d}n#t$rYnwxYw|S)aQReturn this platform's maximum compatible version. distutils.util.get_platform() normally reports the minimum version of macOS that would be required to *use* extensions produced by distutils. But what we want when checking compatibility is to know the version of macOS that we are *running*. To allow usage of packages that explicitly require a newer version of macOS, we must also know the current version of the OS. If this condition occurs for any other platform with a version in its platform strings, this function should be extended accordingly. Ndarwinmacosx-.-r) get_build_platformmacosVersionStringmatchsysplatformjoin _macos_versgroup ValueError)platms r=get_supported_platformrs   D  &&A}11 %(XXkmmBQB.?%@%@%@%@!''!***MDD    D  KsAA>> B  B )Grequire run_script get_providerget_distributionload_entry_point get_entry_mapget_entry_infoiter_entry_pointsresource_stringresource_streamresource_filenameresource_listdirresource_existsresource_isdirdeclare_namespace working_setadd_activation_listenerfind_distributionsset_extraction_pathcleanup_resourcesget_default_cache Environment WorkingSetResourceManagerr-r0 EntryPointResolutionErrorVersionConflictDistributionNotFound UnknownExtraExtractionErrorrKparse_requirements parse_version safe_name safe_version get_platformcompatible_platformsrsplit_sections safe_extra to_filenameinvalid_markerevaluate_markerensure_directorynormalize_pathEGG_DIST BINARY_DIST SOURCE_DIST CHECKOUT_DIST DEVELOP_DISTIMetadataProviderr1 FileMetadata PathMetadata EggMetadata EmptyProviderempty_provider NullProvider EggProviderDefaultProvider ZipProviderregister_finderregister_namespace_handlerregister_loader_typefixup_namespace_packagesrPkgResourcesDeprecationWarningrun_mainAvailableDistributionsceZdZdZdZdS)rz.Abstract base for dependency resolution errorscD|jjt|jzSr:) __class__rAreprrtr<s r=__repr__zResolutionError.__repr__8s~&di88r@N)rArBrCrMrr;r@r=rr5s)8899999r@rcTeZdZdZdZed dZeddZdZdd Z d S)rz An already-installed version conflicts with the requested version. Should be initialized with the installed Distribution and the requested Requirement. z3{self.dist} is installed but {self.req} is requiredr7r-c|jdSNrrsrs r=distzVersionConflict.distFy|r@r0c|jdSNrsrs r=reqzVersionConflict.reqJrr@c>|jjditSNr; _templateformatlocalsrs r=reportzVersionConflict.reportN!$t~$00vxx000r@ required_byset[Distribution | str]c2|s|S|j|fz}t|S)zt If required_by is non-empty, return a version of self that is a ContextualVersionConflict. )rtContextualVersionConflict)r<rrts r= with_contextzVersionConflict.with_contextQs*  KyK>)($//r@Nr7r-r7r0)rr) rArBrCrMrpropertyrrrrr;r@r=rr<sFI XX111000000r@rc>eZdZdZejdzZeddZdS)rz A VersionConflict that accepts a third parameter, the set of the requirements that required the installed Distribution. z by {self.required_by}r7set[str]c|jdS)Nrzrsrs r=rz%ContextualVersionConflict.required_bydrr@N)r7r)rArBrCrMrrrrr;r@r=rr\sL  ),DDI Xr@rcheZdZdZdZed dZed dZedZd Z d Z d S)rz&A requested distribution was not foundzSThe '{self.req}' distribution was not found and is required by {self.requirers_str}r7r0c|jdSrrsrs r=rzDistributionNotFound.reqqrr@set[str] | Nonec|jdSrrsrs r= requirerszDistributionNotFound.requirersurr@cH|jsdSd|jS)Nzthe applicationz, )rrrs r= requirers_strz"DistributionNotFound.requirers_strys&~ %$$yy(((r@c>|jjditSrrrs r=rzDistributionNotFound.reportrr@c*|Sr:)rrs r=__str__zDistributionNotFound.__str__s{{}}r@Nr)r7r) rArBrCrMrrrrrrrr;r@r=rris00 2 XX))X) 111r@rceZdZdZdS)rz>Distribution doesn't have an "extra feature" of the given nameNrLr;r@r=rrsHHHHr@rz-dict[type[_ModuleLike], _ProviderFactoryType]_provider_factoriesz{}.{}rrzr loader_typetype[_ModuleLike]provider_factory_ProviderFactoryTypec|t|<dS)aRegister `provider_factory` to make providers for `loader_type` `loader_type` is the type or class of a PEP 302 ``module.__loader__``, and `provider_factory` is a function that, passed a *module* object, returns an ``IResourceProvider`` for that module. N)r)rrs r=rrs(8 $$$r@ moduleOrReqcdSr:r;rs r=rr9<r@cdSr:r;rs r=rrs>%  :eT"" 2b ( b 1 1  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2=00'(89 ==  sA22A69A6c4ddd||S)Nppc)PowerPCPower_Macintosh)get)machines r= _macos_archr"s  7 7 ; ;GW M MMr@c~ddlm}|}tjdkr|ds t }t jddd}dt|dt|d t|fzS#t$rYnwxYw|S) zReturn this platform's string for platform-specific distributions XXX Currently this is the same as ``distutils.util.get_platform()``, but it needs some hacks for Linux and macOS. r)rrwrx _zmacosx-%d.%d-%sr) sysconfigrrr startswithrrunamereplaceintr"r)rrr%r!s r=r|r|s '&&&&& <>>D |x (B(B !mmGhjjm++C55G$GAJGAJG$$(      D  KsA5B-- B:9B:zmacosx-(\d+)\.(\d+)-(.*)zdarwin-(\d+)\.(\d+)\.(\d+)-(.*)provided str | Nonerequiredc||||krdSt|}|rGt|}|st|}|rit|d}|dd|d}|dkr|dks |dkr|d krdSd S|d|dks,|d |d krd St|dt|dkrd SdSd S) zCan code for the `provided` platform run on the `required` platform? Returns true if either platform is ``None``, or the platforms are equal. XXX Needs compatibility checks for Linux and other unixy OSes. NTrryrzz10.3rz10.4Fr)r}r~darwinVersionStringr+r)r,r.reqMacprovMac provDarwindversion macosversions r=rrss8+x8/C/Ct % %h / /F $**844 -228<Acr@ _PkgReqTypecdSr:r;r8s r=rrrr@Distribution | _PkgReqTypect|trt|}t|trt |}t|t st d||S)z@Return a current distribution object for a Requirement or stringz*Expected str, Requirement, or Distribution)rr6r0parserr- TypeErrorr8s r=rrso$'  &&$ $$"D!! dL ) )LDdKKK Kr@ _EPDistTypername_ResolvedEntryPointcHt|||S)zDReturn `name` entry point of `group` for `dist` or raise ImportError)rrrrr@s r=rr#s D ! ! 2 25$ ? ??r@None dict[str, dict[str, EntryPoint]]cdSr:r;rrs r=rr(s (+sr@dict[str, EntryPoint]cdSr:r;rGs r=rr,sKN3r@cFt||S)=Return the entry point map for `group`, or the full entry map)rrrGs r=rr.s D ! ! / / 6 66r@cHt|||SzeZdZddZddZddZdd Zdd ZddZdS)rr@r6r7boolcdS)z;Does the package's distribution contain the named metadata?Nr;r<r@s r= has_metadatazIMetadataProvider.has_metadata9r?r@cdS)z'The named metadata resource as a stringNr;rQs r= get_metadatazIMetadataProvider.get_metadata<r?r@ Iterator[str]cdS)zYield named metadata resource as list of non-blank non-comment lines Leading and trailing whitespace is stripped from each line, and lines with ``#`` as the first non-blank character are omitted.Nr;rQs r=get_metadata_linesz$IMetadataProvider.get_metadata_lines?r?r@cdS)z>Is the named metadata a directory? (like ``os.path.isdir()``)Nr;rQs r=metadata_isdirz IMetadataProvider.metadata_isdirEr?r@ list[str]cdS)z?List of metadata names in the directory (like ``os.listdir()``)Nr;rQs r=metadata_listdirz"IMetadataProvider.metadata_listdirHr?r@ script_name namespacerTrDcdS)z=Execute the named script in the supplied namespace dictionaryNr;)r<r]r^s r=rzIMetadataProvider.run_scriptKr?r@Nr@r6r7rO)r@r6r7r6r@r6r7rUr@r6r7rZ)r]r6r^rTr7rD) rArBrCrRrTrWrYr\rr;r@r=rr8sJJJJ6666DDDD MMMMNNNNLLLLLLr@rcBeZdZdZddZdd Zdd Zdd ZddZddZ dS)r1z3An object that provides access to package resourcesmanagerr resource_namer6r7cdS)zbReturn a true filesystem path for `resource_name` `manager` must be a ``ResourceManager``Nr;r<rdres r=get_resource_filenamez'IResourceProvider.get_resource_filenameRr?r@_ResourceStreamcdS)zgReturn a readable file-like object for `resource_name` `manager` must be a ``ResourceManager``Nr;rgs r=get_resource_streamz%IResourceProvider.get_resource_streamYr?r@bytescdS)zgReturn the contents of `resource_name` as :obj:`bytes` `manager` must be a ``ResourceManager``Nr;rgs r=get_resource_stringz%IResourceProvider.get_resource_string`r?r@rOcdS)z,Does the package contain the named resource?Nr;r<res r= has_resourcezIResourceProvider.has_resourcegr?r@cdS)z>Is the named resource a directory? (like ``os.path.isdir()``)Nr;rps r=rz IResourceProvider.resource_isdirjr?r@rZcdS)z?List of resource names in the directory (like ``os.listdir()``)Nr;rps r=rz"IResourceProvider.resource_listdirmr?r@N)rdrrer6r7r6)rdrrer6r7rirdrrer6r7rl)rer6r7rO)rer6r7rZ) rArBrCrMrhrkrnrqrrr;r@r=r1r1Os==333333333333;;;;MMMMNNNNNNr@ceZdZdZdKdLdZedZedZdMd ZdNdZ dOdZ dKdPdZ dQdZ dRdZ dSdTd!Ze dUdVd,Ze dKddd-dVd.Ze dWdXd1Z dWdYd4ZdZd5Ze d[d\d;Ze dKdd<d\d=Ze d]d^d?Z d]d_dAZd`dCZ d[dadGZdHZdIZdJZdS)brzDA collection of active distributions on sys.path (or a similar list)NentriesIterable[str] | Nonecg|_i|_i|_i|_g|_| t j}|D]}||dS)z?Create working set from list of path entries (default=sys.path)N)rv entry_keysby_keynormalized_to_canonical_keys callbacksrr add_entry)r<rventrys r=__init__zWorkingSet.__init__ts`"$  ,.) ?hG " "E NN5 ! ! ! ! " "r@c|} ddlm}n#t$r|cYSwxYw ||n%#t$r||cYSwxYw|S)z1 Prepare the master working set. r) __requires__)__main__r ImportErrorrr_build_from_requirements)clswsrs r= _build_masterzWorkingSet._build_masters SUU  - - - - - - -   III   > JJ| $ $ $ $ > > >// == = = = > s ""<AAc8|g}t|}||t}|D]}||tjD] }||jvr||!|jtjdd<|S)zQ Build a working set from a requirement spec. Rewrites sys.path. N)rresolveraddrrrvr})rreq_specrreqsdistsrr~s r=rz#WorkingSet._build_from_requirementssSWW!(++ 4//  D FF4LLLLX $ $EBJ&& U###j  r@r~r6c|j|g|j|t |dD]}|||ddS)aAdd a path item to ``.entries``, finding any distributions on it ``find_distributions(entry, True)`` is used to find distributions corresponding to the path entry, and they are added. `entry` is always appended to ``.entries``, even if it is already present. (This is because ``sys.path`` can contain the same value more than once, and the ``.entries`` of the ``sys.path`` WorkingSet should always equal ``sys.path``.) TFN)ry setdefaultrvappendrr)r<r~rs r=r}zWorkingSet.add_entrysn ""5"--- E"""&ud33 ) )D HHT5% ( ( ( ( ) )r@rr-r7rOcH|j|j|kS)z9True if `dist` is the active distribution for its project)rzr rkr<rs r= __contains__zWorkingSet.__contains__s{tx((D00r@rr0Distribution | Nonec|j|j}|B|j|j}|!||_|j|}|||vrt |||S)aFind a distribution matching requirement `req` If there is an active distribution for the requested project, this returns it as long as it meets the version requirement specified by `req`. But, if there is an active distribution for the project and it does *not* meet the `req` requirement, ``VersionConflict`` is raised. If there is no active distribution for the requested project, ``None`` is returned. )rzr rkr{r)r<rr canonical_keys r=rzWorkingSet.findsy{sw'' < =AA#'JJM('{}55  C!$,, , r@rr@r-c$fd|DS)aYield entry point objects from `group` matching `name` If `name` is None, yields all entry points in `group` from all distributions in the working set, otherwise only ones matching both `group` and `name` are yielded (in distribution order). c3K|]=}|D]} |jk|V>dSr:)rvaluesr@).0rr~rr@s r= z/WorkingSet.iter_entry_points..sq  ++E2299;;  |tuz11  21111   r@r;r<rr@s ``r=rzWorkingSet.iter_entry_pointss4         r@requiresr]ctjdj}|d}|||d<||d||dS)z?Locate distribution for `requires` and run `script_name` scriptrrArN)r _getframe f_globalsrhrr)r<rr]nsr@s r=rzWorkingSet.run_scripts` ]1   '*~  : Xq!,,["=====r@Iterator[Distribution]c#Kt}|jD]D}||jvr |j|D]*}||vr$|||j|V+EdS)zYield distributions for non-duplicate projects in the working set The yield order is the order in which the items' path entries were added to the working set. N)setrvryrrz)r<seenitemrks r=__iter__zWorkingSet.__iter__s uuL + +D4?**t, + +d??HHSMMM+c**** +  + +r@TFinsertr*c|r||j||||j}|j|g}|j|jg}|s|j|jvrdS||j|j<tj|j}|j|j |<|j|vr| |j|j|vr| |j| |dS)aAdd `dist` to working set, associated with `entry` If `entry` is unspecified, it defaults to the ``.location`` of `dist`. On exit from this routine, `entry` is added to the end of the working set's ``.entries`` (if it wasn't already present). `dist` is only added to the working set if it's for a project that doesn't already have a distribution in the set, unless `replace=True`. If it's added, any callbacks registered with the ``subscribe()`` method will be called. r*N) insert_onrvlocationryrrkrz_packaging_utilscanonicalize_namer{r _added_new)r<rr~rr*keyskeys2normalized_names r=rzWorkingSet.adds$  A NN4<N @ @ @ =ME))%44**4="== 48t{22 F $ DH*     0 1 1 1$4 9 9O,001ABBB.1j ?++ MM#   / 4r@c||j}||j|j}|||vr|r|} |5|t|j}ntg}t g} ||| ||x}||j<|&||d} t|| ||||vr+||} t|| | |S)N)r) r rkrzrrvr best_matchrrrr) r<rrrrrrrrrr dependent_reqs r=rzWorkingSet._resolve_distsxx   <;??37++D|C4G;|)$,77 *"oo'^^'*~~Y>>   t $ $ $ s??',M!$,,99-HH H r@ plugin_envrfull_envfallback:tuple[list[_DistributionT], dict[Distribution, Exception]]cdSr:r;r<rrrrs r= find_pluginszWorkingSet.find_pluginss FISr@)rcdSr:r;rs r=rzWorkingSet.find_pluginss FISr@8tuple[list[Distribution], dict[Distribution, Exception]]cdSr:r;rs r=rzWorkingSet.find_pluginss DG3r@Otuple[list[Distribution] | list[_DistributionT], dict[Distribution, Exception]]ct|}|i}i}|t|j}||z }n||z}|g} tt | j||D]} || D]} | g} | | ||} tt | j| | t | n$#t$r}||| <|rYd}~Yd}~nd}~wwxYwt|}|||fS)asFind all activatable distributions in `plugin_env` Example usage:: distributions, errors = working_set.find_plugins( Environment(plugin_dirlist) ) # add plugins+libs to sys.path map(working_set.add, distributions) # display errors print('Could not load', errors) The `plugin_env` should be an ``Environment`` instance that contains only distributions that are in the project's "plugin directory" or directories. The `full_env`, if supplied, should be an ``Environment`` contains all currently-available distributions. If `full_env` is not supplied, one is created automatically from the ``WorkingSet`` this method is called on, which will typically mean that every directory on ``sys.path`` will be scanned for distributions. `installer` is a standard installer callback as used by the ``resolve()`` method. The `fallback` flag indicates whether we should attempt to resolve older versions of a plugin if the newest version cannot be resolved. This method returns a 2-tuple: (`distributions`, `error_info`), where `distributions` is a list of the distributions found in `plugin_env` that were loadable, along with any other distributions that are needed to resolve their dependencies. `error_info` is a dictionary mapping unloadable plugin distributions to an exception instance describing the error that occurred. Usually this will be a ``DistributionNotFound`` or ``VersionConflict`` instance. N) rsortrrvrmapras_requirementrridictfromkeysr)r<rrrrplugin_projects error_info distributionsr shadow_setrrr resolveesr]sorted_distributionss r=rzWorkingSet.find_pluginssXz**46 >@  dl++C : CCZ'C^^B''  S & &'''+  L"<0  **,,- * 2 23Y G GIZ^Y77888!((y)A)ABBBE''(Jt$ " $M22!!####Z//s$D  D-D((D-r/c~|t|}|D]}|||S)aEnsure that distributions matching `requirements` are activated `requirements` must be a string or a (possibly-nested) sequence thereof, specifying the distributions and versions required. The return value is a sequence of the distributions that needed to be activated to fulfill the requirements; all relevant distributions are included, even if they were already activated in this working set. )rrr)r<r"neededrs r=rzWorkingSet.requiresC0>>??  D HHTNNNN r@callback Callable[[Distribution], object]existingcx||jvrdS|j||sdS|D] }||dS)zInvoke `callback` for all distributions If `existing=True` (default), call on all existing ones, as well. N)r|r)r<rrrs r= subscribezWorkingSet.subscribe,sa t~ % % F h'''  F  D HTNNNN  r@c0|jD] }||dSr:)r|)r<rrs r=rzWorkingSet._added_new<s,  H HTNNNN  r@c|jdd|j|j|j|jddfSr:)rvryrcrzr{r|rs r=r^zWorkingSet.__getstate__@s[ LO O " " K      - 2 2 4 4 N111    r@c|\}}}}}|dd|_||_||_||_|dd|_dSr:)rvrcryrzr{r|)r< e_k_b_n_crvrrzr{r|s r=razWorkingSet.__setstate__IsgIRFv;Yqqqz ))++kkmm ,H,M,M,O,O)"111r@r:)rvrw)r~r6)rr-r7rO)rr0r7r)rr6r@r-)rr6r]r6)r7r)NTF)rr-r~r-rrOr*rO)FN) r"rrrrrrrOrrr7r)NNFN) r"rrrrrrrOrrr7r) r"rrrrrrrOrrr7rrT) rrrrrrrrOr7r)NNT) rrrrrrrrOr7r) rrrrrrrrOr7r)r"r/)rrrrO)rArBrCrMr classmethodrrr}rrrrrrrrrrrrrr^rar;r@r=rrqsNN " " " " "[&[* ) ) ) )11110      >>>>++++(! $$$$$L %*)- ####X##'# %*)-#####X##'+/$))- !!!!X!#'MQ$))- HHHHHT>  IIIIXI(,I  IIIIIXI(,+/ GGGGXG(,MQ X0X0X0X0X0t"LP    &&&&&r@rceZdZdZdd dZdS) rz> Map each requirement to the extras that demanded it. Nrr0rrcfd|d|pdzD}j pt|S)z Evaluate markers for req against each extra that demanded it. Return False if the req has a marker and fails evaluation. Otherwise, return True. c3PK|] }jd|iV!dS)extraNmarkerevaluate)rrrs r=rz*_ReqExtras.markers_pass.._sL   J  % 0 1 1      r@r;r:)r rany)r<rr extra_evalss ` r=rz_ReqExtras.markers_passWs\    #r**f.?@   :~1[!1!11r@r:)rr0rr)rArBrCrMrr;r@r=rrRs7 2 2 2 2 2 2 2r@r.ceZdZdZdeefd2dZd3d Zd3d Zd4d5d Z d6dZ d3dZ e d7d8dZ e d9d:d!Z d9d;d#Z e dd)Z d4d?d+Zd@d-ZdAd0ZdAd1ZdS)Brz5Searchable snapshot of distributions on a search pathN search_pathrwrr-pythoncZi|_||_||_||dS)a!Snapshot distributions available on a search path Any distributions found on `search_path` are added to the environment. `search_path` should be a sequence of ``sys.path`` items. If not supplied, ``sys.path`` is used. `platform` is an optional string specifying the name of the platform that platform-specific distributions must be compatible with. If unspecified, it defaults to the current platform. `python` is an optional string naming the desired version of Python (e.g. ``'3.6'``); it defaults to the current version. You may explicitly set `platform` (and/or `python`) to ``None`` if you wish to map *all* distributions, not just those compatible with the running platform or Python version. N)_distmaprrscan)r<rrrs r=rzEnvironment.__init__is1,     +r@rr-c~|jdup|jdup|j|jk}|ot|j|jS)zIs distribution `dist` acceptable for this environment? The distribution must match the platform and python version requirements specified when this environment was created, or False is returned. N)r py_versionrr)r<r py_compats r=can_addzEnvironment.can_addsO K4  .$& .$+-  O1$-OOOr@cP|j|j|dS)z"Remove `dist` from the environmentN)rrkremovers r=rzEnvironment.removes% dh&&t,,,,,r@cz| tj}|D])}t|D]}||*dS)adScan `search_path` for distributions usable in this environment Any distributions found are added to the environment. `search_path` should be a sequence of ``sys.path`` items. If not supplied, ``sys.path`` is used. Only distributions conforming to the platform/python version defined at initialization are added. N)rrrr)r<rrrs r=r zEnvironment.scansW  (K  D*400     r@rr6r7rc`|}|j|gS)aReturn a newest-to-oldest list of distributions for `project_name` Uses case-insensitive `project_name` comparison, assuming all the project's distributions use their project's name converted to all lowercase as their key. )lowerrr )r<rdistribution_keys r= __getitem__zEnvironment.__getitem__s/(--//}  !12666r@c(||rx|rf|j|jg}||vrD|||tjdddSdSdSdS)zCAdd `dist` if we ``can_add()`` it and it has not already been addedhashcmpT)rkreverseN) r  has_versionrrrkrroperator attrgetter)r<rrs r=rzEnvironment.adds <<   M$"2"2"4"4 MM,,TXr::E5   T""" x29==t LLLLL  M M M M  r@Frr0rrrrrrOr,cdSr:r;r<rrrrs r=rzEnvironment.best_matchs r@rrcdSr:r;rs r=rzEnvironment.best_matchs "cr@rc ||}n#t$r|sd}YnwxYw||S||jD] }||vr|cS |||S)aFind distribution best matching `req` and usable on `working_set` This calls the ``find(req)`` method of the `working_set` to see if a suitable distribution is already active. (This may raise ``VersionConflict`` if an unsuitable version of the project is already active in the specified `working_set`.) If a suitable distribution isn't active, this method returns the newest distribution in the environment that meets the ``Requirement`` in `req`. If no suitable distribution is found, and `installer` is supplied, then the result of calling the environment's ``obtain(req, installer)`` method will be returned. N)rrrkobtain)r<rrrrrs r=rzEnvironment.best_matchs& ##C((DD   & DDD   KM  Ds{{ {{3 ***s ** requirementcdSr:r;r<r rs r=rzEnvironment.obtains r@$Callable[[Requirement], None] | NonerDcdSr:r;r"s r=rzEnvironment.obtains sr@cdSr:r;r"s r=rzEnvironment.obtains "cr@WCallable[[Requirement], None] | _InstallerType | None | _InstallerTypeT[_DistributionT]c |r ||ndS)aObtain a distribution matching `requirement` (e.g. via download) Obtain a distro that matches requirement (e.g. via download). In the base ``Environment`` class, this routine just returns ``installer(requirement)``, unless `installer` is None, in which case None is returned instead. This method is a hook that allows subclasses to attempt other ways of obtaining a distribution before falling back to the `installer` argument.Nr;r"s r=rzEnvironment.obtains *3)r<r*projectrs r=__iadd__zEnvironment.__iadd__s e\ * * F HHUOOOO { + + F  # #!'N##DHHTNNNN# #)UUUDEE E r@cN|gdd}||fD]}||z }|S)z4Add an environment or distribution to an environmentN)rrr)r<r*newrs r=__add__zEnvironment.__add__s<nnR$tn<<;  C 3JCC r@)rrwrr-rr-)rr-r:)rrw)rr6r7rF) rr0rrrrrrOr7r,NF) rr0rrrrrrOr7r) rr0rrrrrrOr7r)r r0rrr7r,)r r0rr#r7rD)r r0rrr7r)r r0rr&r7r)r7rU)r*r+)rArBrCrMrPY_MAJORrr rr rrrrrrr.r2r;r@r=rrfs??-15577% 6 P P P P----      7 7 7 7MMMM %* X ,0$) """"X"NR$) +++++BX ;?X ,0""""X"-1 =====$    r@rc2eZdZUdZded<ded<ded<dS) raTAn error occurred extracting a resource The following attributes are available from instances of this exception: manager The resource manager that raised this exception cache_path The base directory for resource extraction original_error The exception instance that caused extraction to fail rrdr6 cache_pathzBaseException | Noneoriginal_errorN)rArBrCrMrIr;r@r=rr+s?  OOO((((((r@rceZdZUdZdZded<dZd%d Zd%d Zd%d Z d%d Z d&dZ d%dZ d'dZ d(d)dZedZd*dZd+dZd,d-d$ZdS).rz'Manage resource extraction and packagesNr-extraction_pathci|_dSr:) cached_filesrs r=rzResourceManager.__init__Dsr@package_or_requirementr9rer6cFt||S)zDoes the named resource exist?)rrqr<r=res r=rzResourceManager.resource_existsGs233@@OOOr@cFt||S)z,Is the named resource an existing directory?)rrr?s r=rzResourceManager.resource_isdirKs233BB=QQQr@cHt|||S)z4Return a true filesystem path for specified resource)rrhr?s r=rz!ResourceManager.resource_filenameOs*233II -   r@cHt|||S)z9Return a readable file-like object for specified resource)rrkr?s r=rzResourceManager.resource_streamWs(233GG -   r@r7rlcHt|||S)z)Return specified resource as :obj:`bytes`)rrnr?s r=rzResourceManager.resource_string]s*233GG -   r@cFt||S)z1List the contents of the named resource directory)rrr?s r=rz ResourceManager.resource_listdires233DD]SSSr@r c$tjd}|jp t}t jd}t|jdit}||_ ||_ ||_ |)z5Give an error message for problems extracting file(s)ra Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: {old_exc} The Python egg cache directory is currently set to: {cache_path} Perhaps your account does not have write access to this directory? You can change the cache directory by setting the PYTHON_EGG_CACHE environment variable to point to an accessible directory. Nr;) rexc_infor:rtextwrapdedentlstriprrrrdr7r8)r<old_excr7tmplerrs r=extraction_errorz ResourceManager.extraction_erroris,..#)@->-@-@    " &((# $kdk55FHH5566 #$ r@r; archive_namenamesIterable[StrPath]c|jp t}tjj||dzg|R} t |n$#t $r|YnwxYw||d|j |<|S)aReturn absolute location in cache for `archive_name` and `names` The parent directory of the resulting path will be created if it does not already exist. `archive_name` should be the base filename of the enclosing egg (which may not be the name of the enclosing zipfile!), including its ".egg" extension. `names`, if provided, should be a sequence of path name parts "under" the egg's extraction location. This method should only be called by resource providers that need to obtain an extraction location, and only for names they intend to extract, as it tracks the generated names for possible cleanup later. z-tmpT) r:rrrr_bypass_ensure_directory ExceptionrM_warn_unsafe_extraction_pathr<)r<rNrO extract_path target_paths r=get_cache_pathzResourceManager.get_cache_paths+B/@/B/B gl<1FOOOO  $ $[ 1 1 1 1 $ $ $  ! ! # # # # # $ )),777)-+&sAA#"A#cLtjdkr'|tjdsdStj|j}|tjzs|tjzr5djdit}tj |tdSdS)aN If the default extraction path is overridden and set to an insecure location, such as /tmp, it opens up an opportunity for an attacker to replace an extracted file with an unauthorized payload. Warn the user if a known insecure location is used. See Distribute #375 for more details. ntwindirNzExtraction path is writable by group/others and vulnerable to attack when used with get_resource_filename ({path}). Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).r;) rr@r(environstatst_modeS_IWOTHS_IWGRPrrwarningswarn UserWarning)rmodemsgs r=rTz,ResourceManager._warn_unsafe_extraction_paths 7d??4??2:h3G#H#H? Fwt}}$ $,  ,$"5 ,: !!xx!!C M#{ + + + + + , ,r@tempnamer)filenamectjdkr6tj|jdzdz}tj||dSdS)a4Perform any platform-specific postprocessing of `tempname` This is where Mac header rewrites should be done; other platforms don't have anything special they should do. Resource providers should call this method ONLY after successfully extracting a compressed resource. They must NOT call it on resources that are already in the filesystem. `tempname` is the current (temporary) name of the file, and `filename` is the name it will be renamed to by the caller after this routine returns. posiximiN)rr@r\r]chmod)r<rerfrcs r= postprocesszResourceManager.postprocesssM 7g  WX&&.%76AD HXt $ $ $ $ $  r@rc@|jrtd||_dS)aSet the base path where resources will be extracted to, if needed. If you do not call this routine before any extractions take place, the path defaults to the return value of ``get_default_cache()``. (Which is based on the ``PYTHON_EGG_CACHE`` environment variable, with various platform-specific fallbacks. See that routine's documentation for more details.) Resources are extracted to subdirectories of this path based upon information given by the ``IResourceProvider``. You may set this to a temporary directory, but then you must call ``cleanup_resources()`` to delete the extracted files when done. There is no guarantee that ``cleanup_resources()`` will be able to remove all extracted files. (Note: you may not change the extraction path for a given resource manager once resources have been extracted, unless you first call ``cleanup_resources()``.) z5Can't change extraction path, files already extractedN)r<rr:r<rs r=rz#ResourceManager.set_extraction_paths-&   VTUU U#r@FforcerOrZcgS)aB Delete all extracted resource files and directories, returning a list of the file and directory names that could not be successfully removed. This function does not have any concurrency protection, so it should generally only be called when the extraction path is a temporary directory exclusive to a single process. This method is not automatically called; you must call it explicitly or register it as an ``atexit`` function if you wish to ensure cleanup of a temporary directory used for extractions. r;)r<rms r=rz!ResourceManager.cleanup_resourcess  r@)r=r9rer6)r=r9rer6r7rl)r7r r;)rNr6rOrP)rer)rfr)rr6r3)rmrOr7rZ)rArBrCrMr:rIrrrrrrrrMrW staticmethodrTrjrrr;r@r=rr?sI11"&O&&&&PPPPRRRR            TTTT<2,,\,4%%%%($$$$0       r@rc`tjdptdS)z Return the ``PYTHON_EGG_CACHE`` environment variable or a platform-relevant user cache dir for an app named "Python-Eggs". PYTHON_EGG_CACHEz Python-Eggs)appname)rr[r _user_cache_dirr;r@r=rrs) :>>, - - W1W1W1WWr@c.tjdd|S)zConvert an arbitrary string to a standard distribution name Any runs of non-alphanumeric/. characters are replaced with a single '-'. [^A-Za-z0-9.]+r{)resubr@s r=rrs 6"C . ..r@r%c ttj|S#tj$r/|dd}t jdd|cYSwxYw)zB Convert an arbitrary string to a standard version string r%ryrwr{)r6_packaging_versionVersionInvalidVersionr*rxryr$s r=rrsm6%-g66777  ,666//#s++v&W555556s #;A! A!c|dd}t|}|r |d}|t|d}nd}|}dt |d}|d|S)aFallback when ``safe_version`` is not safe enough >>> parse_version(_forgiving_version('0.23ubuntu1')) >>> parse_version(_forgiving_version('0.23-')) >>> parse_version(_forgiving_version('0.-_')) >>> parse_version(_forgiving_version('42.+?1')) >>> parse_version(_forgiving_version('hello world')) r%rysafeN0z sanitized.z.dev0+)r*_PEP440_FALLBACKsearchlen _safe_segmentstrip)r%r~rrestlocals r=_forgiving_versionrsooc3''G  # #G , ,E V}s4yy{{# .t,, . . 4 4S 9 9E ! !% ! !!r@ctjdd|}tjdd|}tjdd|dS)z/Convert an arbitrary string into a safe segmentrwr{z-[^A-Za-z0-9]+z\.[^A-Za-z0-9]+ryz.-)rxryr)segments r=rr,sMf%sG44Gf%sG44G 6$c7 3 3 9 9$ ? ??r@rcRtjdd|S)zConvert an arbitrary string to a standard 'extra' name Any runs of non-alphanumeric characters are replaced with a single '_', and the result is always lowercased. z[^A-Za-z0-9.-]+r&)rxryr)rs r=rr3s% 6#S% 0 0 6 6 8 88r@c.|ddS)z|Convert a project or version name to its filename-escaped form Any '-' characters are currently replaced with '_'. r{r&rrzs r=rr<s <<S ! !!r@textcv t|n'#t$r}d|_d|_|cYd}~Sd}~wwxYwdS)zo Validate text as a PEP 508 environment marker; return an exception if invalid or False otherwise. NF)r SyntaxErrorrflineno)res r=rrDs[    5s 6166rOc tj|}|S#tj$r}t ||d}~wwxYw)z Evaluate a PEP 508 environment marker. Return a boolean indicating the marker result in this environment. Raise SyntaxError if marker is invalid. This implementation uses the 'pyparsing' module. N)_packaging_markersMarkerr InvalidMarkerr)rrrrs r=rrRsW$#*400    +$$$!nn!#$s'*AA  AceZdZUdZdZded<dZded<dZded<d,d Zd-dZ d-dZ d.dZ d/dZ dZ d0dZd1dZd2dZd/dZd0dZd/dZd3d Zd4d$Zd5d%Zd5d&Zd6d'Zd7d)Zed*Zd8d+ZdS)9rzETry to implement resources and metadata for arbitrary PEP 302 loadersNr-egg_nameegg_infoz_LoaderProtocol | Noner r  _ModuleLikect|dd|_tjt|dd|_dS)NrG__file__r)r r rrdirname module_path)r<r s r=rzNullProvider.__init__hs=flD99 7??76:r+J+JKKr@rdrrer6c8||j|Sr:)_fnrrgs r=rhz"NullProvider.get_resource_filenamelsxx(-888r@cRtj|||Sr:)ioBytesIOrnrgs r=rkz NullProvider.get_resource_streamos"z$227MJJKKKr@r7rlc^|||j|Sr:)_getrrrgs r=rnz NullProvider.get_resource_stringrs'yy$"2MBBCCCr@c^|||j|Sr:)_hasrrrps r=rqzNullProvider.has_resourcews%yy$"2MBBCCCr@c8||j|Sr:)rrrQs r=_get_metadata_pathzNullProvider._get_metadata_pathzsxx t,,,r@r@rOch|jsdS||}||Sr4)rrrr<r@rs r=rRzNullProvider.has_metadata}s4} 5&&t,,yyr@c|jsdS||}||} |dS#t$r*}|xjd||z c_d}~wwxYw)Nrutf-8z in {} file at path: {})rrrdecodeUnicodeDecodeErrorreasonr)r<r@rvalueexcs r=rTzNullProvider.get_metadatas} 2&&t,, $ <<(( (!    JJ3::4FF FJJ   sA A>%A99A>rUcFt||Sr:rrTrQs r=rWzNullProvider.get_metadata_lines4,,T22333r@c^|||j|Sr:)_isdirrrrps r=rzNullProvider.resource_isdirs%{{488D$4mDDEEEr@ct|jo-|||j|Sr:)rOrrrrQs r=rYzNullProvider.metadata_isdirs3DMPdkk$((4=$2O2O&P&PQQQr@c^|||j|Sr:)_listdirrrrps r=rzNullProvider.resource_listdirs%}}TXXd&6 FFGGGr@rZcp|jr.|||j|SgSr:)rrrrQs r=r\zNullProvider.metadata_listdirs4 = @==$-!>!>?? ? r@r]r^rTcd|z}||s&tdjd it||dd}|dd}||j|}||d<tj |r3t|}t||d}t|||dSdd lm}t!|d|d|f||<t||d} t| ||dS) Nzscripts/z