o ƚRe@s0ddlZddlmZddlZddlZddlZddlZddlZzddlZWn e y1ddl ZYnwddl Z ddl m Z ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZddlmZm Z m!Z!ddl"m#Z#m$Z$ddl%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-dd l.m/Z/m0Z0dd l1m2Z2m3Z3e4e5Z6e7d Z8e7d ej9Z:e7d Z;dZGddde?Z@Gddde@ZAGddde@ZBGddde?ZCGddde@ZDGddde@ZEGdd d e@ZFGd!d"d"e@ZGGd#d$d$e@ZHeHeFeDd%d&d'd(d)ZIeIjJZJGd*d+d+e?ZKdS)-N)BytesIO)DistlibException)urljoinurlparse urlunparse url2pathname pathname2urlqueuequoteunescape build_openerHTTPRedirectHandler text_typeRequest HTTPErrorURLError) DistributionDistributionPath make_dist)MetadataMetadataInvalidError)cached_property ensure_slashsplit_filenameget_project_dataparse_requirementparse_name_and_version ServerProxynormalize_name) get_schemeUnsupportedVersionError)Wheel is_compatiblez^(\w+)=([a-f0-9]+)z;\s*charset\s*=\s*(.*)\s*$ztext/html|application/x(ht)?mlzhttps://pypi.org/pypicCs:|durt}t|dd}z |W|dS|dw)z Return all distribution names known by an index. :param url: The URL of the index. :return: A list of all known distribution names. N@timeoutclose) DEFAULT_INDEXr list_packages)urlclientr,/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-3.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_vendor/distlib/locators.pyget_all_distribution_names)s  r.c@s$eZdZdZddZeZZZdS)RedirectHandlerzE A class to work around a bug in some Python 3.2.x releases. c Csd}dD] }||vr||}nq|durdSt|}|jdkr7t||}t|dr3|||n|||<t||||||S)N)locationurireplace_header)rschemer get_full_urlhasattrr3BaseRedirectHandlerhttp_error_302) selfreqfpcodemsgheadersnewurlkeyurlpartsr,r,r-r8@s"  zRedirectHandler.http_error_302N)__name__ __module__ __qualname____doc__r8http_error_301http_error_303http_error_307r,r,r,r-r/7sr/c@seZdZdZdZdZdZdZedZd)dd Z d d Z d d Z ddZ ddZ ddZee eZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd*d'd(ZdS)+LocatorzG A base class for locators - things that locate distributions. )z.tar.gzz.tar.bz2z.tarz.zipz.tgzz.tbz)z.eggz.exe.whl)z.pdfN)rJdefaultcCs,i|_||_tt|_d|_t|_dS)a^ Initialise an instance. :param scheme: Because locators look for most recent versions, they need to know the version scheme to use. This specifies the current PEP-recommended scheme - use ``'legacy'`` if you need to support existing distributions on PyPI. N) _cacher4r r/openermatcherr Queueerrors)r9r4r,r,r-__init__fs  zLocator.__init__cCsXg}|js*z |jd}||Wn |jjyYqw|j|jr|S)z8 Return any errors which have occurred. F)rPemptygetappendEmpty task_done)r9resulter,r,r- get_errorsys    zLocator.get_errorscCs |dS)z> Clear any errors which may have been logged. N)rYr9r,r,r- clear_errorss zLocator.clear_errorscCs|jdSN)rLclearrZr,r,r- clear_cacheszLocator.clear_cachecCs|jSr\_schemerZr,r,r- _get_schemeszLocator._get_schemecCs ||_dSr\r_)r9valuer,r,r- _set_schemes zLocator._set_schemecCtd)a= For a given project, get a dictionary mapping available versions to Distribution instances. This should be implemented in subclasses. If called from a locate() request, self.matcher will be set to a matcher for the requirement to satisfy, otherwise it will be None. Please implement in the subclassNotImplementedError)r9namer,r,r- _get_projects zLocator._get_projectcCrd)J Return all the distribution names known to this locator. rerfrZr,r,r-get_distribution_nameszLocator.get_distribution_namescCsP|jdur ||}|S||jvr|j|}|S|||}||j|<|S)z For a given project, get a dictionary mapping available versions to Distribution instances. This calls _get_project to do all the work, and just implements a caching layer on top. N)rLrir[)r9rhrWr,r,r- get_projects     zLocator.get_projectcCs^t|}t|j}d}|d}||j}|r!tt||j}|j dkd|j v||||fS)zu Give an url a score which can be used to choose preferred URLs for a given project release. TrJhttpszpypi.org) r posixpathbasenamepathendswithdownloadable_extensionsr#r" wheel_tagsr4netloc)r9r*trp compatibleis_wheelZis_downloadabler,r,r- score_urls   zLocator.score_urlcCsT|}|r(||}||}||kr|}||kr!td|||Std|||S)a{ Choose one of two URLs where both are candidates for distribution archives for the same version of a distribution (for example, .tar.gz vs. zip). The current implementation favours https:// URLs over http://, archives from PyPI over those from other locations, wheel compatibility (if a wheel) and then the archive name. zNot replacing %r with %rzReplacing %r with %r)ryloggerdebug)r9url1url2rWs1s2r,r,r- prefer_urls   zLocator.prefer_urlcCs t||S)zZ Attempt to split a filename in project name, version and Python version. )r)r9filename project_namer,r,r-rs zLocator.split_filenamec Csdd}d}t|\}}}}} } | drtd|| t| } | r,| \} } nd\} } |}|r@|ddkr@|dd}|d rz>t |}t ||j sWtd |n+|dur^d }n||j |}|r|j |j |jt||||| d fd dd|jDd}Wnrty}z td|WYd}~n_d}~ww||jstd|nMt|}}|jD]B}||r|dt| }|||}|std|n!|\}}}|r|||r|||t||||| d fd}|r||d<nq|r| r| |d| <|S)a See if a URL is a candidate for a download URL for a project (the URL has typically been scraped from an HTML page). If it is, a dictionary is returned with keys "name", "version", "filename" and "url"; otherwise, None is returned. cSst|t|kSr\)r)Zname1Zname2r,r,r- same_projectsz:Locator.convert_url_to_download_info..same_projectNzegg=z %s: version hint in fragment: %r)NN/rJzWheel not compatible: %sTr2z, cSs"g|] }dt|ddqS).N)joinlist).0vr,r,r- s"z8Locator.convert_url_to_download_info..)rhversionrr*python-versionzinvalid path for wheel: %szNot downloadable: %sz No match for project/version: %s)rhrrr*r %s_digest)rlower startswithrzr{ HASHER_HASHmatchgroupsrrr"r#rtrhrrrrpyver Exceptionwarningrsrorplenr)r9r*rrrWr4rurqparamsqueryfragmalgodigestZorigpathwheelincluderXrextrvrhrrr,r,r-convert_url_to_download_infos~             z$Locator.convert_url_to_download_infocCsjd}d|vr|d}dD]}||vr|||f}nq |s3dD]}d|}||vr2|||f}|Sq|S)z Get a digest from a dictionary by looking at a "digests" dictionary or keys of the form 'algo_digest'. Returns a 2-tuple (algo, digest) if found, else None. Currently looks only for SHA256, then MD5. Ndigests)sha256md5rr,)r9inforWrrr@r,r,r- _get_digest1s"  zLocator._get_digestc Cs|d}|d}||vr||}|j}n t|||jd}|j}|||_}|d}||d|<|j|dkrN||j||_|d|t  |||_ |||<dS)z Update a result dictionary (the final result from _get_project) with a dictionary for a specific version, which typically holds information gleaned from a filename or URL for an archive for the distribution. rhrr4r*rurlsN) popmetadatarr4rr source_urlr setdefaultsetaddlocator) r9rWrrhrdistmdrr*r,r,r-_update_version_dataHs    zLocator._update_version_dataFc Csrd}t|}|durtd|t|j}||j|_}td|t|j | |j }t |dkrg}|j } |D]+} | dvrBq;z|| sIn |sP| | jsU|| Wq;tyftd|| Yq;wt |dkrtt||jd}|rtd ||d } || }|r|jr|j|_|d i| t|_i} |d i} |jD] }|| vr| || |<q| |_d|_|S) a Find the most recent distribution which matches the given requirement. :param requirement: A requirement of the form 'foo (1.0)' or perhaps 'foo (>= 1.0, < 2.0, != 1.3)' :param prereleases: If ``True``, allow pre-release versions to be located. Otherwise, pre-release versions are not returned. :return: A :class:`Distribution` instance, or ``None`` if no such distribution could be located. NzNot a valid requirement: %rzmatcher: %s (%s)rrrzerror matching %s with %rr)r@zsorted list: %srrr)rrr r4rN requirementrzr{typerBrmrhrZ version_classr is_prereleaserTrrsortedr@extrasrSr download_urlsr)r9r prereleasesrWrr4rNversionsslistZvclskrdsdr*r,r,r-locate_sV             zLocator.locate)rK)F)rBrCrDrEsource_extensionsbinary_extensionsexcluded_extensionsrtrsrQrYr[r^rarcpropertyr4rirkrmryrrrrrrr,r,r,r-rIVs0   JrIc0eZdZdZfddZddZddZZS)PyPIRPCLocatorz This locator uses XML-RPC to locate distributions. It therefore cannot be used with simple mirrors (that only mirror file content). c s.tt|jdi|||_t|dd|_dS)z Initialise an instance. :param url: The URL to use for XML-RPC. :param kwargs: Passed to the superclass constructor. r$r%Nr,)superrrQbase_urlrr+r9r*kwargs __class__r,r-rQszPyPIRPCLocator.__init__cCst|jSrj)rr+r)rZr,r,r-rksz%PyPIRPCLocator.get_distribution_namesc Csiid}|j|d}|D]o}|j||}|j||}t|jd}|d|_|d|_|d|_ |dg|_ |d|_ t |}|r}|d } | d |_ || |_||_|||<|D]} | d } || } |d |t| | |d | <q_q|S) NrTrrhrlicensekeywordssummaryrr*rr)r+Zpackage_releasesZ release_urlsZ release_datarr4rhrrSrrrrrrrrrrr) r9rhrWrrrdatarrrr*rr,r,r-ris2         zPyPIRPCLocator._get_projectrBrCrDrErQrkri __classcell__r,r,rr-rs   rcr)PyPIJSONLocatorzw This locator uses PyPI's JSON interface. It's very limited in functionality and probably not worth using. c s$tt|jdi|t||_dS)Nr,)rrrQrrrrr,r-rQszPyPIJSONLocator.__init__cCrdrjzNot available from this locatorrfrZr,r,r-rkrlz&PyPIJSONLocator.get_distribution_namesc Csiid}t|jdt|}z|j|}|}t|}t |j d}|d}|d|_ |d|_ | d|_| dg|_| d |_t|}||_|d } |||j <|d D]*} | d }|j||| |j|<|d |j t||| |d |<q\|d D]N\} } | |j krqt |j d} |j | _ | | _ t| }||_||| <| D])} | d }|j||| |j|<|d | t||| |d |<qqW|Sty}z|jt|td|WYd}~|Sd}~ww)Nrz%s/jsonrrrhrrrrrr*rZreleaseszJSON fetch failed: %s) rrr rMopenreaddecodejsonloadsrr4rhrrSrrrrrrrrrrritemsrrPputrrz exception)r9rhrWr*resprrrrrrrinfosZomdodistrXr,r,r-ris^               zPyPIJSONLocator._get_projectrr,r,rr-rs  rc@s`eZdZdZedejejBejBZ edejejBZ ddZ edejZ e ddZd S) Pagez4 This class represents a scraped HTML page. z (rel\s*=\s*(?:"(?P[^"]*)"|'(?P[^']*)'|(?P[^>\s ]*))\s+)? href\s*=\s*(?:"(?P[^"]*)"|'(?P[^']*)'|(?P[^>\s ]*)) (\s+rel\s*=\s*(?:"(?P[^"]*)"|'(?P[^']*)'|(?P[^>\s ]*)))? z!]+)cCs8||_||_|_|j|j}|r|d|_dSdS)zk Initialise an instance with the Unicode page contents and the URL they came from. rN)rrr*_basesearchgroup)r9rr*rr,r,r-rQ s  z Page.__init__z[^a-z0-9$&+,/:;=?@.#%_\\|-]cCsdd}t}|j|jD]E}|d}|dp,|dp,|dp,|dp,|dp,|d }|d p8|d p8|d }t|j|}t|}|j d d|}| ||fqt |dddd}|S)z Return the URLs of all the links on a page together with information about their "rel" attribute, for determining which ones to treat as downloads and which ones to queue for further scraping. cSs,t|\}}}}}}t||t||||fS)zTidy up an URL.)rrr )r*r4rurqrrrr,r,r-clean4s zPage.links..cleanr2Zrel1Zrel2Zrel3Zrel4Zrel5Zrel6r|r}Zurl3cSsdt|dS)Nz%%%2xr)ordr)rr,r,r-BszPage.links..cSs|dS)Nrr,)rvr,r,r-rFsT)r@reverse) r_hreffinditerr groupdictrrr _clean_resubrr)r9rrWrrrelr*r,r,r-links-s$  z Page.linksN)rBrCrDrErecompileISXrrrQrrrr,r,r,r-rs rcseZdZdZejdddddZdfdd Zd d Zd d Z ddZ e de j ZddZddZddZddZddZe dZddZZS)SimpleScrapingLocatorz A locator which scrapes HTML pages to locate downloads for a distribution. This runs multiple threads to do the I/O; performance is at least as good as pip's PackageFinder, which works in an analogous fashion. cCstjt|dS)N)fileobj)gzipGzipFilerrbr,r,r-rTszSimpleScrapingLocator.cCs|Sr\r,rr,r,r-rUs)deflaternoneN c sptt|jdi|t||_||_i|_t|_t |_ t|_ d|_ ||_t|_t|_d|_dS)a Initialise an instance. :param url: The root URL to use for scraping. :param timeout: The timeout, in seconds, to be applied to requests. This defaults to ``None`` (no timeout specified). :param num_workers: The number of worker threads you want to do I/O, This defaults to 10. :param kwargs: Passed to the superclass. FNr,)rrrQrrr& _page_cacher_seenr rO _to_fetch _bad_hostsskip_externals num_workers threadingRLock_lock_gplockplatform_check)r9r*r&rrrr,r-rQXs     zSimpleScrapingLocator.__init__cCsFg|_t|jD]}tj|jd}|d||j|qdS)z Threads are created only when get_project is called, and terminate before it returns. They are there primarily to parallelise I/O (i.e. fetching web pages). )targetTN) _threadsrangerrThread_fetch setDaemonstartrT)r9irvr,r,r-_prepare_threadsss z&SimpleScrapingLocator._prepare_threadscCs6|jD]}|jdq|jD]}|qg|_dS)zu Tell all the threads to terminate (by sending a sentinel value) and wait for them to do so. N)r rrr)r9rvr,r,r- _wait_threadss    z#SimpleScrapingLocator._wait_threadsc Csiid}|jF||_||_t|jdt|}|j|j| zt d||j ||j W|n|w|`Wd|S1sQwY|S)Nrz%s/z Queueing %s)r rWrrrr rr]rrrzr{rrrr)r9rhrWr*r,r,r-ris$       z"SimpleScrapingLocator._get_projectz<\b(linux_(i\d86|x86_64|arm\w+)|win(32|_amd64)|macosx_?\d+)\bcCs |j|S)zD Does an URL refer to a platform-specific download? )platform_dependentr)r9r*r,r,r-_is_platform_dependents z,SimpleScrapingLocator._is_platform_dependentcCsp|jr ||r d}n|||j}td|||r6|j||j|Wd|S1s1wY|S)a% See if an URL is a suitable download for a project. If it is, register information in the result dictionary (for _get_project) about the specific version it's for. Note that the return value isn't actually used other than as a boolean value. Nzprocess_download: %s -> %s) r rrrrzr{rrrW)r9r*rr,r,r-_process_downloads  z'SimpleScrapingLocator._process_downloadc Cst|\}}}}}}||j|j|jrd}n>|jr%||js%d}n2||js.d}n)|dvr5d}n"|dvr %s) rrrrrrrrrrsplitrrzr{) r9linkZreferrerrr4rurq_rWhostr,r,r- _should_queues.    z#SimpleScrapingLocator._should_queuec Cs |j}zozM|rS||}|durWW|jq|jD]4\}}||jvrRz!|j|||sG||||rGt d|||j |Wqt yQYqwqWnt yn}z|j t|WYd}~nd}~wwW|jn|jw|sdSq)z Get a URL to fetch from the work queue, get the HTML page, examine its links for download candidates and candidates for further scraping. This is a handy method to run in a thread. TNzQueueing %s from %s)rrSget_pagerVrrrrr!rzr{rrrrPr)r9r*pagerrrXr,r,r-rs@          zSimpleScrapingLocator._fetchc Cst|\}}}}}}|dkrtjt|rtt|d}||jvr0|j|}t d|||S| ddd}d}||j vrHt d|||St |d d id }zzlt d ||j j||jd } t d|| } | dd} t| r| } | } | d}|r|j|}|| } d}t| }|r|d}z| |} Wnty| d} Ynwt| | }||j| <Wnity}z|jdkrtd||WYd}~nXd}~wt y }z&td|||j!|j "|Wdn1swYWYd}~n.d}~wt#y&}z td||WYd}~nd}~wwW||j|<|SW||j|<|SW||j|<|SW||j|<|S||j|<w)a Get the HTML for an URL, possibly from an in-memory cache. XXX TODO Note: this cache is never actually cleared. It's assumed that the data won't get stale over the lifetime of a locator instance (not necessarily true for the default_locator). filez index.htmlzReturning %s from cache: %srrrNzSkipping %s due to bad host %szAccept-encodingidentity)r>z Fetching %sr%z Fetched %sz Content-Typer2zContent-Encodingzutf-8zlatin-1izFetch failed: %s: %s)$rosrqisdirrrrrrzr{rrrrMrr&rrSHTML_CONTENT_TYPErgeturlrdecodersCHARSETrrr UnicodeErrorrrr<rrrrr)r9r*r4rurqrrWr r:rr> content_typeZ final_urlrencodingdecoderrrXr,r,r-r"s   * %                 zSimpleScrapingLocator.get_pagez]*>([^<]+)tj||}tddttj |dddf}| |d}|r>| |dq|j sE|Sq |S)rjr$r2Nrh) rr&r9r6r8rqrrr r5rrr4)r9rWr:r;r<r=r*rr,r,r-rkqs$  z'DirectoryLocator.get_distribution_names) rBrCrDrErQr8rirkrr,r,rr-r3Cs  r3c@s eZdZdZddZddZdS) JSONLocatora This locator uses special extended metadata (not available on PyPI) and is the basis of performant dependency resolution in distlib. Other locators require archive downloads before dependencies can be determined! As you might imagine, that can be slow. cCrdrrfrZr,r,r-rkrlz"JSONLocator.get_distribution_namescCsiid}t|}|rk|dgD]Y}|ddks|ddkr qt|d|d|d d |jd }|j}|d |_d |vrH|d rHd|d f|_|di|_|di|_|||j <|d |j t  |d q|S)Nrr<ptypesdistZ pyversionsourcerhrrzPlaceholder for summary)rr4r*rr requirementsexportsr) rrSrr4rrr dependenciesrCrrrr)r9rhrWrrrrr,r,r-ris*    zJSONLocator._get_projectN)rBrCrDrErkrir,r,r,r-r>s r>cs(eZdZdZfddZddZZS)DistPathLocatorz This locator finds installed distributions in a path. It can be useful for adding to an :class:`AggregatingLocator`. c s.tt|jdi|t|tsJ||_dS)zs Initialise an instance. :param distpath: A :class:`DistributionPath` instance to search. Nr,)rrErQ isinstancerdistpath)r9rGrrr,r-rQs zDistPathLocator.__init__cCsR|j|}|duriid}|S|j|d|jt|jgid|jtdgii}|S)Nrrr)rGget_distributionrrr)r9rhrrWr,r,r-ris  zDistPathLocator._get_project)rBrCrDrErQrirr,r,rr-rEs  rEcsReZdZdZfddZfddZddZeej j eZ dd Z d d Z Z S) AggregatingLocatorzI This class allows you to chain and/or merge a list of locators. cs.|dd|_||_tt|jdi|dS)a Initialise an instance. :param locators: The list of locators to search. :param kwargs: Passed to the superclass constructor, except for: * merge - if False (the default), the first successful search from any of the locators is returned. If True, the results from all locators are merged (this can be slow). mergeFNr,)rrJlocatorsrrIrQ)r9rKrrr,r-rQs zAggregatingLocator.__init__cs&tt||jD]}|q dSr\)rrIr^rKr9rrr,r-r^s  zAggregatingLocator.clear_cachecCs||_|jD]}||_qdSr\)r`rKr4)r9rbrr,r,r-rcs zAggregatingLocator._set_schemec Csi}|jD]o}||}|rt|jrT|di}|di}|||d}|rE|rE|D]\}} ||vr@||| O<q/| ||<q/|d} |rS| rS| |q|jdur\d} nd} |D] }|j|rld} nq`| rt|}|Sq|S)NrrTF)rKrmrJrSupdaterrNr) r9rhrWrrr<rZdfrrddfoundr,r,r-ris@           zAggregatingLocator._get_projectc Cs8t}|jD]}z||O}WqtyYqw|Sr)rrKrkrg)r9rWrr,r,r-rks  z)AggregatingLocator.get_distribution_names)rBrCrDrErQr^rcrrIr4fgetrirkrr,r,rr-rIs  ,rIzhttps://pypi.org/simple/r$r%legacyrc@sLeZdZdZdddZddZddZd d Zd d Zd dZ dddZ dS)DependencyFinderz0 Locate dependencies for distributions. NcCs|pt|_t|jj|_dS)zf Initialise an instance, using the specified locator to locate distributions. N)default_locatorrr r4rLr,r,r-rQ/s zDependencyFinder.__init__cCsrtd||j}||j|<||j||jf<|jD]}t|\}}td||||j |t  ||fqdS)z Add a distribution to the finder. This will update internal information about who provides what. :param dist: The distribution to add. zadding distribution %szAdd to provided: %s, %s, %sN) rzr{r@ dists_by_namedistsrprovidesrprovidedrrr)r9rrhprr,r,r-add_distribution7s    z!DependencyFinder.add_distributioncCsxtd||j}|j|=|j||jf=|jD]"}t|\}}td||||j|}| ||f|s9|j|=qdS)z Remove a distribution from the finder. This will update internal information about who provides what. :param dist: The distribution to remove. zremoving distribution %sz Remove from provided: %s, %s, %sN) rzr{r@rTrUrrVrrWremove)r9rrhrXrsr,r,r-remove_distributionFs    z$DependencyFinder.remove_distributioncCs@z |j|}W|Sty|d}|j|}Y|Sw)z Get a version matcher for a requirement. :param reqt: The requirement :type reqt: str :return: A version matcher (an instance of :class:`distlib.version.Matcher`). r)r4rNr!r)r9reqtrNrhr,r,r- get_matcherXs zDependencyFinder.get_matcherc Cst||}|j}t}|j}||vr8||D]!\}}z||}Wn ty,d}Ynw|r7|||Sq|S)z Find the distributions which can fulfill a requirement. :param reqt: The requirement. :type reqt: str :return: A set of distribution which can fulfill the requirement. F)r^r@rrWrr!r) r9r]rNrhrWrWrproviderrr,r,r-find_providershs"   zDependencyFinder.find_providersc Cs|j|}t}|D]}||}||js||q |r.|d||t|fd}|S|||j|=|D] }|j|t|q9| |d}|S)a Attempt to replace one provider with another. This is typically used when resolving dependencies from multiple sources, e.g. A requires (B >= 1.0) while C requires (B >= 1.1). For successful replacement, ``provider`` must meet all the requirements which ``other`` fulfills. :param provider: The provider we are trying to replace with. :param other: The provider we're trying to replace. :param problems: If False is returned, this will contain what problems prevented replacement. This is currently a tuple of the literal string 'cantreplace', ``provider``, ``other`` and the set of requirements that ``provider`` couldn't fulfill. :return: True if we can replace ``other`` with ``provider``, else False. Z cantreplaceFT) reqtsrr^rrr frozensetr\rrY) r9r_otherproblemsZrlist unmatchedr[rNrWr,r,r-try_to_replaces(       zDependencyFinder.try_to_replaceFcCsi|_i|_i|_i|_t|pg}d|vr#|d|tgdO}t|tr3|}}t d|n|j j ||d}}|durGt d|t d|d|_ t}t|g}t|g}|rH|}|j} | |jvrr||n|j| } | |kr||| ||j|jB} |j} t} |r||vrd D]}d |}||vr| t|d |O} q| | B| B}|D]}||}|st d ||j j ||d}|dur|s|j j |dd}|durt d ||d|fn.|j|j}}||f|jvr|||||| vr||vr||t d|j|D]*}|j} | |jvr2|j|t|q|j| } | |krC||| |qq|s`t|j}|D]}||v|_|jrct d|jqQt d|||fS)a Find a distribution and all distributions it depends on. :param requirement: The requirement specifying the distribution to find, or a Distribution instance. :param meta_extras: A list of meta extras such as :test:, :build: and so on. :param prereleases: If ``True``, allow pre-release versions to be returned - otherwise, don't return prereleases unless they're all that's available. Return a set of :class:`Distribution` instances and a set of problems. The distributions returned should be such that they have the :attr:`required` attribute set to ``True`` if they were from the ``requirement`` passed to ``find()``, and they have the :attr:`build_time_dependency` attribute set to ``True`` unless they are post-installation dependencies of the ``requirement``. The problems should be a tuple consisting of the string ``'unsatisfied'`` and the requirement which couldn't be satisfied by any distribution known to the locator. z:*:)z:test:z:build:z:dev:zpassed %s as requirement)rNzUnable to locate %rz located %sT)testbuilddevz:%s:z %s_requireszNo providers found for %rzCannot satisfy %rZ unsatisfiedzAdding %s to install_distsz#%s is a build-time dependency only.zfind done for %s)rWrUrTrarrZrFrrzr{rrr requestedrr@rYrfZ run_requiresZ meta_requiresZbuild_requiresgetattrr`rrZname_and_versionrvaluesZbuild_time_dependency)r9rZ meta_extrasrrrrdtodoZ install_distsrhrcZireqtsZsreqtsZereqtsr@rXZ all_reqtsr providersr_nrrXrUr,r,r-finds                        3  zDependencyFinder.findr\)NF) rBrCrDrErQrYr\r^r`rfrpr,r,r,r-rR*s (rRr\)Lriorrloggingr&rorr ImportErrorZdummy_threadingr1r2rcompatrrrrr r r r r rr7rrrrZdatabaserrrrrrutilrrrrrrrrrr r!rr"r# getLoggerrBrzrrrr+r(r(r.r/objectrIrrrrr3r>rErIrSrrRr,r,r,r-s`     @(    G0E:zA&[