Y^@s dZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZyddlZWnek rFddlZYnXddlZddlmZmZm Z ddlm!Z!y&ddlm"Z"m#Z#m$Z$dZ%Wnek rd Z%YnXdd lm&Z'dd l(m)Z)m*Z*yddl+j,Z-e-j.Wnek rdZ-YnXddl/Z0ddl1Z0ddl2Z0ddl3Z0ddl4Z4d dfej5ko}d d fknre6d dZ7dZ8Gddde9Z:Gddde;Z<Gddde<e0j=j>Z?Gddde<e0j=j@ZAddZBiZCddZDddZEddZFddZGd d!ZHd"d#ZId$d%ZJd&d'ZKZLd(d)ZMd*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIddJddKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmgFZNGdndEdEeOZPGdodFdFePZQGdpdqdqeQZRGdrdGdGePZSGdsdHdHePZTiZUej=dd ZVd ZWdtZXduZYdZZdu Z[dvdiZ\dwd,Z]gdxdyZ^dzd{Z_d|d}Z`ejad~ZbejadZce`ZdddNZedd+ZfefZgdd-Zhdd.Ziddd/Zjdd0ZkGdd\d\ZlGdd]d]elZmGdd@d@e;ZnGdddeoZpGdd?d?e;ZqeqZrGddIdIe6ZsGddAdAZtdd>ZuddKZvddLZwddQZxddRZyddSZzdddTZ{GddcdcZ|e\e;e|Gddddde|Z}Gddedee}Z~e~jGddadae|ZeZGdddeoZGdddeZGddde jZGddfdfe}Ze\e jeGdd^d^eZGdd_d_e~ZGdd`d`eZeDddiddgZd dd;Zd ddZee jed ddZee;eddZd ddZeejeee-dr{ee-jeeDddieDddiddhZddZddZdd8ZdddjZddZeejeee jeee-dr% ee-jeddZee;eddVZiddZddZddZddOZejadjZejadejejBjZGddDdDe;ZddZddZGddBdBe;ZGdddeZGdddeZdededeiZddZGdddeZddJZGddCdCe0jjZddZddZddUZddZddPZddZe jdde:ddddZeeddZeddZdS)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)urllibmapfilter)utime)mkdirrenameunlinkTF)open)isdirsplitzPython 3.3 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_SetuptoolsVersionMixin.__iter__.._parse_version_partscsg}x|jD]|}|jdr|dkrax$|r`|ddkr`|jq=Wx$|r|ddkr|jqdW|j|qWt|S)Nr1z*finalr.z*final-00000000r9)lower startswithpopappendr)r3partsr4)r7rrold_parse_versions z;_SetuptoolsVersionMixin.__iter__..old_parse_versionaYou 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. stacklevelr.)recompileVERBOSEgetwarningswarnRuntimeWarningstr)rr?r4r)r7r5r6r__iter__sz _SetuptoolsVersionMixin.__iter__) rrrrrrr r!r"r#r%rIrr)rrr\s  rc@seZdZdS)SetuptoolsVersionN)rrrrrrrrJs rJc@seZdZdS)SetuptoolsLegacyVersionN)rrrrrrrrKs rKc Cs7yt|SWn"tjjk r2t|SYnXdS)N)rJ packagingversionInvalidVersionrK)vrrr parse_versionsrPcKs-tj|tjtj||dS)N)globalsupdate _state_varsdictfromkeys)vartypekwrrr_declare_statesrXcCsLi}t}x6tjD](\}}|d|||||srjc 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-%sr-r) get_build_platformmacosVersionStringmatchsysplatformjoin _macosx_versgroup ValueError)platmrrrget_supported_platforms 3 rxrequire 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_packagesrrun_mainAvailableDistributionsc@s"eZdZdZddZdS)rz.Abstract base for dependency resolution errorscCs|jjt|jS)N)rrreprri)rrrr__repr__CszResolutionError.__repr__N)rrrrrrrrrr@s c@sXeZdZdZdZeddZeddZddZd d Z d S) rz An already-installed version conflicts with the requested version. Should be initialized with the installed Distribution and the requested Requirement. z3{self.dist} is installed but {self.req} is requiredcCs |jdS)Nr)ri)rrrrdistQszVersionConflict.distcCs |jdS)Nr.)ri)rrrrreqUszVersionConflict.reqcCs|jjtS)N) _templateformatlocals)rrrrreportYszVersionConflict.reportcCs$|s |S|j|f}t|S)zt If required_by is non-empty, return a version of self that is a ContextualVersionConflict. )riContextualVersionConflict)r required_byrirrr with_context\szVersionConflict.with_contextN) rrrrrpropertyrrrrrrrrrGs  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)Nrl)ri)rrrrrosz%ContextualVersionConflict.required_byN)rrrrrrrrrrrrrgs  rc@sjeZdZdZdZeddZeddZeddZd d Z d d Z d S)rz&A requested distribution was not foundzSThe '{self.req}' distribution was not found and is required by {self.requirers_str}cCs |jdS)Nr)ri)rrrrrzszDistributionNotFound.reqcCs |jdS)Nr.)ri)rrrr requirers~szDistributionNotFound.requirerscCs|js dSdj|jS)Nzthe applicationz, )rrr)rrrr requirers_strs z"DistributionNotFound.requirers_strcCs|jjtS)N)rrr)rrrrrszDistributionNotFound.reportcCs |jS)N)r)rrrr__str__szDistributionNotFound.__str__N) rrrrrrrrrrrrrrrrts  c@seZdZdZdS)rz>Distribution doesn't have an "extra feature" of the given nameN)rrrrrrrrrs rlr.cCs|t|szIMetadataProvider.has_metadatacCsdS)z'The named metadata resource as a stringNr)rrrr get_metadataAszIMetadataProvider.get_metadatacCsdS)zYield named metadata resource as list of non-blank non-comment lines Leading and trailing whitespace is stripped from each line, and lines with ``#`` as the first non-blank character are omitted.Nr)rrrrget_metadata_linesDsz$IMetadataProvider.get_metadata_linescCsdS)z>Is the named metadata a directory? (like ``os.path.isdir()``)Nr)rrrrmetadata_isdirJsz IMetadataProvider.metadata_isdircCsdS)z?List of metadata names in the directory (like ``os.listdir()``)Nr)rrrrmetadata_listdirMsz"IMetadataProvider.metadata_listdircCsdS)z=Execute the named script in the supplied namespace dictionaryNr)r namespacerrrrzPszIMetadataProvider.run_scriptN) rrrrrrrrrzrrrrr=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_filenameWsz'IResourceProvider.get_resource_filenamecCsdS)ziReturn a readable file-like object for `resource_name` `manager` must be an ``IResourceManager``Nr)r r rrrget_resource_stream\sz%IResourceProvider.get_resource_streamcCsdS)zmReturn a string containing the contents of `resource_name` `manager` must be an ``IResourceManager``Nr)r r rrrget_resource_stringasz%IResourceProvider.get_resource_stringcCsdS)z,Does the package contain the named resource?Nr)r rrr has_resourcefszIResourceProvider.has_resourcecCsdS)z>Is the named resource a directory? (like ``os.path.isdir()``)Nr)r rrrrisz IResourceProvider.resource_isdircCsdS)z?List of resource names in the directory (like ``os.listdir()``)Nr)r rrrrlsz"IResourceProvider.resource_listdirN) rrrrr r r rrrrrrrrTs      c@seZdZdZdddZeddZeddZd d Zd d Z d dZ dddZ ddZ ddZ dddddZddddddZdddddZddZddd Zd!d"Zd#d$Zd%d&ZdS)'rzDA 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 callbacksrpr add_entry)rrentryrrr__init__ss       zWorkingSet.__init__cCsm|}yddlm}Wntk r5|SYnXy|j|Wntk rh|j|SYnX|S)z1 Prepare the master working set. r) __requires__)__main__rrryr_build_from_requirements)clswsrrrr _build_masters    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)rresolveraddrprrr)rreq_specrreqsdistsrrrrrrs   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 setdefaultrr=rr)rrrrrrrs zWorkingSet.add_entrycCs|jj|j|kS)z9True if `dist` is the active distribution for its project)rrDr$)rrrrr __contains__szWorkingSet.__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)rrDr$r)rrrrrrrs zWorkingSet.findccsdx]|D]U}|j|}|dkrGx1|jD] }|Vq5Wq||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)r~values)rrtrrreprrrrs    zWorkingSet.iter_entry_pointscCsQtjdj}|d}|j||d<|j|dj||dS)z?Locate distribution for `requires` and run `script_name` scriptr.rrN)rprrrdryrz)rrequiresrrrrrrrzs    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. r.N)rrr)rseenitemr$rrrrIs  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. r6N) insert_onrlocationrr!r$rr= _added_new)rrrinsertr6keyskeys2rrrrs   zWorkingSet.addcCst|ddd}i}i}g}t} tjt} x|r |jd} | |krjqF| j| |sqF|j| j} | dkrr|j j| j} | dks| | kre|re|} |dkr| dkrt |j }nt g}t g} |j | | |} || j<| dkre| 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).0rT)rrr sz*_ReqExtras.markers_pass..N)N)rDrUany)rrr5 extra_evalsr)rrr3s  z_ReqExtras.markers_pass)rrrrr3rrrrr/s r/c@seZdZdZdeeddZddZddZdd d Z d d Z d dZ dddZ dddZ ddZddZddZdS)rz5Searchable 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)_distmaprqpythonscan)r search_pathrqr\rrrrs   zEnvironment.__init__cCsC|jdks0|jdks0|j|jkoBt|j|jS)zIs distribution `dist` acceptable for this environment? The distribution must match the platform and python version requirements specified when this environment was created, or False is returned. N)r\ py_versionrrq)rrrrrcan_addszEnvironment.can_addcCs|j|jj|dS)z"Remove `dist` from the environmentN)r[r$remove)rrrrrra(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)rprrr)rr^r'rrrrr],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. )r:r[rD)rr7distribution_keyrrrr%;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 r$hashcmpreverseTN) r` has_versionr[r!r$r=rCoperator attrgetter)rrr rrrrFs   zEnvironment.addcCsW|j|}|dk r|Sx%||jD]}||kr-|Sq-W|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)rr$obtain)rrrr:rrrrr4Os   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 requirementr:rrrrhes zEnvironment.obtainccs-x&|jjD]}||r|VqWdS)z=Yield the unique project names of the available distributionsN)r[r,)rr$rrrrIqs 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)rrrrr)rrprojectrrrr__iadd__ws zEnvironment.__iadd__cCs@|jgdddd}x||fD]}||7}q(W|S)z4Add an environment or distribution to an environmentrqNr\)r)rrnewr9rrr__add__szEnvironment.__add__)rrrrrxPY_MAJORrr`rar]r%rr4rhrIrkrmrrrrrs      c@seZdZdZdS)raTAn error occurred extracting a resource The following attributes are available from instances of this exception: manager The resource manager that raised this exception cache_path The base directory for resource extraction original_error The exception instance that caused extraction to fail N)rrrrrrrrrs c@seZdZdZdZddZddZddZd d Zd d Z d dZ ddZ ddZ fddZ eddZddZddZdddZdS)rz'Manage resource extraction and packagesNcCs i|_dS)N) cached_files)rrrrrszResourceManager.__init__cCst|j|S)zDoes the named resource exist?)r{r)rpackage_or_requirementr rrrrszResourceManager.resource_existscCst|j|S)z,Is the named resource an existing directory?)r{r)rrpr rrrrs zResourceManager.resource_isdircCst|j||S)z4Return a true filesystem path for specified resource)r{r )rrpr rrrrs z!ResourceManager.resource_filenamecCst|j||S)z9Return a readable file-like object for specified resource)r{r )rrpr rrrrs zResourceManager.resource_streamcCst|j||S)z%Return specified resource as a string)r{r )rrpr rrrrs zResourceManager.resource_stringcCst|j|S)z1List the contents of the named resource directory)r{r)rrpr rrrrs z ResourceManager.resource_listdircCsttjd}|jpt}tjdj}t|jt }||_ ||_ ||_ |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) rpexc_infoextraction_pathrtextwrapdedentlstriprrrr  cache_pathoriginal_error)rold_excrvtmplerrrrrextraction_errors   z ResourceManager.extraction_errorc Cso|jpt}tjj||d|}yt|Wn|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.) rrrrrrr_bypass_ensure_directoryr{_warn_unsafe_extraction_pathro)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).) rrr;environstatst_modeS_IWOTHS_IWGRPrErF 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)rrrrchmod)rtempnamefilenamerrrr 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)rorurr)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)rforcerrrrCsz!ResourceManager.cleanup_resources)rrrrrrrrrrrrrr{r staticmethodr}rrrrrrrrs           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)rrrDappdirsuser_cache_dirrrrrrQscCstjdd|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.]+r))rAsub)rrrrr]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)rHrLrMVersionrNr6rAr)rMrrrres 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)rArr:)rTrrrrqscCs|jddS)z|Convert a project or version name to its filename-escaped form Any '-' characters are currently replaced with '_'. r)r)r6)rrrrrzscCsPyt|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)r SyntaxErrorrlineno)texterrrrs  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)rLmarkersMarkerrV InvalidMarkerr)rrTrUrrrrrs c@seZdZdZdZdZdZddZddZddZ d d Z d d Z d dZ ddZ ddZddZddZddZddZddZddZdd Zd!d"Zd#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)rrrrrrszNullProvider.__init__cCs|j|j|S)N)_fnr)rr r rrrr sz"NullProvider.get_resource_filenamecCstj|j||S)N)ioBytesIOr )rr r rrrr sz NullProvider.get_resource_streamcCs|j|j|j|S)N)_getrr)rr r rrrr sz NullProvider.get_resource_stringcCs|j|j|j|S)N)_hasrr)rr rrrrszNullProvider.has_resourcecCs%|jo$|j|j|j|S)N)egg_inforr)rrrrrrszNullProvider.has_metadatacCsE|js dS|j|j|j|}tjrA|jdS|S)Nrzutf-8)rrrrPY3decode)rrvaluerrrrs zNullProvider.get_metadatacCst|j|S)N)rr)rrrrrrszNullProvider.get_metadata_linescCs|j|j|j|S)N)_isdirrr)rr rrrrszNullProvider.resource_isdircCs%|jo$|j|j|j|S)N)rrr)rrrrrrszNullProvider.metadata_isdircCs|j|j|j|S)N)_listdirrr)rr rrrrszNullProvider.resource_listdircCs)|jr%|j|j|j|SgS)N)rrr)rrrrrrs zNullProvider.metadata_listdirc Csd|}|j|s)td||j|jdd}|jdd}|j|j|}||dcCsdS)Nrr)rrrrrrj:scCsgS)Nr)rrrrrrj;sNcCsdS)Nr)rrrrr>szEmptyProvider.__init__) rrrrrrrrrrrrrrr6s   c@s.eZdZdZeddZeZdS) ZipManifestsz zip manifest builder c sCt|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)r6rsepgetinfo)rWr)zfilerrrXUsz%ZipManifests.build..N)ContextualZipFilenamelistrT)rrrZr)rrbuildJs zZipManifests.buildN)rrrrrSrloadrrrrrEs 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. ) rrnormpathrst_mtimemtimerrmanifest)rrrrrrrrfs zMemoizedZipManifests.loadN)rrrrr0 namedtuplerrrrrrr`s rcs@eZdZdZddZddZfddZS)rzL Supplement ZipFile class to support context manager for Python 2.6 cCs|S)Nr)rrrr __enter__yszContextualZipFile.__enter__cCs|jdS)N)close)rrr tracebackrrr__exit__|szContextualZipFile.__exit__cs8ttjdr"tj||Stt|j|S)zI Construct a ZipFile or ContextualZipFile as appropriate r)rzipfileZipFilerr__new__)rrikwargs)rrrrszContextualZipFile.__new__)rrrrrrrrr)rrrts   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__cCsF|j|jr)|t|jdStd||jfdS)Nz%s is not a subpath of %s)r;rrAssertionError)rfspathrrr _zipinfo_nameszZipProvider._zipinfo_namecCsj|j|}|j|jtjrM|t|jddjtjStd||jfdS)Nr.z%s is not a subpath of %s)rr;rrrrr r)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_resourcesrrr_extract_resource _eager_to_zip)rr r reagersrrrrr s    z!ZipProvider.get_resource_filenamecCs/|j}|jd}tj|}||fS)Nrr.r9)rrr9) 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 .$extractdirr)_indexrrrrrrrr WRITE_SUPPORTIOErrorrrr _is_current_mkstempwriterrrrrr errorisfilerr r{) rr rrlastrr real_pathoutftmpnamrrrrs@ $    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) rrrrrrst_sizerrrr r) r file_pathrrrr zip_contentsf file_contentsrrrrszZipProvider._is_currentcCs[|jdkrTg}x3dD]+}|j|r|j|j|qW||_|jS)Nnative_libs.txteager_resources.txt)r r)rrr6r)rrrrrrrs  z ZipProvider._get_eager_resourcesc Csy |jSWntk ri}x|jD]y}|jtj}x^|rtjj|dd}||kr||j|dPqF|jg||parentrrrr s     zZipProvider._indexcCs.|j|}||jkp-||jkS)N)rrr)rrrrrrrszZipProvider._hascCs|j||jkS)N)rr)rrrrrr!szZipProvider._isdircCs%t|jj|j|fS)N)r.rrDr)rrrrrr$szZipProvider._listdircCs|j|j|j|S)N)rrr)rr rrrr'szZipProvider._eager_to_zipcCs|j|j|j|S)N)rrr)rr rrrr*szZipProvider._resource_to_zip)rrrrrrrrrrrrr rrrrrrrrrrrrrrrrs$      4      c@sReZdZdZddZddZddZdd Zd d Zd S) ra*Metadata handler for standalone PKG-INFO files Usage:: metadata = FileMetadata("/path/to/PKG-INFO") This provider rejects all data and metadata requests except for PKG-INFO, which is treated as existing, and will be the contents of the file at the provided location. cCs ||_dS)N)r)rrrrrr=szFileMetadata.__init__cCs|dkotjj|jS)NzPKG-INFO)rrr)rrrrrr@szFileMetadata.has_metadatac Cs]|dkrtdtj|jdddd}|j}WdQRX|j||S)NzPKG-INFOz(No metadata except PKG-INFO is availableencodingzutf-8errorsr6)rrr rr_warn_on_replacement)rrr metadatarrrrCs   ! zFileMetadata.get_metadatacCsDdjd}||kr@d}|jt}tj|dS)Ns�zutf-8z2{self.path} could not be properly decoded in UTF-8)rrrrErF)rrreplacement_charryrrrrrLs  z!FileMetadata._warn_on_replacementcCst|j|S)N)rr)rrrrrrTszFileMetadata.get_metadata_linesN) rrrrrrrrrrrrrr1s    c@s"eZdZdZddZdS)rasMetadata provider for egg directories Usage:: # Development eggs: egg_info = "/path/to/PackageName.egg-info" base_dir = os.path.dirname(egg_info) metadata = PathMetadata(base_dir, egg_info) dist_name = os.path.splitext(os.path.basename(egg_info))[0] dist = Distribution(basedir, project_name=dist_name, metadata=metadata) # Unpacked egg directories: egg_path = "/path/to/PackageName-ver-pyver-etc.egg" metadata = PathMetadata(egg_path, os.path.join(egg_path,'EGG-INFO')) dist = Distribution.from_filename(egg_path, metadata=metadata) cCs||_||_dS)N)rr)rrrrrrrls zPathMetadata.__init__N)rrrrrrrrrrXs c@s"eZdZdZddZdS)rz Metadata provider for .egg filescCs`|jtj|_||_|jrFtjj|j|j|_n |j|_|j dS)z-Create a metadata provider from a zipimporterN) rrrrrprefixrrrrr)rimporterrrrrts   ! zEggMetadata.__init__N)rrrrrrrrrrqs rT_distribution_finderscCs|t|>> 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)rLrMr)rWr4rrr s z?_by_version_descending.._by_version..)rrsplitext itertoolschainr )rextr>rrr _by_versionsz+_by_version_descending.._by_versionr$rdT)sorted)rr.rrr_by_version_descendings r0c cs.t|}tjj|r*tj|tjr*t|rntj|dt |tjj |dVnt tj |}x|D]}|j }|jds|jdr:tjj ||}tjj|rttj |dkrqt ||}n t|}tj|||dtVq| rt|rttjj ||}x|D] } | VqoWq| r|jdrttjj ||} | j} WdQRXx[| D]S} | jsqtjj || j} t| }x|D] }|VqWPqWqWdS) z6Yield distributions accessible on a sys.path directoryrzEGG-INFOz .egg-infoz .dist-infor precedencez .egg-linkN)_normalize_cachedrrr accessR_OKrrr!rrrr0rr:r rrr%rrr readlinesstriprstrip)rrrpath_item_entriesrr:fullpathrr r entry_file entry_lineslinerr'rrr find_on_pathsB '             r= FileFinder_namespace_handlers_namespace_packagescCs|t|.c s4yj|SWntk r/tdSYnXdS)z/ Workaround for #520 and #513. infN)indexrufloat)r)sys_pathrrsafe_sys_path_index=s 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-r.N)r rrcountr2rr)r path_parts module_partsr>) package_namerQrrposition_in_sys_pathFsz/_rebuild_mod_path..position_in_sys_pathNr$cSsg|]}t|qSr)r2)rWrLrrrr)Ts )rprrr.rCrB) orig_pathrUrrVr)rUrQrPrrH6s  rHcCs tjz|tkrdStjd}}d|krdj|jddd}t||tkr{t|ytj |j }Wn!t k rt d|YnXtj |gj|tj |gx|D]}t||qWWdtjXdS)z9Declare that package 'packageName' is a namespace packageNr-r.zNot a package:r9)_imp acquire_lockr@rprrrr rrrrBrrr!r=rK release_lock)rIrrrrrrrWs&   "     c Cs_tjzCx<tj|fD](}t||}|r t||q WWdtjXdS)zDEnsure that previously-declared namespace packages include path_itemN)rXrYr@rDrKrrZ)rrpackager'rrrrxs cCs]tjj||jdd}t|}x(|jD]}t||kr8Pq8W|SdS)zBCompute an ns-package subpath for a filesystem or zipfile importerr-r.Nr9)rrrrr r2rB)rrrIrr' normalizedr'rrrfile_ns_handlers " r]cCsdS)Nr)rrrIrrrrnull_ns_handlersr^cCstjjtjj|S)z1Normalize a file/dir name for comparison purposes)rrnormcaserealpath)rrrrrsc Cs=y ||SWn*tk r8t|||<}|SYnXdS)N)rr)rrresultrrrr2s   r2cCs|jjdS)z@ Determine if given path appears to be an unpacked egg. z.egg)r:r )rrrrrsrcCsR|jd}|j}|rNdj|}ttj||tj|dS)Nr-)r r<rrsetattrrpr)rIr>rrrrrrFs  rFccst|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 splitlinesr6r;r)strsr3ssrrrrs   z \w+(\.\w+)*$z (?P[^-]+) ( -(?P[^-]+) ( -py(?P[^-]+) ( -(?P.+) )? )? )? c@seZdZdZffdddZddZddZd d d Zd d ZddddZ e j dZ e dddZe ddZe dddZe dddZdS)rz3Object representing an advertised importable objectNcCskt|std|||_||_t||_tjddj|j |_ ||_ dS)NzInvalid module namezx[%s],) MODULErur module_namerattrsrrrrr5r)rrrirjr5rrrrrs   "zEntryPoint.__init__cCs`d|j|jf}|jr9|ddj|j7}|jr\|ddj|j7}|S)Nz%s = %s:r-z [%s]rg)rrirjrrr5)rr3rrrrs   zEntryPoint.__str__cCsdt|S)NzEntryPoint.parse(%r))rH)rrrrrszEntryPoint.__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.r@rl)rErFDeprecationWarningryr)rryrirrrrrszEntryPoint.loadcCsvt|jddgdd}ytjt|j|SWn7tk rq}ztt|WYdd}~XnXdS)zD Resolve the entry point from its module and attrs. fromlistrlevelrN) rri functoolsreducerrjrrrH)rrexcrrrr s zEntryPoint.resolvecCso|jr"|j r"td||jj|j}tj|||d|j}tttj|dS)Nz&Can't require() without a distributionr5) r5rrr%rrr.rr)rr9r:rrZrrrry 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]' formatr5attrr-rr)patternroru groupdict _parse_extrasr )rsrcrrwrresr5rjrrrr s  #zEntryPoint.parsecCs6|s fStjd|}|jr/t|jS)Nx)rrspecsrur5)r extras_specrrrrru4 s   zEntryPoint._parse_extrascCst|std|i}xWt|D]I}|j||}|j|krjtd||j|||j.rrkN)rnextiter partitionrr6)r{is_version_line version_linesr<rrrrr_version_from_fileg s  rc @seZdZdZdZddddededdZedddZ dd Z e d d Z d d Z ddZddZddZddZddZddZe ddZe ddZddZe d d!Ze d"d#Zfd$d%Zd&d'Zdd(d)d*Zd+d,Zd-d.Zd/d0Zd1d2Zedd3d4Z d5d6Z!d7d8Z"dd9d:Z#d;d<Z$dd(d=d>Z%d?d@Z&dAdBZ'dCdDZ(e dEdFZ)dS)Grz5Wrap an actual or potential sys.path entry w/metadatazPKG-INFONcCsgt|p d|_|dk r0t||_||_||_||_||_|p]t|_ dS)NUnknown) rr7r_versionr_rqr)r1r _provider)rr)rr7rMr_rqr1rrrrw s     zDistribution.__init__c Ksdgd\}}}}tjj|\}} | jtkrt| j}t|} | r| jdddd\}}}}|||d|d|d|d ||jS) Nrrverpyverrvr7rMr_rq)rrr*r:_distributionImplEGG_NAMErt_reload_version) rr)rrrWr7rMr_rqr-rorrrr% s zDistribution.from_locationcCs|S)Nr)rrrrr szDistribution._reload_versioncCs:|j|j|jt|j|jp*d|jp6dfS)Nr)parsed_versionr1r$rr)r_rq)rrrrrc s   zDistribution.hashcmpcCs t|jS)N)hashrc)rrrrr szDistribution.__hash__cCs|j|jkS)N)rc)rrrrrr szDistribution.__lt__cCs|j|jkS)N)rc)rrrrrr szDistribution.__le__cCs|j|jkS)N)rc)rrrrrr" szDistribution.__gt__cCs|j|jkS)N)rc)rrrrrr! szDistribution.__ge__cCs&t||jsdS|j|jkS)NF)rrrc)rrrrrr szDistribution.__eq__cCs ||k S)Nr)rrrrrr# szDistribution.__ne__c Cs>y |jSWn,tk r9|jj|_}|SYnXdS)N)_keyrr7r:)rr$rrrr$ s   zDistribution.keycCs(t|ds!t|j|_|jS)N_parsed_version)rrPrMr)rrrrr 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)rLrM LegacyVersionrrrsrtr6r6rErFrvarsr)rLV is_legacyryrrr_warn_legacy_version s  z!Distribution._warn_legacy_versionc Cshy |jSWnVtk rct|j|j}|dkr[d}t||j||SYnXdS)Nz(Missing 'Version:' header and/or %s file)rrr _get_metadataPKG_INFOru)rrMryrrrrM s   zDistribution.versionc Csy |jSWntk rdgi}|_xdD]}xt|j|D]\}}|rd|kr|jdd\}}t|rg}nt|sg}t|pd}|j|gj t |qQWq5W|SYnXdS)N requires.txt depends.txtrkr.)rr) _Distribution__dep_maprrrr rrrr!r6r)rdmrrTrrUrrr_dep_map s    "    'zDistribution._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)rr6rDrrr)rr5rdepsr-rrrr% s   zDistribution.requiresccs2|j|r.x|j|D] }|VqWdS)N)rr)rrr<rrrr szDistribution._get_metadataFcCs{|dkrtj}|j|d||tjkrwt|jx0|jdD]}|tjkrTt|qTWdS)z>Ensure distribution is importable on `path` (default=sys.path)Nr6znamespace_packages.txt)rprr(rr)rrr)rrr6pkgrrractivate 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))rr7rMr_rnrq)rrrrrr$ s  zDistribution.egg_namecCs(|jrd||jfSt|SdS)Nz%s (%s))r)rH)rrrrr/ s zDistribution.__repr__c CsNyt|dd}Wntk r0d}YnX|p:d}d|j|fS)NrMz[unknown version]z%s %s)rrur7)rrMrrrr5 s    zDistribution.__str__cCs+|jdrt|t|j|S)zADelegate all unrecognized public attributes to .metadata providerr)r;rrr)rrrrrr __getattr__= s zDistribution.__getattr__cKs(|jt|tjj|||S)N)r%r2rrr)rrrrWrrrr!C szDistribution.from_filenamecCsTt|jtjjr1d|j|jf}nd|j|jf}tj|S)z?Return a ``Requirement`` that matches this distribution exactlyz%s==%sz%s===%s)rrrLrMrr7rr)rspecrrrrDJ szDistribution.as_requirementcCsA|j||}|dkr7td||ff|jS)z=Return the `name` entry point of `group` or raise ImportErrorNzEntry point %r not found)rrr)rrtrr$rrrr}S 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_maprrrrrD)rrtep_maprrrr~Z s  ! zDistribution.get_entry_mapcCs|j|j|S)z.rr.)r)r2rrr enumerater1rrpcheck_version_conflictr+r=rNru) rrlocr6nlocbdirnpathrLr'nprrrr(j 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)z pkg_resourcesz setuptoolszsite) r$rTrUrrr)rprr@rr; issue_warning)rnsprmodnamefnrrrr s"  z#Distribution.check_version_conflictc Cs<y |jWn*tk r7tdt|dSYnXdS)NzUnbuilt egg for FT)rMrurr)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)rrrrr5 szDistribution.extras)*rrrrrrnrrrSr%rrrcrrrr"r!r r#r$rrrMrr%rrrrrrr!rDr}r~rr(rrerr5rrrrrs sN                    C   c@seZdZddZdS)EggInfoDistributioncCs+t|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. )rrrr)r md_versionrrrr s  z#EggInfoDistribution._reload_versionN)rrrrrrrrr s rc@s[eZdZdZdZejdZeddZ eddZ dd Z d S) DistInfoDistributionzGWrap an actual or potential sys.path entry w/metadata, .dist-info styleMETADATAz([\(,])\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_allr6r frozensetrr6r.)rrrrcommonrTs_extrar)rrr s$z*DistInfoDistribution._compute_dependenciesN) rrrrrrArBEQEQrrrrrrrrr s  rz.eggz .egg-infoz .dist-infoc Osod}t}y-x&tj|j|kr:|d7}qWWntk rPYnXtj|d|d|dS)Nr.r@)rQrprrrurErF)rirWrnr\rrrr! s  rc@seZdZddZdS)RequirementParseErrorcCsdj|jS)Nr)rrri)rrrrr/ szRequirementParseError.__str__N)rrrrrrrrr. s rccstt|}xs|D]k}d|krD|d|jd}|jdry|ddj}|t|7}t|VqWdS)zYield ``Requirement`` objects for each specification in `strs` `strs` must be a string, or a (possibly-nested) iterable thereof. z #N\rl)rrrr r6rr)rer{r<rrrr3 s  cspeZdZfddZddZddZddZd d Zd d Ze d dZ S)rcsytt|j|Wn=tjjk rY}ztt|WYdd}~XnX|j|_ t |j}||j |_ |_ dd|jD|_ttt|j|_|j |jt|j|jrt|jndf|_t|j|_dS)z>DO NOT CALL THIS UNDOCUMENTED METHOD; use Requirement.parse()!NcSs"g|]}|j|jfqSr)rfrM)rWrrrrr)Q s z(Requirement.__init__..)rrrrLr8InvalidRequirementrrHr unsafe_namerr:r7r$ specifierryrrrr5rrUhashCmpr_Requirement__hash)rrequirement_stringrr7)rrrrG s%  $zRequirement.__init__cCst|to|j|jkS)N)rrr)rrrrrr [ szRequirement.__eq__cCs ||k S)Nr)rrrrrr#a szRequirement.__ne__cCsDt|tr.|j|jkr%dS|j}|jj|ddS)NF prereleasesT)rrr$rMrcontains)rr'rrrr"d s  zRequirement.__contains__cCs|jS)N)r)rrrrrp szRequirement.__hash__cCsdt|S)NzRequirement.parse(%r))rH)rrrrrs szRequirement.__repr__cCst|\}|S)N)r)r3rrrrru szRequirement.parse) rrrrr r#r"rrrrrr)rrrF s     cCs@t|ts9Gddd|t}|jddS|jS)z&Get an mro for a type or classic classc@seZdZdS)z_get_mro..clsN)rrrrrrrr s rr.N)rrobject__mro__)rrrr_get_mro{ srcCsAx:tt|dt|D]}||kr||SqWdS)z2Return an adapter factory for `ob` from `registry`rN)rrr)registryretrrrr s% rcCs5tjj|}tjj|s1tj|dS)z1Ensure that the parent directory of `path` existsN)rrrr makedirs)rrrrrr scCsXtstdt|\}}|rT|rTt| rTt|t|ddS)z/Sandbox-bypassing version of ensure_directory()z*"os.mkdir" not supported on this platform.iN)rrr r r|r)rrrrrrr| 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[]r.zInvalid section headingr9)rr;r r6rur=)r3sectioncontentr<rrrr s   c Os7tj}ztt_tj||SWd|t_XdS)N)rr os_opentempfilemkstemp)rirWold_openrrrr s   rignorecategoryr=cOs||||S)Nr)r rirrrr _call_aside s rcs=t|d<|jfddtDdS)z=Set up global resource manager (deliberately not state-saved)_managerc3s3|])}|jds|t|fVqdS)rN)r;r)rWr)r rrrX sz_initialize..N)rrRr)r\r)r r _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. rrcss!|]}|jddVqdS)r6FN)r)rWrrrrrX sz1_initialize_master_working_set..cSs|jddS)Nr6T)r)rrrrrj sz0_initialize_master_working_set..rPFN)rrrXryrrQrzrrr.rrrprrQrRr)rryrrrzrrrr_initialize_master_working_set s        r)r __future__rrprrrrArDrr#rErropkgutilrfrqr0r email.parserrrrsr+rrXrimprZ six.movesrrrrrr r rr ros.pathr r importlib.machinery machineryrrZpackaging.versionrLZpackaging.specifiersZpackaging.requirementsZpackaging.markersr version_info RuntimeErrorryrrGrrrrMrrJrrKrPrSrXr^r`rcrfrgrh _sget_none _sset_nonerx__all__ Exceptionrrrrrrrnrrrrrrr{rsrrmrBrnrrrrzrr|r}r~rrrrrTr/rrrrrrrrrrrrrrrrrrrrrrr$rrrrrr"r(r0r= ImpImporterrr>rrKrHrrr]r^rr2rrFrrorhrC IGNORECASErrrrrrrrrrurrr8rrrrr|rrfilterwarningsrrQrrrrrrs                                 + b                                .      a   '   .   ! !        f0   5