Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 ÝPf>“ã^@södZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZy ddlZWnek räddlZYnXddlmZddlmZm Z m!Z!ddlm"Z"yddlm#Z#m$Z$m%Z%d Z&Wnek �rHd Z&YnXdd lm'Z(dd l)m*Z*m+Z+yddl,j-Z.e.j/Wnek �r”dZ.YnXdd lm0Z0ddlm1Z1e2dƒe2dƒe2dƒe2dƒdñej3k�oädòkn�rúdZ4e j5e4ƒdZ6dZ7Gdd„de8ƒZ9Gdd„de:ƒZ;Gdd„de;e1jGdd„de;e1jd?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPddQddRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtgFZMGdudL„dLeNƒZOGdvdM„dMeOƒZPGdwdx„dxePƒZQGdydN„dNeOƒZRGdzdO„dOeOƒZSiZTej_SetuptoolsVersionMixin.__iter__.._parse_version_partscszg}xlˆ|jƒƒD]\}|jdƒrd|dkrFx|rD|ddkrD|jƒq*Wx|rb|ddkrb|jƒqHW|j|ƒqWt|ƒS)Nr0z*finalr-z*final-Z00000000éÿÿÿÿr7)ÚlowerÚ startswithÚpopÚappendr)r2Úpartsr3)r6rrÚold_parse_version¥s   z;_SetuptoolsVersionMixin.__iter__..old_parse_versiona–You have iterated over the result of pkg_resources.parse_version. This is a legacy behavior which is inconsistent with the new version class introduced in setuptools 8.0. In most cases, conversion to a tuple is unnecessary. For comparison of versions, sort the Version instances directly. If you have another use case requiring the tuple, please file a bug with the setuptools project describing that need.r-)Ú stacklevel)ÚreÚcompileÚVERBOSEÚgetÚwarningsÚwarnÚRuntimeWarningÚstr)rr=r3r)r6r4r5rÚ__iter__�s  z _SetuptoolsVersionMixin.__iter__) rrrrr r"r#r$r%r&r(rGÚ __classcell__rr)rrrbs       rc@s eZdZdS)ÚSetuptoolsVersionN)rrrrrrrrIÄsrIc@s eZdZdS)ÚSetuptoolsLegacyVersionN)rrrrrrrrJÈsrJc Cs*yt|ƒStjjk r$t|ƒSXdS)N)rIrÚversionÚInvalidVersionrJ)ÚvrrrÚ parse_versionÍsrNcKs"tƒj|ƒtjtj||ƒƒdS)N)ÚglobalsÚupdateÚ _state_varsÚdictÚfromkeys)ZvartypeÚkwrrrÚ_declare_state×s rUcCs<i}tƒ}x,tjƒD] \}}|d|||ƒ||<qW|S)NZ_sget_)rOrQÚitems)ÚstateÚgÚkrMrrrÚ __getstate__Üs rZcCs<tƒ}x0|jƒD]$\}}|dt|||||ƒqW|S)NZ_sset_)rOrVrQ)rWrXrYrMrrrÚ __setstate__äs r[cCs|jƒS)N)Úcopy)ÚvalrrrÚ _sget_dictësr^cCs|jƒ|j|ƒdS)N)ÚclearrP)r'ÚobrWrrrÚ _sset_dictïsracCs|jƒS)N)rZ)r]rrrÚ _sget_objectôsrbcCs|j|ƒdS)N)r[)r'r`rWrrrÚ _sset_objectøsrccGsdS)Nr)ÚargsrrrÚüsrec Csbtƒ}tj|ƒ}|dk r^tjdkr^y&ddjtƒdd…ƒ|jdƒf}Wntk r\YnX|S)aZReturn this platform's maximum compatible version. distutils.util.get_platform() normally reports the minimum version of Mac OS X that would be required to *use* extensions produced by distutils. But what we want when checking compatibility is to know the version of Mac OS X that we are *running*. To allow usage of packages that explicitly require a newer version of Mac OS X, 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. NÚdarwinz macosx-%s-%sr,ér) Úget_build_platformÚmacosVersionStringÚmatchÚsysÚplatformÚjoinÚ _macosx_versÚgroupÚ ValueError)ÚplatÚmrrrÚget_supported_platformÿs  &rsÚrequireÚ run_scriptÚ get_providerÚget_distributionÚload_entry_pointÚ get_entry_mapÚget_entry_infoÚiter_entry_pointsÚresource_stringÚresource_streamÚresource_filenameÚresource_listdirÚresource_existsÚresource_isdirÚdeclare_namespaceÚ working_setÚadd_activation_listenerÚfind_distributionsÚset_extraction_pathÚcleanup_resourcesÚget_default_cacheÚ EnvironmentÚ WorkingSetÚResourceManagerÚ DistributionÚ RequirementÚ EntryPointÚResolutionErrorÚVersionConflictÚDistributionNotFoundÚ UnknownExtraÚExtractionErrorÚparse_requirementsÚ safe_nameÚ safe_versionÚ get_platformÚcompatible_platformsÚ yield_linesÚsplit_sectionsÚ safe_extraÚ to_filenameÚinvalid_markerÚevaluate_markerÚensure_directoryÚnormalize_pathÚEGG_DISTÚ BINARY_DISTÚ SOURCE_DISTÚ CHECKOUT_DISTÚ DEVELOP_DISTÚIMetadataProviderÚIResourceProviderÚ FileMetadataÚ PathMetadataÚ EggMetadataÚ EmptyProviderÚempty_providerÚ NullProviderÚ EggProviderÚDefaultProviderÚ ZipProviderÚregister_finderÚregister_namespace_handlerÚregister_loader_typeÚfixup_namespace_packagesrÚrun_mainÚAvailableDistributionsc@seZdZdZdd„ZdS)r�z.Abstract base for dependency resolution errorscCs|jjt|jƒS)N)rrÚreprrd)rrrrÚ__repr__IszResolutionError.__repr__N)rrrrr¸rrrrr�Fsc@s<eZdZdZdZedd„ƒZedd„ƒZdd„Zd d „Z d S) r�zª 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 requiredcCs |jdS)Nr)rd)rrrrÚdistWszVersionConflict.distcCs |jdS)Nr-)rd)rrrrÚreq[szVersionConflict.reqcCs|jjftƒŽS)N)Ú _templateÚformatÚlocals)rrrrÚreport_szVersionConflict.reportcCs|s|S|j|f}t|ŽS)zt If required_by is non-empty, return a version of self that is a ContextualVersionConflict. )rdÚContextualVersionConflict)rÚ required_byrdrrrÚ with_contextbs zVersionConflict.with_contextN) rrrrr»Úpropertyr¹rºr¾rÁrrrrr�Ms   c@s&eZdZdZejdZedd„ƒZdS)r¿z… A VersionConflict that accepts a third parameter, the set of the requirements that required the installed Distribution. z by {self.required_by}cCs |jdS)Nrg)rd)rrrrrÀusz%ContextualVersionConflict.required_byN)rrrrr�r»rÂrÀrrrrr¿ms r¿c@sHeZdZdZdZedd„ƒZedd„ƒZedd„ƒZd d „Z d d „Z d S)r‘z&A requested distribution was not foundzSThe '{self.req}' distribution was not found and is required by {self.requirers_str}cCs |jdS)Nr)rd)rrrrrº€szDistributionNotFound.reqcCs |jdS)Nr-)rd)rrrrÚ requirers„szDistributionNotFound.requirerscCs|js dSdj|jƒS)Nzthe applicationz, )rÃrm)rrrrÚ requirers_strˆsz"DistributionNotFound.requirers_strcCs|jjftƒŽS)N)r»r¼r½)rrrrr¾ŽszDistributionNotFound.reportcCs|jƒS)N)r¾)rrrrÚ__str__‘szDistributionNotFound.__str__N) rrrrr»rÂrºrÃrÄr¾rÅrrrrr‘zs   c@seZdZdZdS)r’z>Distribution doesn't have an "extra feature" of the given nameN)rrrrrrrrr’•srgr-cCs |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)Ú_provider_factories)Z loader_typeZprovider_factoryrrrr³£sc Cstt|tƒr$tj|ƒp"tt|ƒƒdSytj|}Wn&tk rXt |ƒtj|}YnXt |ddƒ}t t |ƒ|ƒS)z?Return an IResourceProvider for the named module or requirementrÚ __loader__N) rr�rƒÚfindrtrFrkÚmodulesÚKeyErrorÚ __import__ÚgetattrÚ _find_adapterrÆ)Z moduleOrReqÚmoduleÚloaderrrrrv­s  cCsd|s\tjƒd}|dkrLd}tjj|ƒrLttdƒrLtj|ƒ}d|krL|d}|j|j dƒƒ|dS)NrÚz0/System/Library/CoreServices/SystemVersion.plistÚ readPlistZProductVersionr,) rlZmac_verÚosÚpathÚexistsÚhasattrÚplistlibrÑr;r)Ú_cacherKZplistZ plist_contentrrrrnºs    rncCsdddœj||ƒS)NZppc)ZPowerPCZPower_Macintosh)rB)ÚmachinerrrÚ _macosx_archÊsrÙcCs¤yddlm}Wn tk r0ddlm}YnX|ƒ}tjdkr |jdƒ r ysc@s<eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd S)r¦cCsdS)z;Does the package's distribution contain the named metadata?Nr)rçrrrÚ has_metadataDszIMetadataProvider.has_metadatacCsdS)z'The named metadata resource as a stringNr)rçrrrÚ get_metadataGszIMetadataProvider.get_metadatacCsdS)zÒYield 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)rçrrrÚget_metadata_linesJsz$IMetadataProvider.get_metadata_linescCsdS)z>Is the named metadata a directory? (like ``os.path.isdir()``)Nr)rçrrrÚmetadata_isdirPsz IMetadataProvider.metadata_isdircCsdS)z?List of metadata names in the directory (like ``os.listdir()``)Nr)rçrrrÚmetadata_listdirSsz"IMetadataProvider.metadata_listdircCsdS)z=Execute the named script in the supplied namespace dictionaryNr)råÚ namespacerrrruVszIMetadataProvider.run_scriptN) rrrrërìrírîrïrurrrrr¦Cs c@s@eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dS)r§z3An object that provides access to package resourcescCsdS)zdReturn a true filesystem path for `resource_name` `manager` must be an ``IResourceManager``Nr)ÚmanagerÚ resource_namerrrÚget_resource_filename]sz'IResourceProvider.get_resource_filenamecCsdS)ziReturn a readable file-like object for `resource_name` `manager` must be an ``IResourceManager``Nr)rñròrrrÚget_resource_streambsz%IResourceProvider.get_resource_streamcCsdS)zmReturn a string containing the contents of `resource_name` `manager` must be an ``IResourceManager``Nr)rñròrrrÚget_resource_stringgsz%IResourceProvider.get_resource_stringcCsdS)z,Does the package contain the named resource?Nr)ròrrrÚ has_resourcelszIResourceProvider.has_resourcecCsdS)z>Is the named resource a directory? (like ``os.path.isdir()``)Nr)ròrrrr�osz IResourceProvider.resource_isdircCsdS)z?List of resource names in the directory (like ``os.listdir()``)Nr)ròrrrrrsz"IResourceProvider.resource_listdirN) rrrrrórôrõrör�rrrrrr§Zsc@s¬eZdZdZd'dd„Zedd„ƒZedd„ƒZd d „Zd d „Z d d„Z d(dd„Z dd„Z dd„Z d)dd„Zd*dd„Zd+dd„Zdd„Zd,dd „Zd!d"„Zd#d$„Zd%d&„ZdS)-rŠzDA collection of active distributions on sys.path (or a similar list)NcCsBg|_i|_i|_g|_|dkr&tj}x|D]}|j|ƒq,WdS)z?Create working set from list of path entries (default=sys.path)N)ÚentriesÚ entry_keysÚby_keyÚ callbacksrkrÓÚ add_entry)rr÷ÚentryrrrÚ__init__ys zWorkingSet.__init__cCsZ|ƒ}yddlm}Wntk r*|SXy|j|ƒWntk rT|j|ƒSX|S)z1 Prepare the master working set. r)Ú __requires__)Ú__main__rþrÞrtr�Ú_build_from_requirements)ÚclsÚwsrþrrrÚ _build_master†s zWorkingSet._build_mastercCsn|gƒ}t|ƒ}|j|tƒƒ}x|D]}|j|ƒq$Wx"tjD]}||jkr>|j|ƒq>W|jtjdd…<|S)zQ Build a working set from a requirement spec. Rewrites sys.path. N)r”Úresolver‰ÚaddrkrÓr÷rû)rZreq_specrÚreqsÚdistsr¹rürrrršs   z#WorkingSet._build_from_requirementscCs@|jj|gƒ|jj|ƒx t|dƒD]}|j||dƒq&WdS)aÝAdd 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)røÚ setdefaultr÷r;r…r)rrür¹rrrrû°s  zWorkingSet.add_entrycCs|jj|jƒ|kS)z9True if `dist` is the active distribution for its project)rùrBr')rr¹rrrÚ __contains__¿szWorkingSet.__contains__cCs,|jj|jƒ}|dk r(||kr(t||ƒ‚|S)aÐFind 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. N)rùrBr'r�)rrºr¹rrrrÈÃs  zWorkingSet.findccsPxJ|D]B}|j|ƒ}|dkr6x*|jƒD] }|Vq&Wq||kr||VqWdS)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). N)ryÚvalues)rrorçr¹r÷Úeprrrr{Ós   zWorkingSet.iter_entry_pointscCs>tjdƒj}|d}|jƒ||d<|j|ƒdj||ƒdS)z?Locate distribution for `requires` and run `script_name` scriptr-rrN)rkrãrär_rtru)rÚrequiresrårærçrrrruâs  zWorkingSet.run_scriptccsTi}xJ|jD]@}||jkrq x.|j|D] }||kr(d||<|j|Vq(Wq WdS)z¸Yield 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. r-N)r÷rørù)rÚseenÚitemr'rrrrGês  zWorkingSet.__iter__TFcCsž|r|j|j||d�|dkr$|j}|jj|gƒ}|jj|jgƒ}| rX|j|jkrXdS||j|j<|j|krz|j|jƒ|j|kr�|j|jƒ|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. )r5N) Ú insert_onr÷Úlocationrørr'rùr;Ú _added_new)rr¹rüÚinsertr5ÚkeysZkeys2rrrrûs      zWorkingSet.addcCs|t|ƒddd…}i}i}g}tƒ}tjtƒ} �xF|�rv|jdƒ} | |krLq2|j| ƒsXq2|j| jƒ} | dk�r|j j| jƒ} | dks�| | krö|rö|} |dkrÀ| dkr°t |j ƒ}nt gƒ}t gƒ} |j | | |ƒ} || j<| dkrö| j| dƒ} t| | ƒ‚|j| ƒ| | k�r"| | }t| | ƒj|ƒ‚| j| jƒddd…}|j|ƒx(|D] }| |j| jƒ| j||<�qHWd|| <q2W|S)aeList 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. Nr-rTr7r7)ÚlistÚ _ReqExtrasÚ collectionsÚ defaultdictÚsetr:Ú markers_passrBr'rùr‰r÷rŠÚ best_matchr‘r;r�rÁr ÚextrasÚextendrÚ project_name)rÚ requirementsÚenvÚ installerZreplace_conflictingZ processedZbestZ to_activateZ req_extrasrÀrºr¹rrÃZ dependent_reqZnew_requirementsZnew_requirementrrrrsJ              zWorkingSet.resolvecCst|ƒ}|jƒi}i}|dkr4t|jƒ}||7}n||}|jgƒ} tt| j|ƒƒx’|D]Š} x„|| D]x} | jƒg} y| j| ||ƒ} Wn4t k r¾}z||| <|r¬wjnPWYdd}~XqjXtt| j| ƒƒ|j t j | ƒƒPqjWq\Wt|ƒ}|jƒ||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) rÚsortr‰r÷rrrÚas_requirementrr�rPrRrS)rZ plugin_envZfull_envr ZfallbackZplugin_projectsZ error_infoZ distributionsrZ shadow_setrr¹rºZ resolveesrMrrrÚ find_pluginsks4$      zWorkingSet.find_pluginscGs*|jt|ƒƒ}x|D]}|j|ƒqW|S)a¾Ensure 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. )rr”r)rrZneededr¹rrrrt¿s  zWorkingSet.requirecCs<||jkrdS|jj|ƒ|s"dSx|D] }||ƒq(WdS)zƒInvoke `callback` for all distributions If `existing=True` (default), call on all existing ones, as well. N)rúr;)rÚcallbackÚexistingr¹rrrÚ subscribeÏs   zWorkingSet.subscribecCsx|jD] }||ƒqWdS)N)rú)rr¹r$rrrrÝs zWorkingSet._added_newcCs,|jdd…|jjƒ|jjƒ|jdd…fS)N)r÷rør\rùrú)rrrrrZászWorkingSet.__getstate__cCs@|\}}}}|dd…|_|jƒ|_|jƒ|_|dd…|_dS)N)r÷r\rørùrú)rZe_k_b_cr÷rrùrúrrrr[çs    zWorkingSet.__setstate__)N)N)NTF)NNF)NNT)T)rrrrrýÚ classmethodrrrûr rÈr{rurGrrr#rtr&rrZr[rrrrrŠvs(     Q S c@seZdZdZdd„ZdS)rz> Map each requirement to the extras that demanded it. cs.‡fdd„|jˆfƒdDƒ}ˆj p,t|ƒ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. c3s|]}ˆjjd|iƒVqdS)ÚextraN)ÚmarkerÚevaluate)Ú.0r()rºrrú ýsz*_ReqExtras.markers_pass..N)N)rBr)Úany)rrºZ extra_evalsr)rºrrôs z_ReqExtras.markers_passN)rrrrrrrrrrïsrc@sxeZdZdZdeƒefdd„Zdd„Zdd„Zdd d „Z d d „Z d d„Z ddd„Z ddd„Z dd„Zdd„Zdd„ZdS)r‰z5Searchable snapshot of distributions on a search pathNcCs i|_||_||_|j|ƒ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.3'``); 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)Ú_distmaprlÚpythonÚscan)rÚ search_pathrlr/rrrrýszEnvironment.__init__cCs.|jdks |jdks |j|jko,t|j|jƒS)zåIs 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_versionr˜rl)rr¹rrrÚcan_adds zEnvironment.can_addcCs|j|jj|ƒdS)z"Remove `dist` from the environmentN)r.r'Úremove)rr¹rrrr4(szEnvironment.removecCs<|dkrtj}x(|D] }xt|ƒD]}|j|ƒq"WqWdS)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)rkrÓr…r)rr1rr¹rrrr0,s  zEnvironment.scancCs|jƒ}|jj|gƒS)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. )r8r.rB)rrZdistribution_keyrrrr(;szEnvironment.__getitem__cCsL|j|ƒrH|jƒrH|jj|jgƒ}||krH|j|ƒ|jtjdƒdd�dS)zLAdd `dist` if we ``can_add()`` it and it has not already been added ÚhashcmpT)r'ÚreverseN) r3Ú has_versionr.rr'r;r!ÚoperatorÚ attrgetter)rr¹rrrrrFs  zEnvironment.addcCsB|j|ƒ}|dk r|Sx||jD]}||kr"|Sq"W|j||ƒS)a¸Find 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)rÈr'Úobtain)rrºrƒr r¹rrrrOs zEnvironment.best_matchcCs|dk r||ƒSdS)aÞObtain 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)rZ requirementr rrrr:es zEnvironment.obtainccs&x |jjƒD]}||r |Vq WdS)z=Yield the unique project names of the available distributionsN)r.r)rr'rrrrGqszEnvironment.__iter__cCs^t|tƒr|j|ƒnDt|tƒrLx8|D] }x||D]}|j|ƒq4Wq&Wntd|fƒ‚|S)z2In-place addition of a distribution or environmentzCan't add %r to environment)rrŒrr‰rê)rr!Zprojectr¹rrrÚ__iadd__ws    zEnvironment.__iadd__cCs.|jgddd�}x||fD] }||7}qW|S)z4Add an environment or distribution to an environmentN)rlr/)r)rr!ÚnewrrrrÚ__add__ƒs zEnvironment.__add__)N)N)N)rrrrrsÚPY_MAJORrýr3r4r0r(rrr:rGr;r=rrrrr‰s       c@seZdZdZdS)r“aTAn 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 N)rrrrrrrrr“�s c@s†eZdZdZdZdd„Zdd„Zdd„Zd d „Zd d „Z d d„Z dd„Z dd„Z ffdd„Z edd„ƒZdd„Zdd„Zddd„ZdS)r‹z'Manage resource extraction and packagesNcCs i|_dS)N)Ú cached_files)rrrrrý£szResourceManager.__init__cCst|ƒj|ƒS)zDoes the named resource exist?)rvrö)rÚpackage_or_requirementròrrrr€¦szResourceManager.resource_existscCst|ƒj|ƒS)z,Is the named resource an existing directory?)rvr�)rr@ròrrrr�ªszResourceManager.resource_isdircCst|ƒj||ƒS)z4Return a true filesystem path for specified resource)rvró)rr@ròrrrr~°sz!ResourceManager.resource_filenamecCst|ƒj||ƒS)z9Return a readable file-like object for specified resource)rvrô)rr@ròrrrr}¶szResourceManager.resource_streamcCst|ƒj||ƒS)z%Return specified resource as a string)rvrõ)rr@ròrrrr|¼szResourceManager.resource_stringcCst|ƒj|ƒS)z1List the contents of the named resource directory)rvr)rr@ròrrrrÂsz ResourceManager.resource_listdircCsRtjƒd}|jptƒ}tjdƒjƒ}t|jft ƒŽƒ}||_ ||_ ||_ |‚dS)z5Give an error message for problems extracting file(s)r-a 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. N) rkÚexc_infoÚextraction_pathrˆÚtextwrapÚdedentÚlstripr“r¼r½rñÚ cache_pathZoriginal_error)rÚold_excrFÚtmplÚerrrrrÚextraction_errorÈs   z ResourceManager.extraction_errorc Cs^|jp tƒ}tjj||df|žŽ}y t|ƒWn|jƒYnX|j|ƒd|j|<|S)a®Return 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-tmpr-) rBrˆrÒrÓrmÚ_bypass_ensure_directoryrJÚ_warn_unsafe_extraction_pathr?)rZ archive_nameÚnamesZ extract_pathZ target_pathrrrÚget_cache_pathäs    zResourceManager.get_cache_pathcCsXtjdkr |jtjdƒ r dStj|ƒj}|tj@s@|tj@rTd|}tj |t ƒdS)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. ÚntZwindirNzË%s is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).) rÒrçr9ÚenvironÚstatÚst_modeÚS_IWOTHÚS_IWGRPrCrDÚ UserWarning)rÓÚmodeÚmsgrrrrLýs  z,ResourceManager._warn_unsafe_extraction_pathcCs.tjdkr*tj|ƒjdBd@}tj||ƒdS)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. ÚposiximiÿN)rÒrçrQrRÚchmod)rZtempnameÚfilenamerVrrrÚ postprocesss zResourceManager.postprocesscCs|jrtdƒ‚||_dS)aÒSet 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?rprB)rrÓrrrr†)sz#ResourceManager.set_extraction_pathFcCsdS)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. Nr)rÚforcerrrr‡Csz!ResourceManager.cleanup_resources)F)rrrrrBrýr€r�r~r}r|rrJrNÚ staticmethodrLr[r†r‡rrrrr‹Ÿs  cCstjjdƒptjdd�S)zŒ Return the ``PYTHON_EGG_CACHE`` environment variable or a platform-relevant user cache dir for an app named "Python-Eggs". ZPYTHON_EGG_CACHEz Python-Eggs)Zappname)rÒrPrBrZuser_cache_dirrrrrrˆQs cCstjdd|ƒS)z�Convert an arbitrary string to a standard distribution name Any runs of non-alphanumeric/. characters are replaced with a single '-'. z[^A-Za-z0-9.]+r+)r?Úsub)rçrrrr•]sc CsDyttjj|ƒƒStjjk r>|jddƒ}tjdd|ƒSXdS)zB Convert an arbitrary string to a standard version string rÛr,z[^A-Za-z0-9.]+r+N)rFrrKÚVersionrLr5r?r^)rKrrrr–es  cCstjdd|ƒjƒS)z±Convert 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Ü)r?r^r8)r(rrrr›qscCs |jddƒS)z|Convert a project or version name to its filename-escaped form Any '-' characters are currently replaced with '_'. r+rÜ)r5)rçrrrrœzscCs>y t|ƒWn,tk r8}zd|_d|_|Sd}~XnXdS)zo Validate text as a PEP 508 environment marker; return an exception if invalid or False otherwise. NF)ržÚ SyntaxErrorrZÚlineno)ÚtextÚerrrr�‚s cCsHytjj|ƒ}|jƒStjjk rB}zt|ƒ‚WYdd}~XnXdS)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)rZmarkersZMarkerr*Z InvalidMarkerr`)rbr(r)rcrrrrž�s  c@s¬eZdZdZdZdZdZdd„Zdd„Zdd„Z d d „Z d d „Z d d„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„ZdS)'r­zETry to implement resources and metadata for arbitrary PEP 302 loadersNcCs(t|ddƒ|_tjjt|ddƒƒ|_dS)NrÇÚ__file__rÐ)rÌrÏrÒrÓÚdirnameÚ module_path)rrÎrrrrý¦szNullProvider.__init__cCs|j|j|ƒS)N)Ú_fnrf)rrñròrrrróªsz"NullProvider.get_resource_filenamecCstj|j||ƒƒS)N)ÚioÚBytesIOrõ)rrñròrrrrô­sz NullProvider.get_resource_streamcCs|j|j|j|ƒƒS)N)Ú_getrgrf)rrñròrrrrõ°sz NullProvider.get_resource_stringcCs|j|j|j|ƒƒS)N)Ú_hasrgrf)rròrrrrö³szNullProvider.has_resourcecCs|jo|j|j|j|ƒƒS)N)Úegg_inforkrg)rrçrrrrë¶szNullProvider.has_metadatacCs2|js dS|j|j|j|ƒƒ}tjr.|jdƒS|S)NrÐzutf-8)rlrjrgrZPY3Údecode)rrçÚvaluerrrrì¹szNullProvider.get_metadatacCst|j|ƒƒS)N)r™rì)rrçrrrrí¿szNullProvider.get_metadata_linescCs|j|j|j|ƒƒS)N)Ú_isdirrgrf)rròrrrr�ÂszNullProvider.resource_isdircCs|jo|j|j|j|ƒƒS)N)rlrorg)rrçrrrrîÅszNullProvider.metadata_isdircCs|j|j|j|ƒƒS)N)Ú_listdirrgrf)rròrrrrÈszNullProvider.resource_listdircCs|jr|j|j|j|ƒƒSgS)N)rlrprg)rrçrrrrïËszNullProvider.metadata_listdirc CsÆd|}|j|ƒstd|ƒ‚|j|ƒjddƒ}|jddƒ}|j|j|ƒ}||d<tjj|ƒr„t |ƒj ƒ}t ||dƒ}t |||ƒn>dd l m}t|ƒd|jdƒ|f||<t ||dƒ} t | ||ƒdS) Nzscripts/zNo script named %rz Ú ú rdÚexecr)Úcache)rër�rìr5rgrlrÒrÓrÔr Úreadr@rsÚ linecachertÚlenr) rrårðZscriptZ script_textZscript_filenameÚsourceÚcodertZ script_coderrrruÐs        zNullProvider.run_scriptcCs tdƒ‚dS)Nz9Can't perform this operation for unregistered loader type)ÚNotImplementedError)rrÓrrrrkäszNullProvider._hascCs tdƒ‚dS)Nz9Can't perform this operation for unregistered loader type)rz)rrÓrrrroészNullProvider._isdircCs tdƒ‚dS)Nz9Can't perform this operation for unregistered loader type)rz)rrÓrrrrpîszNullProvider._listdircCs |rtjj|f|jdƒžŽS|S)Nú/)rÒrÓrmr)rÚbaseròrrrrgószNullProvider._fncCs$t|jdƒr|jj|ƒStdƒ‚dS)NÚget_dataz=Can't perform this operation for loaders without 'get_data()')rÕrÏr}rz)rrÓrrrrjøs  zNullProvider._get)rrrrÚegg_namerlrÏrýrórôrõrörërìrír�rîrrïrurkrorprgrjrrrrr­Ÿs,c@s eZdZdZdd„Zdd„ZdS)r®z&Provider based on a virtual filesystemcCstj||ƒ|jƒdS)N)r­rýÚ _setup_prefix)rrÎrrrrýs zEggProvider.__init__cCs^|j}d}xN||krXt|ƒrBtjj|ƒ|_tjj|dƒ|_||_P|}tjj |ƒ\}}q WdS)NzEGG-INFO) rfÚ_is_unpacked_eggrÒrÓÚbasenamer~rmrlÚegg_rootr)rrÓÚoldr|rrrr s zEggProvider._setup_prefixN)rrrrrýrrrrrr®sc@sDeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Ze d d „ƒZ dS)r¯z6Provides access to package resources in the filesystemcCs tjj|ƒS)N)rÒrÓrÔ)rrÓrrrrkszDefaultProvider._hascCs tjj|ƒS)N)rÒrÓr )rrÓrrrroszDefaultProvider._isdircCs tj|ƒS)N)rÒÚlistdir)rrÓrrrrp"szDefaultProvider._listdircCst|j|j|ƒdƒS)NÚrb)r rgrf)rrñròrrrrô%sz#DefaultProvider.get_resource_streamc Cst|dƒ� }|jƒSQRXdS)Nr…)r ru)rrÓÚstreamrrrrj(s zDefaultProvider._getcCsttdtdƒƒ}t||ƒdS)NÚSourceFileLoader)rÌÚimportlib_machineryÚtyper³)rZ loader_clsrrrÚ _register,s zDefaultProvider._registerN) rrrrrkrorprôrjr'rŠrrrrr¯sc@s8eZdZdZdd„ZZdd„Zdd„ZdZdd„Z dS) r«z.Provider that returns nothing for all requestscCsdS)NFr)rrÓrrrre9szEmptyProvider.cCsdS)NrÐr)rrÓrrrre:scCsgS)Nr)rrÓrrrre;sNcCsdS)Nr)rrrrrý>szEmptyProvider.__init__) rrrrrorkrjrprfrýrrrrr«6s  c@s eZdZdZedd„ƒZeZdS)Ú ZipManifestsz zip manifest builder c s2t|ƒ� ‰‡fdd„ˆjƒDƒ}t|ƒSQRXdS)a Build a dictionary similar to the zipimport directory caches, except instead of tuples, store ZipInfo objects. Use a platform-specific path separator (os.sep) for the path keys for compatibility with pypy on Windows. c3s&|]}|jdtjƒˆj|ƒfVqdS)r{N)r5rÒÚsepZgetinfo)r+rç)Úzfilerrr,Usz%ZipManifests.build..N)ÚContextualZipFileZnamelistrR)rrÓrVr)r�rÚbuildJs   zZipManifests.buildN)rrrrr'r�Úloadrrrrr‹Es r‹c@s$eZdZdZejddƒZdd„ZdS)ÚMemoizedZipManifestsz% Memoized zipfile manifests. Ú manifest_modzmanifest mtimecCsRtjj|ƒ}tj|ƒj}||ks.||j|krH|j|ƒ}|j||ƒ||<||jS)zW Load a manifest at path or return a suitable manifest already loaded. ) rÒrÓÚnormpathrQÚst_mtimeÚmtimer�r’Úmanifest)rrÓr•r–rrrr�fs    zMemoizedZipManifests.loadN)rrrrrÚ namedtupler’r�rrrrr‘`s r‘cs0eZdZdZdd„Zdd„Z‡fdd„Z‡ZS)rŽzL Supplement ZipFile class to support context manager for Python 2.6 cCs|S)Nr)rrrrÚ __enter__yszContextualZipFile.__enter__cCs |jƒdS)N)Úclose)rr‰rnÚ tracebackrrrÚ__exit__|szContextualZipFile.__exit__cs(ttjdƒrtj||ŽStt|ƒj|ƒS)zI Construct a ZipFile or ContextualZipFile as appropriate r›)rÕÚzipfileÚZipFilerrŽÚ__new__)rrdÚkwargs)rrrržs  zContextualZipFile.__new__)rrrrr˜r›ržrHrr)rrrŽtsrŽc@sšeZdZdZdZeƒZdd„Zdd„Zdd„Z e d d „ƒZ d d „Z e d d„ƒZdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „ZdS)!r°z"Resource support for zips and eggsNcCs tj||ƒ|jjtj|_dS)N)r®rýrÏÚarchiverÒrŒÚzip_pre)rrÎrrrrýŽs zZipProvider.__init__cCs4|j|jƒr|t|jƒd…Std||jfƒ‚dS)Nz%s is not a subpath of %s)r9r¡rwÚAssertionError)rÚfspathrrrÚ _zipinfo_name’s zZipProvider._zipinfo_namecCsP|j|}|j|jtjƒr:|t|jƒdd…jtjƒStd||jfƒ‚dS)Nr-z%s is not a subpath of %s)r¡r9r‚rÒrŒrwrr¢)rÚzip_pathr£rrrÚ_parts›s  zZipProvider._partscCs|jj|jjƒS)N)Ú_zip_manifestsr�rÏr )rrrrÚzipinfo¥szZipProvider.zipinfocCs`|jstdƒ‚|j|ƒ}|jƒ}dj|j|ƒƒ|krTx|D]}|j||j|ƒƒq:W|j||ƒS)Nz5resource_filename() only supported for .egg, not .zipr{)r~rzÚ_resource_to_zipÚ_get_eager_resourcesrmr¦Ú_extract_resourceÚ _eager_to_zip)rrñròr¥Úeagersrçrrrró©s  z!ZipProvider.get_resource_filenamecCs"|j}|jd}tj|ƒ}||fS)Nrr-r7)rrr7)Z file_sizeÚ date_timeÚtimeZmktime)Zzip_statÚsizer®Ú timestamprrrÚ_get_date_and_size¶s  zZipProvider._get_date_and_sizec Csn||jƒkrDx*|jƒ|D]}|j|tjj||ƒƒ}qWtjj|ƒS|j|j|ƒ\}}tsdt dƒ‚yä|j |j |j |ƒƒ}|j ||ƒrŠ|Stdtjj|ƒd�\}} tj||jj|ƒƒtj|ƒt| ||fƒ|j| |ƒyt| |ƒWn\tjk �rDtjj|ƒ�r>|j ||ƒ�r|Stjdk�r>t|ƒt| |ƒ|S‚YnXWn tjk �rh|jƒYnX|S)Nz>"os.rename" and "os.unlink" are not supported on this platformz .$extract)ÚdirrO)Ú_indexr«rÒrÓrmrer²r¨Ú WRITE_SUPPORTÚIOErrorrNr~r¦Ú _is_currentÚ_mkstempÚwriterÏr}r™rr[r ÚerrorÚisfilerçr rJ) rrñr¥rçZlastr±r°Z real_pathZoutfZtmpnamrrrr«¿s@        zZipProvider._extract_resourcec Csx|j|j|ƒ\}}tjj|ƒs$dStj|ƒ}|j|ksB|j|krFdS|jj |ƒ}t |dƒ�}|j ƒ}WdQRX||kS)zK Return True if the file_path is current for this zip_path Fr…N) r²r¨rÒrÓr»rQÚst_sizer”rÏr}r ru) rZ file_pathr¥r±r°rQZ zip_contentsÚfZ file_contentsrrrr·ós    zZipProvider._is_currentcCsB|jdkr>> names = 'bar', 'foo', 'Python-2.7.10.egg', 'Python-2.7.2.egg' >>> _by_version_descending(names) ['Python-2.7.10.egg', 'Python-2.7.2.egg', 'foo', 'bar'] >>> names = 'Setuptools-1.2.3b1.egg', 'Setuptools-1.2.3.egg' >>> _by_version_descending(names) ['Setuptools-1.2.3.egg', 'Setuptools-1.2.3b1.egg'] >>> names = 'Setuptools-1.2.3b1.egg', 'Setuptools-1.2.3.post1.egg' >>> _by_version_descending(names) ['Setuptools-1.2.3.post1.egg', 'Setuptools-1.2.3b1.egg'] cSs2tjj|ƒ\}}tj|jdƒ|gƒ}dd„|DƒS)z6 Parse each component of the filename r+cSsg|]}tjj|ƒ‘qSr)rrKré)r+r3rrrú Èsz?_by_version_descending.._by_version..)rÒrÓÚsplitextÚ itertoolsÚchainr)rçÚextr<rrrÚ _by_versionÂsz+_by_version_descending.._by_versionT)r'r6)Úsorted)rMrÙrrrÚ_by_version_descending³srÛc cs¨t|ƒ}tjj|ƒo tj|tjƒ�r¤t|ƒrPtj|t |tjj |dƒƒd�V�nTt tj |ƒƒ}�xB|D�]8}|j ƒ}|jdƒsˆ|jdƒràtjj ||ƒ}tjj|ƒrÂttj |ƒƒdkr¶qft ||ƒ}nt|ƒ}tj|||td�Vqf| oìt|ƒ�rttjj ||ƒƒ}xœ|D] } | V�qWqf| rf|jdƒrfttjj ||ƒƒ�} | jƒ} WdQRXxN| D]F} | jƒ�sh�qVtjj || jƒƒ} t| ƒ}x|D] }|V�qˆWP�qVWqfWdS) z6Yield distributions accessible on a sys.path directoryzEGG-INFO)rÅz .egg-infoz .dist-infor)Ú precedencez .egg-linkN)Ú_normalize_cachedrÒrÓr ÚaccessÚR_OKr€rŒrÎr©rmrÛr„r8rÍrwr¨Ú from_locationr¥r…r Ú readlinesÚstripÚrstrip)rÇrÊrËZpath_item_entriesrür8ZfullpathrÅrr¹Z entry_fileZ entry_linesÚlinerÓrrrrÚ find_on_pathÍsB       råÚ FileFinder)Ú_namespace_handlers)Ú_namespace_packagescCs |t|<dS)ašRegister `namespace_handler` to declare namespace packages `importer_type` is the type or class of a PEP 302 "Importer" (sys.path item handler), and `namespace_handler` is a callable like this:: def namespace_handler(importer, path_entry, moduleName, module): # return a path_entry to use for child packages Namespace handlers are only called if the importer object has already agreed that it can handle the relevant path item, and they should only return a subpath if the module __path__ does not already contain an equivalent subpath. For an example namespace handler, see ``pkg_resources.file_ns_handler``. N)rç)rÉZnamespace_handlerrrrr²scCsÀt|ƒ}|dkrdS|j|ƒ}|dkr*dStjj|ƒ}|dkrbtj|ƒ}tj|<g|_t|ƒnt |dƒsvt d|ƒ‚t t |ƒ}|||||ƒ}|dk r¼|j}|j |ƒ|j|ƒt|||ƒ|S)zEEnsure that named package includes a subpath of path_item (if needed)NÚ__path__zNot a package:)rÚ find_modulerkrÉrBÚtypesÚ ModuleTyperéÚ_set_parent_nsrÕrêrÍrçr;Ú load_moduleÚ_rebuild_mod_path)Ú packageNamerÊrÇrÏrÎZhandlerrÒrÓrrrÚ _handle_nss*         rñcsRdd„tjDƒ‰‡fdd„‰‡‡fdd„}|j|d�dd„|Dƒ|jd d …<d S) zq Rebuild module.__path__ ensuring that all entries are ordered corresponding to their sys.path order cSsg|] }t|ƒ‘qSr)rÝ)r+ÚprrrrÔ5sz%_rebuild_mod_path..c s(y ˆj|ƒStk r"tdƒSXdS)z/ Workaround for #520 and #513. ÚinfN)ÚindexrpÚfloat)rü)Úsys_pathrrÚsafe_sys_path_index7s z._rebuild_mod_path..safe_sys_path_indexcs<|jtjƒ}ˆjdƒd}|d| …}ˆttjj|ƒƒƒS)zR Return the ordinal of the path based on its position in sys.path r,r-N)rrÒrŒÚcountrÝrm)rÓÚ path_partsZ module_partsr<)Ú package_namer÷rrÚposition_in_sys_path@s z/_rebuild_mod_path..position_in_sys_path)r'cSsg|] }t|ƒ‘qSr)rÝ)r+ròrrrrÔJsN)rkrÓr!ré)Z orig_pathrúrÎrûr)rúr÷rörrï0s   rïcCsÒtjƒzº|tkrdStjd}}d|krŠdj|jdƒdd…ƒ}t|ƒ|tkrZt|ƒytj |j }Wnt k rˆt d|ƒ‚YnXtj |gƒj|ƒtj |gƒx|D]}t||ƒq®WWdtjƒXdS)z9Declare that package 'packageName' is a namespace packageNr,r-zNot a package:r7)Ú_impÚ acquire_lockrèrkrÓrmrr‚rËrÉrérÀrêrr;rñÚ release_lock)rðrÓrÁrÊrrrr‚Ms&   c CsJtjƒz2x,tj|fƒD]}t||ƒ}|rt||ƒqWWdtjƒXdS)zDEnsure that previously-declared namespace packages include path_itemN)rürýrèrBrñr´rþ)rÊrÁÚpackagerÒrrrr´ns cCsFtjj||jdƒdƒ}t|ƒ}x |jD]}t|ƒ|kr(Pq(W|SdS)zBCompute an ns-package subpath for a filesystem or zipfile importerr,r-Nr7)rÒrÓrmrrÝré)rÇrÊrðrÎrÒZ normalizedrrrrÚfile_ns_handlerzs   rcCsdS)Nr)rÇrÊrðrÎrrrÚnull_ns_handlerŽsrcCstjjtjj|ƒƒS)z1Normalize a file/dir name for comparison purposes)rÒrÓÚnormcaseÚrealpath)rZrrrr •sc Cs2y||Stk r,t|ƒ||<}|SXdS)N)rÊr )rZr×ÚresultrrrrÝšs rÝcCs|jƒjdƒS)z@ Determine if given path appears to be an unpacked egg. z.egg)r8rÍ)rÓrrrr€¢sr€cCs<|jdƒ}|jƒ}|r8dj|ƒ}ttj||tj|ƒdS)Nr,)rr:rmÚsetattrrkrÉ)rðr<rçrÁrrrrí«s   ríccsht|tjƒr>xV|jƒD]"}|jƒ}|r|jdƒ r|VqWn&x$|D]}xt|ƒD] }|VqRWqDWdS)z9Yield non-empty/non-comment lines of a string or sequenceú#N)rrrèÚ splitlinesrâr9r™)Ústrsr2Zssrrrr™³s   z \w+(\.\w+)*$z– (?P[^-]+) ( -(?P[^-]+) ( -py(?P[^-]+) ( -(?P.+) )? )? )? c@sŒeZdZdZffdfdd„Zdd„Zdd„Zdd d „Zd d „Zddd„Z e j dƒZ e ddd„ƒZe dd„ƒZe ddd„ƒZe ddd„ƒZdS)rŽz3Object representing an advertised importable objectNcCsJt|ƒstd|ƒ‚||_||_t|ƒ|_tjddj|ƒƒj |_ ||_ dS)NzInvalid module namezx[%s]ú,) ÚMODULErprçÚ module_namerÚattrsr�rérmrr¹)rrçr r rr¹rrrrýÓs  zEntryPoint.__init__cCsHd|j|jf}|jr*|ddj|jƒ7}|jrD|ddj|jƒ7}|S)Nz%s = %sú:r,z [%s]r )rçr r rmr)rr2rrrrÅÜs zEntryPoint.__str__cCs dt|ƒS)NzEntryPoint.parse(%r))rF)rrrrr¸äszEntryPoint.__repr__TcOs6| s|s|rtjdtdd�|r.|j||Ž|jƒS)zH Require packages for this EntryPoint, then resolve it. zJParameters to load are deprecated. Call .resolve and .require separately.rg)r>)rCrDÚDeprecationWarningrtr)rrtrdrŸrrrr�çs zEntryPoint.loadcCsVt|jdgdd�}ytjt|j|ƒStk rP}ztt|ƒƒ‚WYdd}~XnXdS)zD Resolve the entry point from its module and attrs. rr)ÚfromlistÚlevelN) rËr Ú functoolsÚreducerÌr rÀrÞrF)rrÎÚexcrrrrös zEntryPoint.resolvecCsH|jr|j rtd|ƒ‚|jj|jƒ}tj|||ƒ}tttj|ƒƒdS)Nz&Can't require() without a distribution) rr¹r’r rƒrrrr)rrr rrVrrrrt s  zEntryPoint.requirez]\s*(?P.+?)\s*=\s*(?P[\w.]+)\s*(:\s*(?P[\w.]+))?\s*(?P\[.*\])?\s*$cCsf|jj|ƒ}|sd}t||ƒ‚|jƒ}|j|dƒ}|drJ|djdƒnf}||d|d|||ƒS)aParse a single entry point from string `src` Entry point syntax follows the form:: name = some.module:some.attr [extra1, extra2] The entry name and module name are required, but the ``:attrs`` and ``[extras]`` parts are optional z9EntryPoint must be in 'name=module:attrs [extras]' formatrÚattrr,rçrÎ)ÚpatternrjrpÚ groupdictÚ _parse_extrasr)rÚsrcr¹rrrWÚresrr rrrré s  zEntryPoint.parsecCs(|sfStjd|ƒ}|jr"tƒ‚|jS)NÚx)r�réÚspecsrpr)rZ extras_specrºrrrr$ s zEntryPoint._parse_extrascCsZt|ƒstd|ƒ‚i}x>t|ƒD]2}|j||ƒ}|j|krHtd||jƒ‚|||j<q W|S)zParse an entry point groupzInvalid group namezDuplicate entry point)r rpr™rérç)rroÚlinesr¹Úthisrär rrrÚ parse_group- s   zEntryPoint.parse_groupcCsxt|tƒr|jƒ}nt|ƒ}i}xR|D]J\}}|dkrD|s|sdStjj|ƒ}|djdƒr:tjj|dd…dƒS|S)NrÐr-zmd5=r7r7)rÐ)rréZurlparser9Z urlunparse)rZparsedrrrÚ_remove_md5_fragmentN s  r"cCs@dd„}t||ƒ}tt|ƒdƒ}|jdƒ\}}}t|jƒƒp>dS)z„ Given an iterable of lines from a Metadata file, return the value of the Version field, if present, or None otherwise. cSs|jƒjdƒS)Nzversion:)r8r9)rärrrre\ sz$_version_from_file..rÐr N)rÚnextÚiterÚ partitionr–râ)rZis_version_lineZ version_linesrärÜrnrrrÚ_version_from_fileW s  r&c@sZeZdZdZdZddddedefdd„ZedGdd„ƒZ dd „Z e d d „ƒZ d d „Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Ze dd„ƒZe dd„ƒZdd„Ze d d!„ƒZe d"d#„ƒZffd$d%„Zd&d'„ZdHd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„ZedId3d4„ƒZ d5d6„Z!d7d8„Z"dJd9d:„Z#d;d<„Z$dKd=d>„Z%d?d@„Z&dAdB„Z'dCdD„Z(e dEdF„ƒZ)dS)LrŒz5Wrap an actual or potential sys.path entry w/metadatazPKG-INFONcCsFt|pdƒ|_|dk r t|ƒ|_||_||_||_||_|p>t|_ dS)NZUnknown) r•rr–Ú_versionr2rlrrÜr¬Ú _provider)rrrÅrrKr2rlrÜrrrrýg s zDistribution.__init__c Ks~dgd\}}}}tjj|ƒ\}} | jƒtkr^t| jƒ}t|ƒ} | r^| jddddƒ\}}}}|||f||||dœ|—ŽjƒS)NrÚrçZverZpyverrq)rrKr2rl)rÒrÓrÕr8Ú_distributionImplÚEGG_NAMEroÚ_reload_version) rrr�rÅrTrrKr2rlrØrjrrrràs s   zDistribution.from_locationcCs|S)Nr)rrrrr+„ szDistribution._reload_versioncCs(|j|j|jt|jƒ|jpd|jp$dfS)NrÐ)Úparsed_versionrÜr'r"rr2rl)rrrrr5‡ s zDistribution.hashcmpcCs t|jƒS)N)Úhashr5)rrrrr’ szDistribution.__hash__cCs |j|jkS)N)r5)rr!rrrr • szDistribution.__lt__cCs |j|jkS)N)r5)rr!rrrr"˜ szDistribution.__le__cCs |j|jkS)N)r5)rr!rrrr%› szDistribution.__gt__cCs |j|jkS)N)r5)rr!rrrr$ž szDistribution.__ge__cCst||jƒsdS|j|jkS)NF)rrr5)rr!rrrr#¡ s zDistribution.__eq__cCs ||k S)Nr)rr!rrrr&§ szDistribution.__ne__c Cs0y|jStk r*|jjƒ|_}|SXdS)N)Z_keyrÀrr8)rr'rrrr'® s zDistribution.keycCst|dƒst|jƒ|_|jS)NÚ_parsed_version)rÕrNrKr.)rrrrr,¶ s  zDistribution.parsed_versioncCsXtjj}t|j|ƒ}|sdS|js&dStjdƒjƒjddƒ}t j |j ft |ƒŽt ƒdS)Na> '{project_name} ({version})' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommended to migrate to PEP 440 compatible versions. rqrÛ)rrKÚ LegacyVersionrr.rCrDrâr5rCrDr¼Úvarsr)rZLVZ is_legacyrHrrrÚ_warn_legacy_version½ s z!Distribution._warn_legacy_versionc CsLy|jStk rFt|j|jƒƒ}|dkrBd}t||j|ƒ‚|SXdS)Nz(Missing 'Version:' header and/or %s file)r'rÀr&Ú _get_metadataÚPKG_INFOrp)rrKrHrrrrK× szDistribution.versionc Cs°y|jStk rªdgi}|_x€dD]x}xrt|j|ƒƒD]`\}}|rˆd|kr||jddƒ\}}t|ƒrpg}n t|ƒs|g}t|ƒp†d}|j|gƒj t |ƒƒq>Wq*W|SXdS)Nú requires.txtú depends.txtr r-)r4r5) Z_Distribution__dep_maprÀršr2rr�ržr›rrr”)rÚdmrçr(rr)rrrÚ_dep_mapâ s   zDistribution._dep_mapc Csj|j}g}|j|jdfƒƒxH|D]@}y|j|t|ƒƒWq"tk r`td||fƒ‚Yq"Xq"W|S)z@List of Requirements needed for this distro if `extras` are usedNz%s has no such extra feature %r)r7rrBr›rÊr’)rrr6ZdepsrØrrrr ö s zDistribution.requiresccs(|j|ƒr$x|j|ƒD] }|VqWdS)N)rërí)rrçrärrrr2 s zDistribution._get_metadataFcCsZ|dkrtj}|j||d�|tjkrVt|jƒx$|jdƒD]}|tjkrEnsure distribution is importable on `path` (default=sys.path)N)r5znamespace_packages.txt)rkrÓrr´rr2rÉr‚)rrÓr5ZpkgrrrÚactivate s   zDistribution.activatecCs8dt|jƒt|jƒ|jptf}|jr4|d|j7}|S)z@Return what this distribution's standard .egg filename should bez %s-%s-py%sr+)rœrrKr2r>rl)rrZrrrr~ s zDistribution.egg_namecCs |jrd||jfSt|ƒSdS)Nz%s (%s))rrF)rrrrr¸ szDistribution.__repr__c Cs@yt|ddƒ}Wntk r(d}YnX|p0d}d|j|fS)NrKz[unknown version]z%s %s)rÌrpr)rrKrrrrÅ% s  zDistribution.__str__cCs|jdƒrt|ƒ‚t|j|ƒS)zADelegate all unrecognized public attributes to .metadata providerrÜ)r9rÀrÌr()rrrrrÚ __getattr__- s zDistribution.__getattr__cKs|jt|ƒtjj|ƒ|f|ŽS)N)ràrÝrÒrÓr�)rrZrÅrTrrrrÎ3 szDistribution.from_filenamecCs<t|jtjjƒr"d|j|jf}nd|j|jf}tj|ƒS)z?Return a ``Requirement`` that matches this distribution exactlyz%s==%sz%s===%s)rr,rrKr_rr�ré)rÚspecrrrr": szDistribution.as_requirementcCs.|j||ƒ}|dkr&td||ffƒ‚|jƒS)z=Return the `name` entry point of `group` or raise ImportErrorNzEntry point %r not found)rzrÞr�)rrorçr rrrrxC s zDistribution.load_entry_pointc CsPy |j}Wn,tk r6tj|jdƒ|ƒ}|_YnX|dk rL|j|iƒS|S)z=Return the entry point map for `group`, or the full entry mapzentry_points.txtN)Z_ep_maprÀrŽr!r2rB)rroZep_maprrrryJ s  zDistribution.get_entry_mapcCs|j|ƒj|ƒS)z||kr>|jtkr>| rˆ|||d…krˆdS|tjkrš|j ƒ|j ||ƒ|j ||ƒPq>W|tjkrÊ|j ƒ|rÜ|j d|ƒn |j |ƒdSxBy|j ||dƒ} Wnt k �rPYqìX|| =|| =| }qìWdS)aäEnsure self.location is on path If replace=False (default): - If location is already in path anywhere, do nothing. - Else: - If it's an egg and its parent directory is on path, insert just ahead of the parent. - Else: add to the end of path. If replace=True: - If location is already on path anywhere (not eggs) or higher priority than its parent (eggs) do nothing. - Else: - If it's an egg and its parent directory is on path, insert just ahead of the parent, removing any lower-priority entries. - Else: add it to the front of path. NcSsg|]}|rt|ƒp|‘qSr)rÝ)r+ròrrrrÔt sz*Distribution.insert_on..rr-)rrÝrÒrÓreÚ enumeraterÜr¡rkÚcheck_version_conflictrr;rôrp) rrÓÚlocr5ZnlocZbdirZnpathròrZnprrrrZ sB        zDistribution.insert_oncCs¬|jdkrdStj|jdƒƒ}t|jƒ}x~|jdƒD]p}|tjks4||ks4|tkrTq4|dkr^q4t tj|ddƒ}|r�t|ƒj |ƒs4|j |jƒr�q4t d|||jfƒq4WdS) NÚ setuptoolsznamespace_packages.txtz top_level.txtÚ pkg_resourcesÚsiterdzIModule %s was already imported from %s, but %s is being added to sys.path)r?r>r@) r'rRrSr2r rrkrÉrèrÌr9Ú issue_warning)rZnspr=ÚmodnameÚfnrrrr<� s"   z#Distribution.check_version_conflictc Cs4y |jWn$tk r.tdt|ƒƒdSXdS)NzUnbuilt egg for FT)rKrprAr·)rrrrr7³ s  zDistribution.has_versioncKsDd}x$|jƒD]}|j|t||dƒƒqW|jd|jƒ|jf|ŽS)z@Copy this distribution, substituting in any changed keyword argsz.)r7)rrrrrà szDistribution.extras)N)NF)N)N)NF)*rrrrr3r>r¡rýr'ràr+rÂr5rr r"r%r$r#r&r'r,r1rKr7r r2r8r~r¸rÅr9rÎr"rxryrzrr<r7rDrrrrrrŒc sN             Cc@seZdZdd„ZdS)ÚEggInfoDistributioncCst|j|jƒƒ}|r||_|S)añ Packages installed by distutils (e.g. numpy or scipy), which uses an old safe_version, and so their version numbers can get mangled when converted to filenames (e.g., 1.11.0.dev0+2329eae to 1.11.0.dev0_2329eae). These distributions will not be parsed properly downstream by Distribution and safe_version, so take an extra step and try to get the version number from the metadata file itself instead of the filename. )r&r2r3r')rZ md_versionrrrr+É s z#EggInfoDistribution._reload_versionN)rrrr+rrrrrEÈ srEc@s>eZdZdZdZejdƒZedd„ƒZ edd„ƒZ dd „Z d S) ÚDistInfoDistributionzGWrap an actual or potential sys.path entry w/metadata, .dist-info styleZMETADATAz([\(,])\s*(\d.*?)\s*([,\)])c Cs@y|jStk r:|j|jƒ}tjjƒj|ƒ|_|jSXdS)zParse and cache metadataN)Z _pkg_inforÀrìr3ÚemailÚparserZParserZparsestr)rrÅrrrÚ_parsed_pkg_infoà s  z%DistInfoDistribution._parsed_pkg_infoc Cs,y|jStk r&|jƒ|_|jSXdS)N)Ú_DistInfoDistribution__dep_maprÀÚ_compute_dependencies)rrrrr7ê s  zDistInfoDistribution._dep_mapcs¢dgi}|_g‰x&|jjdƒp"gD]}ˆjt|ƒƒq$W‡fdd„}t|dƒƒ}|dj|ƒx<|jjdƒppgD](}t|jƒƒ}tt||ƒƒ|ƒ||<qrW|S)z+Recompute this distribution's dependencies.Nz Requires-Distc3s0x*ˆD]"}|j s"|jjd|iƒr|VqWdS)Nr()r)r*)r(rº)rrrÚreqs_for_extraû s zBDistInfoDistribution._compute_dependencies..reqs_for_extrazProvides-Extra) rJrIZget_allrr”Ú frozensetr›râr)rr6rºrLÚcommonr(Zs_extrar)rrrKò s   z*DistInfoDistribution._compute_dependenciesN) rrrrr3r?r@ZEQEQrÂrIr7rKrrrrrFÛ s   rF)z.eggz .egg-infoz .dist-infoc Os^d}tƒ}y"xtj|ƒj|kr(|d7}qWWntk r@YnXtj|d|di|—ŽdS)Nr-r>)rOrkrãrärprCrD)rdrTrrXrrrrA srAc@seZdZdd„ZdS)ÚRequirementParseErrorcCs dj|jƒS)NrÛ)rmrd)rrrrrÅ szRequirementParseError.__str__N)rrrrÅrrrrrO srOccshtt|ƒƒ}xV|D]N}d|kr0|d|jdƒ…}|jdƒrV|dd…jƒ}|t|ƒ7}t|ƒVqWdS)zŠYield ``Requirement`` objects for each specification in `strs` `strs` must be a string, or a (possibly-nested) iterable thereof. z #Nú\rgéþÿÿÿ)r$r™rÈrÍrâr#r�)rrrärrrr”# s    csPeZdZ‡fdd„Zdd„Zdd„Zdd„Zd d „Zd d „Ze d d„ƒZ ‡Z S)r�csÈytt|ƒj|ƒWn2tjjk rF}ztt|ƒƒ‚WYdd}~XnX|j|_ t |jƒ}||j ƒ|_ |_ dd„|jDƒ|_ttt|jƒƒ|_|j |jt|jƒ|jr°t|jƒndf|_t|jƒ|_dS)z>DO NOT CALL THIS UNDOCUMENTED METHOD; use Requirement.parse()!NcSsg|]}|j|jf‘qSr)r8rK)r+r:rrrrÔA sz(Requirement.__init__..)rr�rýrrZInvalidRequirementrOrFrçZ unsafe_namer•r8rr'Ú specifierrrrr›rrMr)ÚhashCmpr-Ú_Requirement__hash)rZrequirement_stringrcr)rrrrý7 s zRequirement.__init__cCst|tƒo|j|jkS)N)rr�rS)rr!rrrr#K s zRequirement.__eq__cCs ||k S)Nr)rr!rrrr&Q szRequirement.__ne__cCs0t|tƒr |j|jkrdS|j}|jj|dd�S)NFT)Z prereleases)rrŒr'rKrRÚcontains)rrrrrr T s   zRequirement.__contains__cCs|jS)N)rT)rrrrr` szRequirement.__hash__cCs dt|ƒS)NzRequirement.parse(%r))rF)rrrrr¸c szRequirement.__repr__cCst|ƒ\}|S)N)r”)r2rºrrrrée s zRequirement.parse) rrrrýr#r&r rr¸r]rérHrr)rrr�6 s  cCs0t|tƒs*Gdd„d|tƒ}|jdd…S|jS)z&Get an mro for a type or classic classc@s eZdZdS)z_get_mro..clsN)rrrrrrrro srr-N)rr‰ÚobjectÚ__mro__)rrrrÚ_get_mrok s rXcCs2x,tt|dt|ƒƒƒD]}||kr||SqWdS)z2Return an adapter factory for `ob` from `registry`rN)rXrÌr‰)Úregistryr`ÚtrrrrÍv srÍcCs&tjj|ƒ}tjj|ƒs"tj|ƒdS)z1Ensure that the parent directory of `path` existsN)rÒrÓrer Úmakedirs)rÓrerrrrŸ} s  cCs@ts tdƒ‚t|ƒ\}}|r<|r.)r%)rŠrrUrtr{r&rur8r÷rrrûrkrÓrOrPr½)rƒrtr{r„rurµr¹rrrÚ_initialize_master_working_setÊ s   rd)rr)rrr7)N)N)F)F)F)F)N)½rZ __future__rrkrÒrhr¯r?rërœrÐrCrQrZpkgutilr8rlrrÖZ email.parserrGr_rCrÖrrürÞZimpZ pip._vendorrZpip._vendor.six.movesrrrrr r r rµr r^Zos.pathr rZimportlib.machineryÚ machineryrˆrrrrËÚ version_inforWrDrtrƒrErrVrrKr_rIr/rJrNrQrUrZr[r^rarbrcZ _sget_noneZ _sset_nonersÚ__all__Ú Exceptionr�r�r¿r‘r’rÆr>r¡r¢r£r¤r¥r³rvrnrÙrhr@rirâr—r˜rurµrwrxryrzr¦r§rŠrRrr‰r¶Ú RuntimeErrorr“r‹rˆr•r–r›rœr�ržr­r®r¯rŠr«r¬r‹r‘r�rŽr°rÑr¨r©rªr±r…rÏrÓrÛråZ ImpImporterrÕrær²rñrïr‚r´rrr rÝr€rír™rjr rAÚ IGNORECASEr*rŽr"r&rŒrErFr)rArprOr”rr�rXrÍrŸrKršr¸ÚfilterwarningsrbrOrcrdrrrrÚs®             b          .   { 3    a  ' '       .     !          ~  g0 5