K i  8UdZddlmZddlZejdkredddlZddlZddlZ ddl Z ddl Z ddl Z ddl Z ddlZ ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl!m"Z"m#Z#m$Z$m%Z%ddlm&Z&ddl'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2ejfjiejfjkejfjmejfjme7d d xZ8ejfve8gzejrjud ddd lm;Zm?Z?m@Z@ ddlmAZAmBZBmCZCdZDddlFZGddlHZGddlIZGddlJZGddlKZGddlLmMZMmNZNmOZOddlPmQZRe(rddlSmTZTmUZUmVZVddlWmXZXddlYmZZZm[Z[ejde]de0dZ^e0ddZ_e1e`e"e1e`e"dffZadebd<e+dgdfZcdebd <e+dge1d!fZddebd"<e1e`dfZedebd#<e1deefZfdebd$<e1d%Zgdebd&<e)Zhdebd'<e)Zidebd(<e1ejejfZldebd)<e+e)gd*fZmdebd+<e+e^e`enge"dfZodebd,<e+e^e`e`ejge1e`dffZpdebd-<e0d.eoe)emepe)ZqGd/d0e/Zrejd1ejZuGd2d3evZweGjjZziZ{d4ebd5<dd6Z|dd7Z}dd8Z~d9Zdd:Zd;Zdd<Zd=xZZd>Zgd?ZGd@dAeZGdBdCeZGdDdEeZGdFdGeZGdHdIeZiZdJebdK<ejjdLejjZdMZdZdNZdZdOZ ddPZe2ddQZe2ddRZddSZe j0dTZdUZdVZejdWZejdXZeZddYZe2ddZZe2dd[Zdd\Zdd]Ze2 d dd^Ze2dd_Zddd`ZddaZGdbdce/ZGddd*ee/ZGdedfZGdgdhedee`diffZGdjdkZeZGdldmeZGdndoZddpZddqZddrZddsZdtZdduZddvZddwZdddxZGdydzZeejed{ZGd|d}eZGd~deZejwGddeZeZGddee`dfZGddeZGddeZee jeGddeZGddeZGddeZe|ddiZdebd< ddZdddZ d ddZee jeȫ d ddZeejeɫdddZdZGddZddZddZdZdZeedreejeʫee jjeʫe|ddiZdebd<e|ddiZdebd< ddZdZddZddZdddZ ddZeedreejeܫee jeܫee jjeܫ ddZeejeݫe2ddZe2ddZddZddZe(re2ddZe2ddZddZne j0dZdZdZdZddZejdjZejdejejzjZGddZdZGddZGddeZGddeZeeedZdZdd„ZGdÄdeGjjZGdńdeGjjZdƄZddDŽZddȄZddɄZddʄZd˄ZejdewdͫGd΄deZejdk\rdndZefdd҄ZdӄZeefddԄZeddՄZe(reZej ZejZejZejZ ejZ ejZ ejZ ejZ eZejZej Zej"Zej&ZeZyy#eE$rdZDYwxYw(a 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.9 or later is required)IterableIteratorMappingMutableSequence) get_importer) TYPE_CHECKINGAnyBinaryIOCallableLiteral NamedTupleNoReturnProtocolTypeVarUnionoverload setuptools_vendor backports)openutime)isdirsplit)mkdirrenameunlinkTF) drop_commentjoin_continuation yield_lines)user_cache_dir) BytesPathStrOrBytesPathStrPath)LoaderProtocol)Self TypeAliaszpkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81. stacklevel_T_DistributionT Distribution)bound _NestedStrr) Requirement_StrictInstallerType)r/N_InstallerType _PkgReqType _EPDistType)IResourceProviderN _MetadataType_ResolvedEntryPoint_ResourceStream _ModuleLiker7_ProviderFactoryType_DistFinderType_NSHandlerType _AdapterTceZdZUded<y)_ZipLoaderModulezipimport.zipimporter __loader__N__name__ __module__ __qualname____annotations__\/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pkg_resources/__init__.pyrArAs%%rJrAz,^v?(?P(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)ceZdZdZy) PEP440Warningza Used when there is an issue with a version or specifier not complying with PEP 440. NrErFrG__doc__rIrJrKrMrMsrJrMzdict[str, str] _state_varsc|t|<|SN)rP)vartypevarname initial_values rK_declare_staterVs"K rJc~i}t}tjD]\}}|d|z||||<|S)N_sget_)globalsrPitemsstategkvs rK __getstate__r`sK E A!!#)1"1X\?1Q4(a) LrJc~t}|jD]\}}|dt|z||||!|S)N_sset_)rYrZrPr[s rK __setstate__rcsG A 11$([^ #$Q!a01 LrJc"|jSrR)copyvals rK _sget_dictrhs 88:rJcF|j|j|yrR)clearupdatekeyobr\s rK _sset_dictrosHHJIIerJc"|jSrR)r`rfs rK _sget_objectrqs    rJc&|j|yrR)rcrls rK _sset_objectrssOOErJcyrRrIargss rKrwrJct}tj|}|Ktjdk(r8 dj t dd}|jd}d|d|}|S|S#t$rY|SwxYw)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. Ndarwin.r*rmacosx--) get_build_platformmacosVersionStringmatchsysplatformjoin _macos_versgroup ValueError)platm major_minorbuilds rKget_supported_platformrs  D  &A}1 ((;=!#45KGGAJE[M5'2D K4K   K s5A// A<;A<)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/r2 EntryPointResolutionErrorVersionConflictDistributionNotFound UnknownExtraExtractionErrorrMparse_requirements parse_version safe_name safe_version get_platformcompatible_platformsr"split_sections safe_extra to_filenameinvalid_markerevaluate_markerensure_directorynormalize_pathEGG_DIST BINARY_DIST SOURCE_DIST CHECKOUT_DIST DEVELOP_DISTIMetadataProviderr7 FileMetadata PathMetadata EggMetadata EmptyProviderempty_provider NullProvider EggProviderDefaultProvider ZipProviderregister_finderregister_namespace_handlerregister_loader_typefixup_namespace_packagesr PkgResourcesDeprecationWarningrun_mainAvailableDistributionsceZdZdZddZy)rz.Abstract base for dependency resolution errorscZ|jjt|jzSrR) __class__rEreprrvselfs rK__repr__zResolutionError.__repr__0s~~&&dii88rJNreturnstr)rErFrGrOrrIrJrKrr-s 89rJrcNeZdZdZdZeddZed dZdZ d dZ y) 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 requiredc |jdSNrrurs rKdistzVersionConflict.dist>yy|rJc |jdSNrurs rKreqzVersionConflict.reqBrrJcJ|jjditSNrI _templateformatlocalsrs rKreportzVersionConflict.reportF$t~~$$0vx00rJc:|s|S|j|fz}t|S)zt If required_by is non-empty, return a version of self that is a ContextualVersionConflict. )rvContextualVersionConflict)r required_byrvs rK with_contextzVersionConflict.with_contextIs'KyyK>)($//rJNrr/rr2)rzset[Distribution | str]rz Self | ContextualVersionConflict) rErFrGrOrpropertyrrrrrIrJrKrr4sOFI 1 02 0 ) 0rJrc@eZdZdZej dzZeddZy)rz A VersionConflict that accepts a third parameter, the set of the requirements that required the installed Distribution. z by {self.required_by}c |jdS)Nr*rurs rKrz%ContextualVersionConflict.required_by^rrJN)rzset[str])rErFrGrOrrrrrIrJrKrrVs,  )),DDI rJrcVeZdZdZdZed dZed dZedZdZ d dZ y) rz&A requested distribution was not foundzSThe '{self.req}' distribution was not found and is required by {self.requirers_str}c |jdSrrurs rKrzDistributionNotFound.reqkrrJc |jdSrrurs rK requirerszDistributionNotFound.requirersorrJcR|jsydj|jS)Nzthe applicationz, )rrrs rK requirers_strz"DistributionNotFound.requirers_strss~~$yy((rJcJ|jjditSrrrs rKrzDistributionNotFound.reportyrrJc"|jSrR)rrs rK__str__zDistributionNotFound.__str__|s{{}rJNr)rzset[str] | Noner) rErFrGrOrrrrrrrrIrJrKrrcsU0 2 )) 1rJrceZdZdZy)rz>Distribution doesn't have an "extra feature" of the given nameNrNrIrJrKrrsHrJrz-dict[type[_ModuleLike], _ProviderFactoryType]_provider_factoriesr{rrc|t|<y)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) loader_typeprovider_factorys rKrrs(8 $rJcyrRrI moduleOrReqs rKrr9>% eT" 2b ( b 1  2=0'(89 ==   2 2s BB c,dddj||S)Nppc)PowerPCPower_Macintosh)get)machines rK _macos_archr#s 7 ; ;GW MMrJc ddlm}|}tjdk(r]|j dsL t }t tjdjdd}d|dd|d d |S|S#t$rY|SwxYw) zAReturn this platform's string for platform-specific distributionsr)rrzr| _r{rr}) sysconfigrrr startswithrr#runamereplacer)rrrr"s rKr~r~s& >D ||x (B !mG!"((*Q-"7"7S"ABGWQZL'!*Qwi@ @ K    K  sA B B  B zmacosx-(\d+)\.(\d+)-(.*)zdarwin-(\d+)\.(\d+)\.(\d+)-(.*)cJ||||k(rytj|}|rtj|}|sltj|}|rTt|j d}|j dd|j d}|dk(r|dk\s |dk(r|dk\ryy |j d|j dk7s#|j d |j d k7ry t|j dt|j dkDry yy ) 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. Trr{r*z10.3z10.4Fr)rrdarwinVersionStringintr)providedrequiredreqMacprovMac provDarwindversion macosversions rKrrs8+x8/C % %h /F $**84-228ArJcyrRrIr9s rKrrrrJct|trtj|}t|tr t |}t|t s t d||S)z@Return a current distribution object for a Requirement or stringz*Expected str, Requirement, or Distribution)rrr2parserr/ TypeErrorr9s rKrr sM$  &$ $D! dL )DdKK KrJc8t|j||S)zDReturn `name` entry point of `group` for `dist` or raise ImportError)rrrrnames rKrrs D ! 2 25$ ??rJcyrRrIrrs rKrrs(+rJcyrRrIrBs rKrrsKNrJc6t|j|S)=Return the entry point map for `group`, or the full entry map)rrrBs rKrrs D ! / / 66rJc8t|j||SzIs the named metadata a directory? (like ``os.path.isdir()``)NrIrJs rKmetadata_isdirz IMetadataProvider.metadata_isdir9rLrJcy)z?List of metadata names in the directory (like ``os.listdir()``)NrIrJs rKmetadata_listdirz"IMetadataProvider.metadata_listdir=rLrJcy)z=Execute the named script in the supplied namespace dictionaryNrI)r script_name namespaces rKrzIMetadataProvider.run_scriptArLrJNr@rrboolr@rrrr@rr Iterator[str]r@rr list[str]rVrrWdict[str, Any]rNone) rErFrGrKrNrPrRrTrrIrJrKrr)s       rJrcdeZdZdZ d dZ d dZ d dZd dZd dZd dZ y)r7z3An object that provides access to package resourcescy)zbReturn a true filesystem path for `resource_name` `manager` must be a ``ResourceManager``NrIrmanager resource_names rKget_resource_filenamez'IResourceProvider.get_resource_filenameI rJcy)zgReturn a readable file-like object for `resource_name` `manager` must be a ``ResourceManager``NrIrds rKget_resource_streamz%IResourceProvider.get_resource_streamQrhrJcy)zgReturn the contents of `resource_name` as :obj:`bytes` `manager` must be a ``ResourceManager``NrIrds rKget_resource_stringz%IResourceProvider.get_resource_stringYrhrJcy)z,Does the package contain the named resource?NrIrrfs rK has_resourcezIResourceProvider.has_resourcearLrJcy)z>Is the named resource a directory? (like ``os.path.isdir()``)NrIrns rKrz IResourceProvider.resource_isdirerLrJcy)z?List of resource names in the directory (like ``os.listdir()``)NrIrns rKrz"IResourceProvider.resource_listdirirLrJNrerrfrrr)rerrfrrr:rerrfrrbytesrfrrrYrfrrr^) rErFrGrOrgrjrlrorrrIrJrKr7r7Fsk= & 7:   & 7:   & 7:     rJc@eZdZdZdd dZedZedZd!dZd"dZ d#dZ d d$d Z d%d Z d&d Z d' d(dZe d) d*dZe dd dd d*dZe d+ d,dZ d+ d-dZ d.dZe d/ d0dZe dd d d0dZe d1 d2dZ d1 d3dZd4dZ d/ d5dZd6dZ d7dZd6dZy)8rzDA collection of active distributions on sys.path (or a similar list)Ncg|_i|_i|_i|_g|_|t j }|D]}|j|y)z?Create working set from list of path entries (default=sys.path)N)entries entry_keysby_keynormalized_to_canonical_keys callbacksrr add_entry)rryentrys rK__init__zWorkingSet.__init__qsO"$ 79/1 <>)AC ?hhG "E NN5 ! "rJc|} ddlm} |j||S#t$r|cYSwxYw#t$r|j |cYSwxYw)z1 Prepare the master working set. r) __requires__)__main__r ImportErrorrr_build_from_requirements)clswsrs rK _build_masterzWorkingSet._build_mastersb U  -  > JJ| $  I  >// = = >s#4 11AAc4|g}t|}|j|t}|D]}|j|tj D]"}||j vs|j|$|j tj dd|S)zQ Build a working set from a requirement spec. Rewrites sys.path. N)rresolveraddrrryr~)rreq_specrreqsdistsrrs rKrz#WorkingSet._build_from_requirementssW!(+ 4/ D FF4L XX $EBJJ& U# $ jj  rJc|jj|g|jj|t |dD]}|j ||dy)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)rz setdefaultryappendrr)rrrs rKr~zWorkingSet.add_entrysP ""5"- E"&ud3 )D HHT5% ( )rJcR|jj|j|k(S)z9True if `dist` is the active distribution for its project)r{r!rmrrs rK __contains__zWorkingSet.__contains__s{{txx(D00rJcFd}|j|jj|jt|jj ddf}t d|D](}|j j|}|s!||_n|||vr t|||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. Nr{r})rmr|r!rr+filterr{r)rrr candidates candidates rKrzWorkingSet.finds%) GG  - - 1 1#'' : cgg  & &sC 0  j1 I;;??9-D#    C!$, , rJcfd|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|];}|jjD]}|jk(r|=ywrR)rvaluesr@).0rrrr@s rK z/WorkingSet.iter_entry_points..sR ++E299; |tuzz1   sAArIrrr@s ``rKrzWorkingSet.iter_entry_pointss   rJctjdj}|d}|j||d<|j |dj ||y)z?Locate distribution for `requires` and run `script_name` scriptrrErN)r _getframe f_globalsrjrr)rrequiresrVnsr@s rKrzWorkingSet.run_scriptsO ]]1  ' '*~  : Xq!,,["=rJc#Kt}|jD]L}||jvr|j|D])}||vs|j||j|+Nyw)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)setryrzrr{)rseenitemrms rK__iter__zWorkingSet.__iter__sj uLL +D4??*t, +d?HHSM++c** +  +s ?A)'A)TFc|r|j|j||| |j}|jj |g}|jj |jg}|s|j |j vry||j |j <tjj|j }|j |j|<|j |vr|j|j |j |vr|j|j |j|y)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_onrylocationrzrrmr{ packagingutilscanonicalize_namer|r _added_new)rrrinsertr+keyskeys2normalized_names rKrzWorkingSet.adds$  NN4<<N @ =MME))%4**4=="=488t{{2  $ DHH#//;;DHHE=AXX))/: 884  KK ! 885 LL " rJcyrRrIr requirementsenv installerreplace_conflictingextrass rKrzWorkingSet.resolve(s #rJ)rrcyrRrIrs rKrzWorkingSet.resolve1s #rJcyrRrIrs rKrzWorkingSet.resolve;s!rJc *t|ddd}t}i}g}t} tjt tt ft} |r|jd} | |vr| j| |s+|j| ||||| |} | j| jddd} |j| | D]/}| |j| j| j| |<1|j| |r|S)aList all distributions needed to (recursively) meet `requirements` `requirements` must be a sequence of ``Requirement`` objects. `env`, if supplied, should be an ``Environment`` instance. If not supplied, it defaults to all distributions available within any entry or distribution in the working set. `installer`, if supplied, will be invoked with each requirement that cannot be met by an already-installed distribution; it should return a ``Distribution`` or ``None``. Unless `replace_conflicting=True`, raises a VersionConflict exception if any requirements are found on the path that have the correct name but the wrong version. Otherwise, if an `installer` is supplied it will be invoked to obtain the correct version of the requirement and activate it. `extras` is a list of the extras to be used with these requirements. This is important because extra requirements may look like `my_req; extra = "my_extra"`, which would otherwise be interpreted as a purely optional requirement. Instead, we want to be able to assert that these requirements are truly required. Nrr)listr _ReqExtras collections defaultdictr2rpop markers_pass _resolve_distrrextendr project_name)rrrrrr processedbest to_activate req_extrasrrrnew_requirementsnew_requirements rKrzWorkingSet.resolveDs!BL)$B$/ E (**, \ "--k3s8.CDSI ""1%Ci**37%%T.Y [D $}}SZZ82>     0 1$4 9O,001A1AB.1jj ?+ 9 MM# /4rJc|j|j}||jj|j}|||vrx|rv|} |.|t|j}ntg}t g} |j || ||x}||j<||j|d} t|| |j|||vr ||} t||j| |S)N)r) r!rmr{rryr best_matchrrrr) rrrrrrrrrrr dependent_reqs rKrzWorkingSet._resolve_distsxx  <;;??377+D|C4G;|)$,,7 *"o'^'*~~Y>   t $ s?',M!$,99-H H rJcyrRrIr plugin_envfull_envrfallbacks rK find_pluginszWorkingSet.find_pluginss FIrJ)rcyrRrIrs rKrzWorkingSet.find_pluginss FIrJcyrRrIrs rKrzWorkingSet.find_pluginss DGrJc\t|}|ji}i}|t|j}||z }n||z}|j g} tt | j ||D]u} || D]k} | jg} | j| ||} tt | j | |jtj| uwt|}|j||fS#t$r}||| <|rYd}~Yd}~d}~wwxYw)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) rsortrryrmapras_requirementrrkdictfromkeysr)rrrrrplugin_projects error_info distributionsr shadow_setrrr resolveesr_sorted_distributionss rKrzWorkingSet.find_pluginss7Xz*46 >@  dll+C : CZ'C^^B'  S &'+ L"<0 **,- * 2 23Y GIZ^^Y78!((y)AB+  0 $M2!!##Z//)''(Jt$ sD  D+D&&D+cj|jt|}|D]}|j||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)rrneededrs rKrzWorkingSet.require s90>? D HHTN  rJc|||jvry|jj||sy|D] }|| y)zInvoke `callback` for all distributions If `existing=True` (default), call on all existing ones, as well. N)r}r)rcallbackexistingrs rK subscribezWorkingSet.subscribe0sA t~~ %  h'  D TN rJc6|jD] }|| yrR)r})rrrs rKrzWorkingSet._added_new@s H TN rJc|jdd|jj|jj|jj|j ddfSrR)ryrzrer{r|r}rs rKr`zWorkingSet.__getstate__DsW LLO OO " KK     - - 2 2 4 NN1    rJc|\}}}}}|dd|_|j|_|j|_|j|_|dd|_yrR)ryrerzr{r|r})r e_k_b_n_cryrr{r|r}s rKrczWorkingSet.__setstate__UsTIRFv;Yqz ))+kkm ,H,M,M,O)"1rJrR)ryIterable[str] | Nonerra)rrrrarr/rrY)rr2rDistribution | None)rrr@ str | NonerzIterator[EntryPoint])rrrVrrra)rIterator[Distribution])NTF) rr/rrrrYr+rYrra)FN) rIterable[Requirement]rEnvironment | Noner$_StrictInstallerType[_DistributionT]rrYrtuple[str, ...] | Nonerzlist[_DistributionT])NNFN) rrrrr_InstallerType | NonerrYrrrlist[Distribution]) rrrrr<_InstallerType | None | _StrictInstallerType[_DistributionT]rrYrrrz)list[Distribution] | list[_DistributionT]rT) rrrrrrrrYrz:tuple[list[_DistributionT], dict[Distribution, Exception]])NNT) rrrrrrrrYrz8tuple[list[Distribution], dict[Distribution, Exception]]) rrrrrrrrYrzOtuple[list[Distribution] | list[_DistributionT], dict[Distribution, Exception]])rr1rr)rz Callable[[Distribution], object]rrYrrarra)rz~tuple[list[str], dict[str | None, list[str]], dict[str, Distribution], dict[str, str], list[Callable[[Distribution], object]]])rErFrGrOr classmethodrrr~rrrrrrrrrrrrrr`rcrIrJrKrrnsN "&* )1<.2  *  >+(! $$$ $  $  $L %*)- #+# #8 # " # ' # ###'# %*)-#+# # 8 # " #'# ###'+/$))- !+! !) ! " ! ' ! !!#'RV$))- H+H HP H " H ' H 3HT >  II%I8 I  I D II(,I  II%I 8 I  I DII(,+/ GG%G) G  G B GG(,RV X0X0%X0P X0  X0   X0t"LP8DH     "&rJrceZdZdZdddZy)rz> Map each requirement to the extras that demanded it. Ncxj xs+tfd|jd|xsdzDS)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. c3XK|]!}jjd|i#yw)extraNmarkerevaluate)rrrs rKrz*_ReqExtras.markers_pass..ks-%  JJ  % 0 1% s'*rI)r)ranyr!)rrrs ` rKrz_ReqExtras.markers_passcs@::~ % #r*fo>% "  rJrR)rr2rr)rErFrGrOrrIrJrKrr^s   rJr.c`eZdZdZdeef ddZddZddZdddZ ddZ ddZ e d dd Z e d dd Z d dd Z e dd Ze d dd Ze d d dZ d d!dZd"dZd#dZd#dZy)$rz5Searchable snapshot of distributions on a search pathNcPi|_||_||_|j|y)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)_distmaprpythonscan)r search_pathrr s rKrzEnvironment.__init__ts%,8:     +rJc|jduxs)|jduxs|j|jk(}|xr t|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)rr py_compats rKcan_addzEnvironment.can_addsX KK4  .$& .$++-  O1$--OOrJcT|j|jj|y)z"Remove `dist` from the environmentN)rrmremovers rKrzEnvironment.removes dhh&&t,rJcx|tj}|D]#}t|D]}|j|%y)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)rr rrs rKr zEnvironment.scansA  ((K D*40   rJcZ|j}|jj|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!)rrdistribution_keys rK __getitem__zEnvironment.__getitem__s+(--/}}  !1266rJc|j|rt|jrc|jj|jg}||vr8|j ||j tjddyyyy)zCAdd `dist` if we ``can_add()`` it and it has not already been addedhashcmpT)rmreverseN) r has_versionrrrmrroperator attrgetter)rrrs rKrzEnvironment.addso << $"2"2"4MM,,TXXr:E5  T" x229=t L!#5 rJcyrRrIrrrrrs rKrzEnvironment.best_matchsrJcyrRrIrs rKrzEnvironment.best_matchs"rJc |j|}||S||jD] }||vs|cS|j||S#t$r|sd}YBwxYw)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)rrrmobtain)rrrrrrs rKrzEnvironment.best_matchsv& ##C(D  KM Ds{  {{3 ** &D sAAAcyrRrIr requirementrs rKr!zEnvironment.obtains rJcyrRrIr#s rKr!zEnvironment.obtains rJcyrRrIr#s rKr!zEnvironment.obtains "rJc|r||SdS)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.NrIr#s rKr!zEnvironment.obtains *3y%<-@   " &(# $kdkk5FH56 #$ rJc|jxs t}tjj||dzg|} t ||j|d|j|<|S#t $r|jY=wxYw)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) r9rrrr_bypass_ensure_directory ExceptionrM_warn_unsafe_extraction_pathr;)r archive_namenames extract_path target_paths rKget_cache_pathzResourceManager.get_cache_paths++B/@/B ggll<1FOO  $ $[ 1 )),7)-+&  $  ! ! # $s A++BBcdtjdk(r#|jtjdsytj|j }|tj zs|tjzr5djdit}tj|tyy)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).rI) rr@r)environstatst_modeS_IWOTHS_IWGRPrrwarningswarn UserWarning)rmodemsgs rKrQz,ResourceManager._warn_unsafe_extraction_paths 77d?4??2::h3G#H wwt}$$ $,, $"5: f!x!C MM#{ +#6rJctjdk(rr5rfrrrY)r>r5rfrrr)r>r5rfrrr:)r>r5rfrrrt)r>r5rfrrr^)rrrI)rRrrSzIterable[StrPath]rr)rgr%rhr%rrarrrrar2)rmrYrr^)rErFrGrOr9rHrrrrrrrrMrV staticmethodrQrirrrIrJrKrrJs1"&OZ&9P&1PBEP P R&1RBER R  &1 BE   &1 BE   &1 BE  T&1TBET T <2,,4%($0 rJrc\tjjdxs tdS)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)rrZr!_user_cache_dirrIrJrKrr s" ::>>, - W1WWrJc0tjdd|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 rKrrs 66"C ..rJc ttjj|S#tjj$r,|j dd}t jdd|cYSwxYw)zB Convert an arbitrary string to a standard version string r&r{rvr})rrrVersionInvalidVersionr+rwrx)rs rKrrsb69$$,,W566    + +6//#s+vv&W556s'*AA32A3c|jdd}tj|}|r|d}|t|d}nd}|}dt |j 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&r{safeN0z sanitized.z.dev0+)r+_PEP440_FALLBACKsearchlen _safe_segmentstrip)rrr~restlocals rK_forgiving_versionr'sxooc3'G  # #G ,E V}s4y{#t,- . 4 4S 9EV6% !!rJctjdd|}tjdd|}tjdd|jdS)z/Convert an arbitrary string into a safe segmentrvr}z-[^A-Za-z0-9]+z\.[^A-Za-z0-9]+r{z.-)rwrxr)segments rKrr@sGff%sG4Gff%sG4G 66$c7 3 9 9$ ??rJcLtjdd|jS)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')rwrxr)rs rKrrGs! 66#S% 0 6 6 88rJc&|jddS)z|Convert a project or version name to its filename-escaped form Any '-' characters are currently replaced with '_'. r}r'rrys rKrrPs <<S !!rJch t|y#t$r}d|_d|_|cYd}~Sd}~wwxYw)zo Validate text as a PEP 508 environment marker; return an exception if invalid or False otherwise. NF)r SyntaxErrorrhlineno)textes rKrrXs9    s  1,11c tjj|}|jS#tjj$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)rmarkersMarkerr InvalidMarkerr)rrrrs rKrrfsR$""))$/     * *$!n!#$s.1A AAceZdZUdZdZded<dZded<dZded<ddZ dd Z dd Z dd Z d d Z d Z d!dZd"dZd#dZd dZd!dZd$dZd%dZd&dZd'dZd'dZd(dZd)dZed*dZd+dZy),rzETry to implement resources and metadata for arbitrary PEP 302 loadersNregg_nameegg_infozLoaderProtocol | Nonerct|dd|_tjj t|dd|_y)NrC__file__r)r rrrdirname module_path)rr s rKrzNullProvider.__init__|s0flD9 77??76:r+JKrJc:|j|j|SrR)_fnrrds rKrgz"NullProvider.get_resource_filenamesxx((-88rJcLtj|j||SrR)ioBytesIOrlrds rKrjz NullProvider.get_resource_streams zz$227MJKKrJcX|j|j|j|SrR)_getrrrds rKrlz NullProvider.get_resource_strings$yy$"2"2MBCCrJcX|j|j|j|SrR)_hasrrrns rKrozNullProvider.has_resources"yy$"2"2MBCCrJc:|j|j|SrR)rrrJs rK_get_metadata_pathzNullProvider._get_metadata_pathsxx t,,rJc`|jsy|j|}|j|Sr3)rrrrr@rs rKrKzNullProvider.has_metadatas*}}&&t,yyrJc|jsy|j|}|j|} |jdS#t$r!}|xj d|d|z c_d}~wwxYw)Nrutf-8z in  file at path: )rrrdecodeUnicodeDecodeErrorreason)rr@rvalueexcs rKrNzNullProvider.get_metadatasm}}&&t, $ <<( (!  JJDodV< ? ? rJc*d|z}|j|s#tdjd it|j |j dd}|j dd}|j |j|}||d<tjj|r&t|}t||d}t|||ydd lm}t!|d|j#d|f||<t||d} t| ||y) Nzscripts/z