Reg@s dZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZyddlZWnek rvddlZYnXye Wne!k re"Z YnXddl#m$Z$ddl%m&Z&m'Z'm(Z(ddlm)Z)y&ddlm*Z*m+Z+m,Z,d Z-Wnek rd Z-YnXdd lm.Z/dd l0m1Z1m2Z2yddl3j4Z5e5j6Wnek rqdZ5YnXd dl7m8Z8ddl#m9Z9ddl#m:Z:e;de;de;de;de<Z=ddfej>koddfknre?de$j@rdZAdZBdZCdZDdZEdZFdZGdZHdZIdZJdZKdZLdZMdZNdZOdZPdZQdZRdZSGdddeTZUddZViZWddZXddZYd d!ZZd"d#Z[d$d%Z\d&d'Z]d(d)Z^d*d+Z_Z`d,d-Zad.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMddNddOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrgGZbGdsdIdIecZdGdtdJdJedZeGdudvdveeZfGdwdKdKedZgGdxdLdLedZhiZidyjjej>ZkdZldzZmd ZndZod Zpd{dmZqd|d0Zrgd}d~ZsddZtddZuejvdZwejvdZxeuZyddRZzdd/Z{e{Z|dd1Z}dd2Z~ddd3Zdd4ZGdd`d`ZGddadaeZGddDdDZGdddeZGddCdCZeZGddMdMe?ZGddEdEZddBZddOZddPZddUZddVZddWZdddXZGddgdgZeqeeGddhdheZGddidieZejGddedeeZeZGdddeZGdddeZGddjdjeZeqe jeGddbdbeZGddcdceZGdddddeZeXddiddkZd dd?Zd ddZee jed ddZeeeddZd ddZddZGdddZddZddZddZddZeejeee5drA ee5jeeXddieXddiddlZddZddZdd<ZdddnZddZeejeee jeee5dr ee5jeddZeeeddZZddZiddZddZddZddZddSZejvdjZejvdejejBjZGddHdHZddZddZGddFdFZGdddeZGdddeZdededeiZddZGdddeZddNZGddGdGe:jjZddZddZddYZddZddTZddZe jddeUdd ddZeeddZeddZGddpdpeZdS(aZ 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. )absolute_importN) get_importer)six)urllibmapfilter)utime)mkdirrenameunlinkTF)open)isdirsplit) py31compat)appdirs) packagingzpip._vendor.packaging.versionz pip._vendor.packaging.specifiersz"pip._vendor.packaging.requirementszpip._vendor.packaging.markerszPython 3.5 or later is requiredc@seZdZdZdS) PEP440Warningza Used when there is an issue with a version or specifier not complying with PEP 440. N)__name__ __module__ __qualname____doc__rr/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-5.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.pyrxs rc CsCytjj|SWn(tjjk r>tjj|SYnXdS)N)rversionVersionInvalidVersion LegacyVersion)vrrr parse_versionsr!cKs-tj|tjtj||dS)N)globalsupdate _state_varsdictfromkeys)vartypekwrrr_declare_statesr)cCsLi}t}x6tjD](\}}|d|||||sr<c Cst}tj|}|dk r{tjdkr{y3ddjtdd|jdf}Wntk rzYnX|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. Ndarwinz macosx-%s-%s.r) get_build_platformmacosVersionStringmatchsysplatformjoin _macosx_versgroup ValueError)platmrrrget_supported_platforms 3 rKrequire 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 WorkingSetResourceManager Distribution Requirement EntryPointResolutionErrorVersionConflictDistributionNotFound UnknownExtraExtractionErrorparse_requirements safe_name safe_version get_platformcompatible_platforms yield_linessplit_sections safe_extra to_filenameinvalid_markerevaluate_markerensure_directorynormalize_pathEGG_DIST BINARY_DIST SOURCE_DIST CHECKOUT_DIST DEVELOP_DISTIMetadataProviderIResourceProvider FileMetadata PathMetadata EggMetadata EmptyProviderempty_provider NullProvider EggProviderDefaultProvider ZipProviderregister_finderregister_namespace_handlerregister_loader_typefixup_namespace_packagesrPkgResourcesDeprecationWarningrun_mainAvailableDistributionsc@s"eZdZdZddZdS)rgz.Abstract base for dependency resolution errorscCs|jjt|jS)N) __class__rreprr;)selfrrr__repr__szResolutionError.__repr__N)rrrrrrrrrrgs c@sXeZdZdZdZeddZeddZddZd d Z d S) rhz 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)r;)rrrrdist szVersionConflict.distcCs |jdS)Nr)r;)rrrrreqszVersionConflict.reqcCs|jjtS)N) _templateformatlocals)rrrrreportszVersionConflict.reportcCs$|s |S|j|f}t|S)zt If required_by is non-empty, return a version of self that is a ContextualVersionConflict. )r;ContextualVersionConflict)r required_byr;rrr with_contextszVersionConflict.with_contextN) rrrrrpropertyrrrrrrrrrhs  c@s5eZdZdZejdZeddZdS)rz A VersionConflict that accepts a third parameter, the set of the requirements that required the installed Distribution. z by {self.required_by}cCs |jdS)Nr?)r;)rrrrr*sz%ContextualVersionConflict.required_byN)rrrrrhrrrrrrrr"s  rc@sjeZdZdZdZeddZeddZeddZd d Z d d Z d S)riz&A requested distribution was not foundzSThe '{self.req}' distribution was not found and is required by {self.requirers_str}cCs |jdS)Nr)r;)rrrrr5szDistributionNotFound.reqcCs |jdS)Nr)r;)rrrr requirers9szDistributionNotFound.requirerscCs|js dSdj|jS)Nzthe applicationz, )rrE)rrrr requirers_str=s z"DistributionNotFound.requirers_strcCs|jjtS)N)rrr)rrrrrCszDistributionNotFound.reportcCs |jS)N)r)rrrr__str__FszDistributionNotFound.__str__N) rrrrrrrrrrrrrrrri/s  c@seZdZdZdS)rjz>Distribution doesn't have an "extra feature" of the given nameN)rrrrrrrrrjJs z{}.{}r?cCs|t|) rDmac_verospathexistshasattrplistlibrappendr)_cacherplist plist_contentrrrrFos   rFcCsddddij||S)NPowerPCppcPower_Macintosh)get)machinerrr _macosx_archsrc Csddlm}|}tjdkr|jd ryTt}tjdjdd}dt |dt |d t |fSWnt k rYnX|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 Mac OS X. r)ror=zmacosx- _zmacosx-%d.%d-%sr) sysconfigrorCrD startswithrFrunamereplaceintrrH)rorIrrrrrr@s   r@zmacosx-(\d+)\.(\d+)-(.*)zdarwin-(\d+)\.(\d+)\.(\d+)-(.*)cCsL|dks$|dks$||kr(dStj|}|rHtj|}|stj|}|rt|jd}d|jd|jdf}|dkr|dks|dkr|d krdSd S|jd|jdks|jd |jd krd St|jdt|jdkrDd 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. NTrz%s.%sr?z10.3z10.4Fr)rArBdarwinVersionStringrrG)providedrequiredreqMacprovMac provDarwindversion macosversionrrrrps*$"*cCsNtjdj}|d}|j||dIs the named metadata a directory? (like ``os.path.isdir()``)Nr)rrrrmetadata_isdirsz IMetadataProvider.metadata_isdircCsdS)z?List of metadata names in the directory (like ``os.listdir()``)Nr)rrrrmetadata_listdirsz"IMetadataProvider.metadata_listdircCsdS)z=Execute the named script in the supplied namespace dictionaryNr)r namespacerrrrM szIMetadataProvider.run_scriptN) rrrrrrrrrMrrrrr~s      c@s^eZdZdZddZddZddZdd Zd d Zd d Z dS)rz3An object that provides access to package resourcescCsdS)zdReturn a true filesystem path for `resource_name` `manager` must be an ``IResourceManager``Nr)manager resource_namerrrget_resource_filenamesz'IResourceProvider.get_resource_filenamecCsdS)ziReturn a readable file-like object for `resource_name` `manager` must be an ``IResourceManager``Nr)rrrrrget_resource_streamsz%IResourceProvider.get_resource_streamcCsdS)zmReturn a string containing the contents of `resource_name` `manager` must be an ``IResourceManager``Nr)rrrrrget_resource_stringsz%IResourceProvider.get_resource_stringcCsdS)z,Does the package contain the named resource?Nr)rrrr has_resourceszIResourceProvider.has_resourcecCsdS)z>Is the named resource a directory? (like ``os.path.isdir()``)Nr)rrrrrY"sz IResourceProvider.resource_isdircCsdS)z?List of resource names in the directory (like ``os.listdir()``)Nr)rrrrrW%sz"IResourceProvider.resource_listdirN) rrrrrrrrrYrWrrrrr s      c@seZdZdZdddZeddZeddZd d Zd d Z d dZ dddZ ddZ ddZ dddddZddddddZdddddZddZddd Zd!d"Zd#d$Zd%d&ZdS)'rbzDA collection of active distributions on sys.path (or a similar list)NcCs[g|_i|_i|_g|_|dkr9tj}x|D]}|j|q@WdS)z?Create working set from list of path entries (default=sys.path)N)entries entry_keysby_key callbacksrCr add_entry)rrentryrrr__init__,s       zWorkingSet.__init__cCsm|}yddlm}Wntk r5|SYnXy|j|Wntk rh|j|SYnX|S)z1 Prepare the master working set. r) __requires__)__main__r ImportErrorrLrh_build_from_requirements)clswsrrrr _build_master9s    zWorkingSet._build_mastercCs|g}t|}|j|t}x|D]}|j|q4Wx-tjD]"}||jkrU|j|qUW|jtjdd<|S)zQ Build a working set from a requirement spec. Rewrites sys.path. N)rlresolveraaddrCrrr)rreq_specrreqsdistsrrrrrrMs   z#WorkingSet._build_from_requirementscCsT|jj|g|jj|x*t|dD]}|j||dq3WdS)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)r setdefaultrrr]r)rrrrrrrcs zWorkingSet.add_entrycCs|jj|j|kS)z9True if `dist` is the active distribution for its project)rrr6)rrrrr __contains__rszWorkingSet.__contains__cCs@|jj|j}|dk r<||kr<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. N)rrr6rh)rrrrrrrvs zWorkingSet.findcsfdd|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). c3sL|]B}|jjD]&}dks=|jkr|VqqdS)N)rQvaluesr).0rr)rGrrr sz/WorkingSet.iter_entry_points..r)rrGrr)rGrrrSszWorkingSet.iter_entry_pointscCsQtjdj}|d}|j||d<|j|dj||dS)z?Locate distribution for `requires` and run `script_name` scriptrrrN)rCrrr5rLrM)rrequiresrrrrrrrMs    zWorkingSet.run_scriptccsji}x]|jD]R}||jkr(qx7|j|D](}||kr6d||<|j|Vq6WqWdS)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. rN)rrr)rseenitemr6rrr__iter__s  zWorkingSet.__iter__TFcCs|r|j|j|d||dkr4|j}|jj|g}|jj|jg}| r~|j|jkr~dS||j|j<|j|kr|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. rN) insert_onrlocationrrr6rr _added_new)rrrinsertrkeyskeys2rrrrs   zWorkingSet.addcCst|ddd}i}i}g}t} tjt} x|r|jd} | |krjqF| j| |sqF|j| j} | dkrx|j j| j} | dks| | krk|rk|} |dkr| dkrt |j }nt g}t g} |j | | |d|} || j<| dkrk| j| d}t| ||j| | | kr| | }t| | j|| j| jddd}|j|x/|D]'}| |j| j| j| | Map each requirement to the extras that demanded it. NcsCfdd|jf|p'dD}j pBt|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|iVqdS)extraN)markerevaluate)rr3)rrrrsz*_ReqExtras.markers_pass..N)N)rr4any)rrr extra_evalsr)rrrs  z_ReqExtras.markers_pass)rrrrrrrrrrs rc@seZdZdZdeeddZddZddZdd d Z d d Z d dZ ddddZ dddZ ddZddZddZdS)raz5Searchable 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.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)_distmaprDpythonscan)r search_pathrDr9rrrrs   zEnvironment.__init__cCsI|jdkp-|jdkp-|j|jk}|oHt|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)r9 py_versionrprD)rr py_compatrrrcan_addszEnvironment.can_addcCs|j|jj|dS)z"Remove `dist` from the environmentN)r8r6remove)rrrrrr?szEnvironment.removecCsN|dkrtj}x2|D]*}x!t|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)rCrr]r)rr;rrrrrr:s    zEnvironment.scancCs|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. )lowerr8r)rrdistribution_keyrrr __getitem__s zEnvironment.__getitem__cCso|j|rk|jrk|jj|jg}||krk|j||jdtjddddS)zLAdd `dist` if we ``can_add()`` it and it has not already been added r6hashcmpreverseTN) r> has_versionr8rr6rr"operator attrgetter)rrrrrrrs   zEnvironment.addFc Csy|j|}Wn!tk r6|s,d}YnX|dk rG|Sx%||jD]}||krU|SqUW|j||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)rrhr6obtain)rrr[rr rrrrrs    zEnvironment.best_matchcCs|dk 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.Nr)r requirementrrrrrH+s zEnvironment.obtainccs-x&|jjD]}||r|VqWdS)z=Yield the unique project names of the available distributionsN)r8r )rr6rrrr7s zEnvironment.__iter__cCs{t|tr|j|nXt|trdxF|D](}x||D]}|j|qFWq5Wntd|f|S)z2In-place addition of a distribution or environmentzCan't add %r to environment)rrdrrar)rotherprojectrrrr__iadd__=s zEnvironment.__iadd__cCs@|jgdddd}x||fD]}||7}q(W|S)z4Add an environment or distribution to an environmentrDNr9)r)rrJnewrrrr__add__IszEnvironment.__add__)rrrrrKPY_MAJORrr>r?r:rBrrrHrrLrNrrrrras       c@seZdZdZdS)rkaTAn 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)rrrrrrrrrkUs c@seZdZdZdZddZddZddZd d Zd d Z d dZ ddZ ddZ fddZ eddZddZddZdddZdS)rcz'Manage resource extraction and packagesNcCs i|_dS)N) cached_files)rrrrriszResourceManager.__init__cCst|j|S)zDoes the named resource exist?)rNr)rpackage_or_requirementrrrrrXlszResourceManager.resource_existscCst|j|S)z,Is the named resource an existing directory?)rNrY)rrQrrrrrYps zResourceManager.resource_isdircCst|j||S)z4Return a true filesystem path for specified resource)rNr)rrQrrrrrVvs z!ResourceManager.resource_filenamecCst|j||S)z9Return a readable file-like object for specified resource)rNr)rrQrrrrrU|s zResourceManager.resource_streamcCst|j||S)z%Return specified resource as a string)rNr)rrQrrrrrTs zResourceManager.resource_stringcCst|j|S)z1List the contents of the named resource directory)rNrW)rrQrrrrrWs z ResourceManager.resource_listdircCsttjd}|jpt}tjdj}t|jt }||_ ||_ ||_ |dS)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. N) rCexc_infoextraction_pathr`textwrapdedentlstriprkrrr cache_pathoriginal_error)rold_excrWtmplerrrrrextraction_errors   z ResourceManager.extraction_errorc Csy|jpt}tjj||d|}yt|Wntk rZ|jYnX|j|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-tmpr) rSr`rrrE_bypass_ensure_directory Exceptionr\_warn_unsafe_extraction_pathrP)r archive_namenames extract_path target_pathrrrget_cache_paths    zResourceManager.get_cache_pathcCsttjdkr*|jtjd r*dStj|j}|tj@sV|tj@rpd|}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. ntwindirNz%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).) rrrenvironstatst_modeS_IWOTHS_IWGRPwarningswarn UserWarning)rmodemsgrrrr_s &z,ResourceManager._warn_unsafe_extraction_pathcCs=tjdkr9tj|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. posiximiN)rrrhrichmod)rtempnamefilenamerorrr postprocessszResourceManager.postprocesscCs"|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)rPrHrS)rrrrrr^s  z#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)rforcerrrr_ sz!ResourceManager.cleanup_resources)rrrrrSrrXrYrVrUrTrWr\rd staticmethodr_rur^r_rrrrrces           cCs"tjjdp!tjddS)z Return the ``PYTHON_EGG_CACHE`` environment variable or a platform-relevant user cache dir for an app named "Python-Eggs". PYTHON_EGG_CACHEappnamez Python-Eggs)rrgrruser_cache_dirrrrrr`scCstjdd|S)zConvert an arbitrary string to a standard distribution name Any runs of non-alphanumeric/. characters are replaced with a single '-'. z[^A-Za-z0-9.]+-)resub)rrrrrm%sc Cs^yttjj|SWn=tjjk rY|jdd}tjdd|SYnXdS)zB Convert an arbitrary string to a standard version string rr>z[^A-Za-z0-9.]+r{N)rrrrrrr|r})rrrrrn-s cCstjdd|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)r|r}r@)r3rrrrs9scCs|jddS)z|Convert a project or version name to its filename-escaped form Any '-' characters are currently replaced with '_'. r{r)r)rrrrrtBscCsPyt|Wn;tk rK}zd|_d|_|SWYdd}~XnXdS)zo Validate text as a PEP 508 environment marker; return an exception if invalid or False otherwise. NF)rv SyntaxErrorrtlineno)texterrrruJs  cCs^y tjj|}|jSWn7tjjk rY}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)rmarkersMarkerr5 InvalidMarkerr~)rr3r4rrrrrvXs c@seZdZdZdZdZdZddZddZddZ d d Z d d Z d dZ ddZ ddZddZddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zed'd(Zd)d*ZdS)+rzETry to implement resources and metadata for arbitrary PEP 302 loadersNcCs:t|dd|_tjjt|dd|_dS)Nr__file__r)rrrrdirname module_path)rrrrrrnszNullProvider.__init__cCs|j|j|S)N)_fnr)rrrrrrrrsz"NullProvider.get_resource_filenamecCstj|j||S)N)ioBytesIOr)rrrrrrrusz NullProvider.get_resource_streamcCs|j|j|j|S)N)_getrr)rrrrrrrxsz NullProvider.get_resource_stringcCs|j|j|j|S)N)_hasrr)rrrrrr{szNullProvider.has_resourcecCs|j|j|S)N)regg_info)rrrrr_get_metadata_path~szNullProvider._get_metadata_pathcCs,|js|jS|j|}|j|S)N)rrr)rrrrrrrs zNullProvider.has_metadatacCs|js dS|j|}|j|}tjr8|Sy|jdSWnCtk r}z#|jdj||7_WYdd}~XnXdS)Nrzutf-8z in {} file at path: {}) rrrrPY2decodeUnicodeDecodeErrorreasonr)rrrvalueexcrrrrs  zNullProvider.get_metadatacCst|j|S)N)rqr)rrrrrrszNullProvider.get_metadata_linescCs|j|j|j|S)N)_isdirrr)rrrrrrYszNullProvider.resource_isdircCs%|jo$|j|j|j|S)N)rrr)rrrrrrszNullProvider.metadata_isdircCs|j|j|j|S)N)_listdirrr)rrrrrrWszNullProvider.resource_listdircCs)|jr%|j|j|j|SgS)N)rrr)rrrrrrs zNullProvider.metadata_listdirc Cs!d|}|j|s1tdjt|j|jdd}|jdd}|j|j|}||d>> warned = getfixture('recwarn') >>> warnings.simplefilter('always') >>> vrp = NullProvider._validate_resource_path >>> vrp('foo/bar.txt') >>> bool(warned) False >>> vrp('../foo/bar.txt') >>> bool(warned) True >>> warned.clear() >>> vrp('/foo/bar.txt') >>> bool(warned) True >>> vrp('foo/../../bar.txt') >>> bool(warned) True >>> warned.clear() >>> vrp('foo/f../bar.txt') >>> bool(warned) False Windows path separators are straight-up disallowed. >>> vrp(r'\foo/bar.txt') Traceback (most recent call last): ... ValueError: Use of .. or absolute path in a resource path is not allowed. >>> vrp(r'C:\foo/bar.txt') Traceback (most recent call last): ... ValueError: Use of .. or absolute path in a resource path is not allowed. Blank values are allowed >>> vrp('') >>> bool(warned) False Non-string values are not. >>> vrp(None) Traceback (most recent call last): ... AttributeError: ... Nz=Use of .. or absolute path in a resource path is not allowed.rz/ and will raise exceptions in a future release. stacklevelrr ) rrpardirr posixpathsepisabsntpathrHrlrmDeprecationWarning)rinvalidrprrrrs6 z$NullProvider._validate_resource_pathcCs2t|jdr"|jj|StddS)Nget_dataz=Can't perform this operation for loaders without 'get_data()')rrrr)rrrrrrszNullProvider._get)rrrregg_namerrrrrrrrrrrrYrrWrrMrrrrrwrrrrrrrgs0                   Kc@s.eZdZdZddZddZdS)rz&Provider based on a virtual filesystemcCstj|||jdS)N)rr _setup_prefix)rrrrrr-szEggProvider.__init__cCs|j}d}xq||krt|ratjj||_tjj|d|_||_P|}tjj |\}}qWdS)NzEGG-INFO) r _is_egg_pathrrbasenamerrEregg_rootr)rroldrrrrr1s   zEggProvider._setup_prefixN)rrrrrrrrrrr*s  c@sdeZdZdZddZddZddZdd Zd d Ze d d Z dS)rz6Provides access to package resources in the filesystemcCstjj|S)N)rrr)rrrrrrCszDefaultProvider._hascCstjj|S)N)rrr )rrrrrrFszDefaultProvider._isdircCs tj|S)N)rlistdir)rrrrrrIszDefaultProvider._listdircCst|j|j|dS)Nrb)r rr)rrrrrrrLsz#DefaultProvider.get_resource_streamc Cs't|d}|jSWdQRXdS)Nr)r r)rrstreamrrrrOszDefaultProvider._getcCs@d}x3|D]+}tt|td}t||q WdS)NSourceFileLoaderSourcelessFileLoader)rr)rimportlib_machinerytyper)r loader_namesr loader_clsrrr _registerSs zDefaultProvider._registerN) rrrrrrrrrr2rrrrrr@s      c@sPeZdZdZdZddZZddZddZd d Z dS) rz.Provider that returns nothing for all requestsNcCsdS)NFr)rrrrrr<cszEmptyProvider.cCsdS)Nrr)rrrrrreszEmptyProvider._getcCsgS)Nr)rrrrrrhszEmptyProvider._listdircCsdS)Nr)rrrrrkszEmptyProvider.__init__) rrrrrrrrrrrrrrr^s   c@s.eZdZdZeddZeZdS) ZipManifestsz zip manifest builder c sFtj|0fddjD}t|SWdQRXdS)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. c3s3|])}|jdtjj|fVqdS)rN)rrrgetinfo)rr)zfilerrrsz%ZipManifests.build..N)zipfileZipFilenamelistr%)rrr+r)rrbuildws zZipManifests.buildN)rrrrr2rloadrrrrrrs rc@s4eZdZdZejddZddZdS)MemoizedZipManifestsz% Memoized zipfile manifests. manifest_modzmanifest mtimecCsstjj|}tj|j}||ksC||j|krh|j|}|j||||<||jS)zW Load a manifest at path or return a suitable manifest already loaded. ) rrnormpathrhst_mtimemtimerrmanifest)rrrrrrrrs zMemoizedZipManifests.loadN)rrrrr namedtuplerrrrrrrs rc@seZdZdZdZeZddZddZddZ e d d Z d d Z e d dZddZddZddZddZddZddZddZddZdd ZdS)!rz"Resource support for zips and eggsNcCs*tj|||jjtj|_dS)N)rrrarchiverrzip_pre)rrrrrrszZipProvider.__init__cCsn|jtj}||jjkr(dS|j|jrQ|t|jdStd||jfdS)Nrz%s is not a subpath of %s) rstriprrrrrrrAssertionError)rfspathrrr _zipinfo_nameszZipProvider._zipinfo_namecCsj|j|}|j|jtjrM|t|jddjtjStd||jfdS)Nrz%s is not a subpath of %s)rrrrrrrr)rzip_pathrrrr_partss  'zZipProvider._partscCs|jj|jjS)N)_zip_manifestsrrr)rrrrzipinfoszZipProvider.zipinfocCs|jstd|j|}|j}dj|j||krxx'|D]}|j||j|qUW|j||S)Nz5resource_filename() only supported for .egg, not .zipr)rr_resource_to_zip_get_eager_resourcesrEr_extract_resource _eager_to_zip)rrrreagersrrrrrs    z!ZipProvider.get_resource_filenamecCs/|j}|jd}tj|}||fS)Nrrr )rrr ) file_size date_timetimemktime)zip_statsizer timestamprrr_get_date_and_sizes  zZipProvider._get_date_and_sizec Cs||jkr^x9|j|D]'}|j|tjj||}q#Wtjj|S|j|j|\}}tst dy&|j |j |j |}|j ||r|Stddtjj|\}} tj||jj|tj|t| ||f|j| |yt| |Wnjtjk rtjj|r|j ||r|Stjdkrt|t| ||SYnXWntjk r|jYnX|S)Nz>"os.rename" and "os.unlink" are not supported on this platformz .$extractdirre)_indexrrrrErrr WRITE_SUPPORTIOErrorrdrr _is_current_mkstempwriterrcloserrur errorisfilerr r\) rrrrlastrr real_pathoutftmpnamrrrrsD     zZipProvider._extract_resourcec Cs|j|j|\}}tjj|s2dStj|}|j|ks_|j|krcdS|jj |}t |d}|j }WdQRX||kS)zK Return True if the file_path is current for this zip_path FrN) rrrrrrhst_sizerrrr r) r file_pathrrrrh zip_contentsf file_contentsrrrrszZipProvider._is_currentcCs[|jdkrTg}x3dD]+}|j|r|j|j|qW||_|jS)Nnative_libs.txteager_resources.txt)rr)rrrr)rrrrrrr"s  z ZipProvider._get_eager_resourcesc Csy |jSWntk ri}x|jD]y}|jtj}x^|rtjj|dd}||kr||j|dPqF|jg||>> 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'] cSsGtjj|\}}tj|jd|g}dd|DS)z6 Parse each component of the filename r{cSs"g|]}tjj|qSr)rrr)rpartrrr s z?_by_version_descending.._by_version..)rrsplitext itertoolschainr)rextrrrr _by_versionsz+_by_version_descending.._by_versionr6rDT)sorted)rarrrr_by_version_descendings r!c #sttrHtjdttjjdVdSt}fdd|D}t |}xQ|D]I}tjj|}t |}x||D] } | VqWqWdS)z6Yield distributions accessible on a sys.path directoryrzEGG-INFONc3s'|]}t|r|VqdS)N) dist_factory)rr)r r rrrszfind_on_path..) _normalize_cached_is_unpacked_eggrdrrrrrE safe_listdirr!r") rr r rfilteredpath_item_entriesrfullpathfactoryrr)r r r find_on_paths       r*cCsf|j}tt|jd}|r.tS| rEt|rEtS| r_|jdr_tStS)z9 Return a dist_factory for a path_item and entry .egg-info .dist-infoz .egg-link)r+r,) r@r6rrdistributions_from_metadatarr]resolve_egg_linkNoDists)r rr r@is_metarrrr"s   r"c@s=eZdZdZddZejr-eZddZdS)r/zS >>> bool(NoDists()) False >>> list(NoDists()('anything')) [] cCsdS)NFr)rrrr__bool__.szNoDists.__bool__cCs tfS)N)iter)rr(rrr__call__3szNoDists.__call__N) rrrrr1rr __nonzero__r3rrrrr/&s   r/cCsytj|SWn~ttfk r+Yngtk r}zG|jtjtjtjfkpst |dddk}|sWYdd}~XnXfS)zI Attempt to list contents of path, but suppress some exceptions. winerrorNi ) rrPermissionErrorNotADirectoryErrorOSErrorerrnoENOTDIREACCESENOENTr)rr ignorablerrrr%7s!r%ccstjj|}tjj|rUttj|dkrCdSt||}n t|}tjj|}t j |||dt VdS)Nr precedence) rrrr rrrrrrdrr})rrootrrrrrr-Ls r-c csBt|/}x%|D]}|j}|r|VqWWdQRXdS)z1 Yield non-empty lines from file at path N)r strip)rrlinerrrnon_empty_lines[s   rBcsAt}fdd|D}tt|}t|fS)za Given a path to an .egg-link, resolve distributions present in the referenced path. c3s0|]&}tjjtjj|VqdS)N)rrrEr)rref)rrrrmsz#resolve_egg_link..)rBrr]next)rreferenced_pathsresolved_paths dist_groupsr)rrr.fs   r. FileFinder_namespace_handlers_namespace_packagescCs|t|.c s4yj|SWntk r/tdSYnXdS)z/ Workaround for #520 and #513. infN)indexrHfloat)r)sys_pathrrsafe_sys_path_indexs z._rebuild_mod_path..safe_sys_path_indexcsR|jtj}jdd}|d| }ttjj|S)zR Return the ordinal of the path based on its position in sys.path r>rN)rrrcountr#rE)r path_parts module_partsr) package_namer^rrposition_in_sys_pathsz/_rebuild_mod_path..position_in_sys_pathr6cSsg|]}t|qSr)r#)rrYrrrrs N)rCrr rrMr ) orig_pathrbrrcnew_pathr)rbr^r]rrUs  rUcCstjz|tkrdStj}|jd\}}}|rt||tkrdt|ytj|j }Wn!t k rt d|YnXtj |pdgj |tj |gx|D]}t||qWWdtjXdS)z9Declare that package 'packageName' is a namespace packageNr>zNot a package:)_imp acquire_lockrJrCr rpartitionrZrrrMrrrrrX release_lock)rVrrrr rrrrZs&        c Cs_tjzCx<tj|fD](}t||}|r t||q WWdtjXdS)zDEnsure that previously-declared namespace packages include path_itemN)rfrgrJrrXrri)r rpackagerrrrrs cCs]tjj||jdd}t|}x(|jD]}t||kr8Pq8W|SdS)zBCompute an ns-package subpath for a filesystem or zipfile importerr>rNr )rrrErr#rM)rr rVrr normalizedrrrrfile_ns_handlers " rlcCsdS)Nr)rr rVrrrrnull_ns_handler srmcCs.tjjtjjtjjt|S)z1Normalize a file/dir name for comparison purposes)rrnormcaserealpathr _cygwin_patch)rtrrrrx scCs#tjdkrtjj|S|S)a Contrary to POSIX 2008, on Cygwin, getcwd (3) contains symlink components. Using os.path.abspath() works around this limitation. A fix in os.getcwd() would probably better, in Cygwin even more so, except that this seems to be by design... cygwin)rCrDrrabspath)rtrrrrp srpc Cs=y ||SWn*tk r8t|||<}|SYnXdS)N)rrx)rtrresultrrrr#) s   r#cCs|jjdS)z7 Determine if given path appears to be an egg. z.egg)r@r)rrrrr1 srcCs.t|o-tjjtjj|ddS)z@ Determine if given path appears to be an unpacked egg. zEGG-INFOzPKG-INFO)rrrrrE)rrrrr$8 s r$cCsR|jd}|j}|rNdj|}ttj||tj|dS)Nr>)rrrEsetattrrCr)rVrrrrrrrSB s  rSccst|tjrSxk|jD]-}|j}|r|jd r|VqWn-x*|D]"}xt|D] }|VqmWqZWdS)z9Yield non-empty/non-comment lines of a string or sequence#N)rrr splitlinesr@rrq)strssssrrrrqJ s   z \w+(\.\w+)*$z (?P[^-]+) ( -(?P[^-]+) ( -py(?P[^-]+) ( -(?P.+) )? )? )? c@seZdZdZffdddZddZddZd d d Zd d ZddddZ e j dZ e dddZe ddZe dddZe dddZdS)rfz3Object representing an advertised importable objectNcCsXt|std|||_||_t||_t||_||_dS)NzInvalid module name)MODULErHr module_nametupleattrsrr)rrr{r}rrrrrrj s   zEntryPoint.__init__cCs`d|j|jf}|jr9|ddj|j7}|jr\|ddj|j7}|S)Nz%s = %s:r>z [%s],)rr{r}rEr)rrxrrrrs s   zEntryPoint.__str__cCsdt|S)NzEntryPoint.parse(%r))r)rrrrr{ szEntryPoint.__repr__TcOsI| s|s|r)tjdtdd|r?|j|||jS)zH Require packages for this EntryPoint, then resolve it. zJParameters to load are deprecated. Call .resolve and .require separately.rr?)rlrmrrLr)rrLr;kwargsrrrr~ szEntryPoint.loadcCsvt|jddgdd}ytjt|j|SWn7tk rq}ztt|WYdd}~XnXdS)zD Resolve the entry point from its module and attrs. fromlistrlevelrN) rr{ functoolsreducerr}rrr)rrrrrrr s zEntryPoint.resolvecCso|jr"|j r"td||jj|j}tj|||d|j}tttj|dS)Nz&Can't require() without a distributionr) rrrjrr[rr rr)rrrrr+rrrrL s zEntryPoint.requirez]\s*(?P.+?)\s*=\s*(?P[\w.]+)\s*(:\s*(?P[\w.]+))?\s*(?P\[.*\])?\s*$cCs|jj|}|s-d}t|||j}|j|d}|dri|djdnf}||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]' formatrattrr>rr)patternrBrH groupdict _parse_extrasr)rsrcrrJrpresrr}rrrr s  #zEntryPoint.parsecCs6|s fStjd|}|jr/t|jS)Nx)rerspecsrHr)r extras_specrrrrr s   zEntryPoint._parse_extrascCst|std|i}xWt|D]I}|j||}|j|krjtd||j|||j.is_version_linerr~N)rrDr2 partitionrnr@)rr version_linesrArrrrr_version_from_file s  rc s_eZdZdZdZddddededdZedddZ dd Z e d d Z d d Z ddZddZddZddZddZddZe ddZe ddZddZe d d!Ze d"d#Zed$d%Zd&d'Zfd(d)Zd*d+Zd,d-Zd.d/Zdd0d1d2Z d3d4Z!d5d6Z"d7d8Z#d9d:Z$fd;d<Z%e&e'd=s[%edd>d?Z(d@dAZ)dBdCZ*ddDdEZ+dFdGZ,dd0dHdIZ-dJdKZ.dLdMZ/dNdOZ0e dPdQZ1S)Rrdz5Wrap an actual or potential sys.path entry w/metadatazPKG-INFONcCsgt|p d|_|dk r0t||_||_||_||_||_|p]t|_ dS)NUnknown) rmrrn_versionr<rDrr>r _provider)rrrrrr<rDr>rrrr s     zDistribution.__init__c Ksdgd\}}}}tjj|\}} | jtkrt| j}t|} | r| jdddd\}}}}|||d|d|d|d ||jS) NrrverpyverrIrrr<rD)rrrr@_distributionImplEGG_NAMErG_reload_version) rrrrr(rrr<rDrrBrrrr s zDistribution.from_locationcCs|S)Nr)rrrrr# szDistribution._reload_versioncCs:|j|j|jt|j|jp*d|jp6dfS)Nr)parsed_versionr>r6rrr<rD)rrrrrC& s   zDistribution.hashcmpcCs t|jS)N)hashrC)rrrr__hash__1 szDistribution.__hash__cCs|j|jkS)N)rC)rrJrrr__lt__4 szDistribution.__lt__cCs|j|jkS)N)rC)rrJrrr__le__7 szDistribution.__le__cCs|j|jkS)N)rC)rrJrrr__gt__: szDistribution.__gt__cCs|j|jkS)N)rC)rrJrrr__ge__= szDistribution.__ge__cCs&t||jsdS|j|jkS)NF)rrrC)rrJrrr__eq__@ szDistribution.__eq__cCs ||k S)Nr)rrJrrr__ne__F szDistribution.__ne__c Cs>y |jSWn,tk r9|jj|_}|SYnXdS)N)_keyrrr@)rr6rrrr6M s   zDistribution.keycCs(t|ds!t|j|_|jS)N_parsed_version)rr!rr)rrrrrU szDistribution.parsed_versioncCsytjj}t|j|}|s(dS|js5dStjdjjdd}t j |j t |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. rr)rrrrrrTrUr@rrlrmrvarsr)rLV is_legacyrZrrr_warn_legacy_version\ s  z!Distribution._warn_legacy_versionc Csvy |jSWndtk rq|j}|dkri|j|j}dj|j|}t|||SYnXdS)Nz4Missing 'Version:' header and/or {} file at path: {})rr _get_version_get_metadata_path_for_displayPKG_INFOrrH)rrrrprrrrv s    zDistribution.versionc Cs?y |jSWn*tk r7|j|j|_YnX|jS)z~ A map of extra to its list of (direct) requirements for this distribution, including the null extra. )_Distribution__dep_mapr_filter_extras_build_dep_map)rrrr_dep_map s   zDistribution._dep_mapcCsxttd|D]}|}|j|}|jd\}}}|oet|pet| }|rtg}t|pd}|j|gj|qW|S)z Given a mapping of extras to dependencies, strip off environment markers and filter out any dependencies not matching the markers. Nr~) r rrrrurvrsrr)dmr3 new_extrarrr4 fails_markerrrrr s  zDistribution._filter_extrascCs`i}xSdD]K}xBt|j|D]+\}}|j|gjt|q)Wq W|S)N requires.txt depends.txt)rr)rr _get_metadatarrrl)rrrr3rrrrr s  "'zDistribution._build_dep_mapc Cs|j}g}|j|jdfxT|D]L}y|j|t|Wq/tk rztd||fYq/Xq/W|S)z@List of Requirements needed for this distro if `extras` are usedNz%s has no such extra feature %r)rrrrsrrj)rrrdepsrrrrr s   zDistribution.requiresc Cs3y|jj|}Wntk r.dSYnX|S)zK Return the path to the given metadata file, if available. z[could not detect])rrr^)rrrrrrr s   z+Distribution._get_metadata_path_for_displayccs2|j|r.x|j|D] }|VqWdS)N)rr)rrrArrrr szDistribution._get_metadatacCs"|j|j}t|}|S)N)rrr)rrrrrrr s zDistribution._get_versionFcCs{|dkrtj}|j|d||tjkrwt|jx0|jdD]}|tjkrTt|qTWdS)z>Ensure distribution is importable on `path` (default=sys.path)Nrznamespace_packages.txt)rCrrrrrrrZ)rrrpkgrrractivate s   zDistribution.activatecCsLdt|jt|j|jp'tf}|jrH|d|j7}|S)z@Return what this distribution's standard .egg filename should bez %s-%s-py%sr{)rtrrr<rOrD)rrtrrrr s  zDistribution.egg_namecCs(|jrd||jfSt|SdS)Nz%s (%s))rr)rrrrr s zDistribution.__repr__c CsNyt|dd}Wntk r0d}YnX|p:d}d|j|fS)Nrz[unknown version]z%s %s)rrHr)rrrrrr s    zDistribution.__str__cCs+|jdrt|t|j|S)zADelegate all unrecognized public attributes to .metadata providerr)rrrr)rrrrr __getattr__ s zDistribution.__getattr__cs?tttt|jtdd|jjDBS)Ncss$|]}|jds|VqdS)rN)r)rrrrrr sz'Distribution.__dir__..)r rsuperrd__dir__r)r)rrrr szDistribution.__dir__rcKs(|jt|tjj|||S)N)rr#rrr)rrtrr(rrrr szDistribution.from_filenamecCsTt|jtjjr1d|j|jf}nd|j|jf}tj|S)z?Return a ``Requirement`` that matches this distribution exactlyz%s==%sz%s===%s)rrrrrrrer)rspecrrrr# szDistribution.as_requirementcCsA|j||}|dkr7td||ff|jS)z=Return the `name` entry point of `group` or raise ImportErrorNzEntry point %r not found)rRrr)rrGrrrrrrP s zDistribution.load_entry_pointc Csdy |j}Wn4tk rCtj|jd|}|_YnX|dk r`|j|iS|S)z=Return the entry point map for `group`, or the full entry mapzentry_points.txtN)_ep_maprrfrrr)rrGep_maprrrrQ& s  ! zDistribution.get_entry_mapcCs|j|j|S)z.rr)rr#rrr enumerater>ryrCcheck_version_conflictrrr[rH) rrlocrnlocbdirnpathrYrnprrrr6 sB       zDistribution.insert_oncCs|jdkrdStj|jd}t|j}x|jdD]}|tjksJ||ksJ|tkrzqJ|dkrqJt tj|dd}|rt|j |sJ|j |jrqJt d|||jfqJWdS) N setuptoolsznamespace_packages.txtz top_level.txt pkg_resourcessiterzIModule %s was already imported from %s, but %s is being added to sys.path)rrr) r6r%r&rrxrrCrrJrr issue_warning)rnsprmodnamefnrrrrz s"  z#Distribution.check_version_conflictc Cs<y |jWn*tk r7tdt|dSYnXdS)NzUnbuilt egg for FT)rrHrr)rrrrrE s    zDistribution.has_versioncKsYd}x0|jD]"}|j|t||dqW|jd|j|j|S)z@Copy this distribution, substituting in any changed keyword argsz.)r)rrrrr szDistribution.extras)2rrrrrrOryrr2rrrrCrrrrrrrr6rrrrrwrrrrrrrrrrrrrobjectrr#rPrQrRrrrErrrr)rrrd s\                        D   c@seZdZddZdS)EggInfoDistributioncCs|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. )rr)r md_versionrrrr s  z#EggInfoDistribution._reload_versionN)rrrrrrrrr s rc@s[eZdZdZdZejdZeddZ eddZ dd Z d S) DistInfoDistributionzV Wrap an actual or potential sys.path entry w/metadata, .dist-info style. METADATAz([\(,])\s*(\d.*?)\s*([,\)])c CsXy |jSWnFtk rS|j|j}tjjj||_|jSYnXdS)zParse and cache metadataN) _pkg_inforrremailparserParserparsestr)rrrrr_parsed_pkg_info s   z%DistInfoDistribution._parsed_pkg_infoc Cs:y |jSWn(tk r5|j|_|jSYnXdS)N)_DistInfoDistribution__dep_mapr_compute_dependencies)rrrrr s   zDistInfoDistribution._dep_mapcsdgi}|_gx3|jjdp1gD]}jt|q2Wfdd}t|d}|dj|xR|jjdpgD]8}t|j}tt|||||.reqs_for_extrazProvides-Extra) rrget_allrrl frozensetrsr@r )rrrrcommonr3s_extrar)rrr s$z*DistInfoDistribution._compute_dependenciesN) rrrrrr|rEQEQrrrrrrrrr s  rz.eggz .egg-infoz .dist-infoc Osod}t}y-x&tj|j|kr:|d7}qWWntk rPYnXtj|d|d|dS)Nrr)r"rCrrrHrlrm)r;r(rr-rrrr s  rc@seZdZddZdS)RequirementParseErrorcCsdj|jS)Nr)rEr;)rrrrr szRequirementParseError.__str__N)rrrrrrrrr s rc cstt|}x|D]}d|krD|d|jd}|jdr|ddj}y|t|7}Wntk rdSYnXt|VqWdS)zYield ``Requirement`` objects for each specification in `strs` `strs` must be a string, or a (possibly-nested) iterable thereof. z #N\r?)r2rqrrr@rD StopIterationre)rwrrArrrrl s    cspeZdZfddZddZddZddZd d Zd d Ze d dZ S)recsytt|j|Wn=tjjk rY}ztt|WYdd}~XnX|j|_ t |j}||j |_ |_ dd|jD|_ttt|j|_|j |j|jt|j|jrt|jndf|_t|j|_dS)z>DO NOT CALL THIS UNDOCUMENTED METHOD; use Requirement.parse()!NcSs"g|]}|j|jfqSr)rFr)rrrrrr$ s z(Requirement.__init__..)rrerrrInvalidRequirementrrr unsafe_namermr@rr6 specifierrr|rrsrurlrr4hashCmpr_Requirement__hash)rrequirement_stringrr)rrrr s%  $zRequirement.__init__cCst|to|j|jkS)N)rrer)rrJrrrr/ szRequirement.__eq__cCs ||k S)Nr)rrJrrrr5 szRequirement.__ne__cCsDt|tr.|j|jkr%dS|j}|jj|ddS)NF prereleasesT)rrdr6rrcontains)rrrrrr8 s  zRequirement.__contains__cCs|jS)N)r)rrrrrD szRequirement.__hash__cCsdt|S)NzRequirement.parse(%r))r)rrrrrG szRequirement.__repr__cCst|\}|S)N)rl)rxrrrrrJ szRequirement.parse) rrrrrrrrrrwrrr)rrre s     cCst|kr|tfS|S)zJ Ensure object appears in the mro even for old-style classes. )r)classesrrr_always_objectP s  rcCsPttjt|dt|}x"|D]}||kr.||Sq.WdS)z2Return an adapter factory for `ob` from `registry`rN)rinspectgetmrorr)registryr7rQtrrrrZ s'  rcCs)tjj|}tj|dddS)z1Ensure that the parent directory of `path` existsexist_okTN)rrrrmakedirs)rrrrrrwb sc Csqtstdt|\}}|rm|rmt| rmt|yt|dWntk rlYnXdS)z/Sandbox-bypassing version of ensure_directory()z*"os.mkdir" not supported on this platform.iN)rrrr r]r FileExistsError)rrrtrrrr]h s   r]ccsd}g}xt|D]y}|jdr|jdrs|sI|rT||fV|ddj}g}qtd|q|j|qW||fVdS)asSplit a string or iterable thereof into (section, content) pairs Each ``section`` is a stripped version of the section header ("[section]") and each ``content`` is a list of stripped lines excluding blank lines and comment-only lines. If there are any such lines before the first section header, they're returned in a first ``section`` of ``None``. N[]rzInvalid section headingr )rqrrr@rHr)rxsectioncontentrArrrrru s   c Os7tj}ztt_tj||SWd|t_XdS)N)rr os_opentempfilemkstemp)r;r(old_openrrrr s   rrLcategoryrcOs||||S)Nr)rr;rrrr _call_aside s r cs=t|d<|jfddtDdS)z=Set up global resource manager (deliberately not state-saved)_managerc3s3|])}|jds|t|fVqdS)rN)rr)rr)rrrr sz_initialize..N)rcr#r)r-r)rr _initialize s   rcCstj}tdd||j}|j}|j}|j}|}tdd|D|ddddg|_t t |j t j tjtd S) aE Prepare the master working set and make the ``require()`` API available. This function has explicit effects on the global state of pkg_resources. It is intended to be invoked once at the initialization of this module. Invocation by other packages is unsupported and done at their own risk. rr[css!|]}|jddVqdS)rFN)r)rrrrrr sz1_initialize_master_working_set..cSs|jddS)NrT)r)rrrrr< sz0_initialize_master_working_set..r/FN)rbrr)rLrSr0rMr|rr rrrCrr"r#r)r[rLrSr\rMrrrr_initialize_master_working_set s         rc@seZdZdZdS)rz Base class for warning about deprecations in ``pkg_resources`` This class is not derived from ``DeprecationWarning``, and as such is visible by default. N)rrrrrrrrr s )r __future__rrCrrrr|rQrrrlrhrpkgutilrFrDrr email.parserrr9rrTrrrrrrfrimpr NameErrorr8 pip._vendorrpip._vendor.six.movesrrrrr r r rr ros.pathr rimportlib.machinery machineryrrrrrrrr __metaclass__ version_info RuntimeErrorrr6r7rLr[r\resources_streamr_ resource_dirrUr^rYrTrSrWrVrXr rIrJRuntimeWarningrr!r$r)r/r1r4r8r9r: _sget_none _sset_nonerK__all__r^rgrhrrirjrrrOryrzr{r|r}rrNrFrr@rrArrorprMrrOrPrQrRr~rrbr%rrarrkrcr`rmrnrsrtrurvrrrrrrrrrrrrrrrr]rrr!r*r"r/r%r-rBr. ImpImporterrrHrrXrUrZrrlrmrxrpr#rr$rSrqrBrzVERBOSE IGNORECASErrfrrrdrrrrrHrrlrrerrrwr]rrrfilterwarningsr r"rrWarningrrrrrs                                     +                                  .         *          " "          3   7      '