def fetch_distribution(self,<EOL>requirement, tmpdir, force_scan=False, source=False, develop_ok=False,<EOL>local_index=None<EOL>):
<EOL>self.info("<STR_LIT>", requirement)<EOL>skipped = {}<EOL>dist = None<EOL>def find(req, env=None):<EOL><INDENT>if env is None:<EOL><INDENT>env = self<EOL><DEDENT>for dist in env[req.key]:<EOL><INDENT>if dist.precedence==DEVELOP_DIST and not develop_ok:<EOL><INDENT>if dist not in skipped:<EOL><INDENT>self.warn("<STR_LIT>",dist)<EOL>skipped[dist] = <NUM_LIT:1><EOL><DEDENT>continue<EOL><DEDENT>if dist in req and (dist.precedence<=SOURCE_DIST or not source):<EOL><INDENT>self.info("<STR_LIT>", dist)<EOL>return dist.clone(<EOL>location=self.download(dist.location, tmpdir)<EOL>)<EOL><DEDENT><DEDENT><DEDENT>if force_scan:<EOL><INDENT>self.prescan()<EOL>self.find_packages(requirement)<EOL>dist = find(requirement)<EOL><DEDENT>if local_index is not None:<EOL><INDENT>dist = dist or find(requirement, local_index)<EOL><DEDENT>if dist is None and self.to_scan is not None:<EOL><INDENT>self.prescan()<EOL>dist = find(requirement)<EOL><DEDENT>if dist is None and not force_scan:<EOL><INDENT>self.find_packages(requirement)<EOL>dist = find(requirement)<EOL><DEDENT>if dist is None:<EOL><INDENT>self.warn(<EOL>"<STR_LIT>",<EOL>(source and "<STR_LIT>" or "<STR_LIT>"),<EOL>requirement,<EOL>)<EOL><DEDENT>return dist<EOL>
Obtain a distribution suitable for fulfilling `requirement`

        `requirement` must be a ``pkg_resources.Requirement`` instance.
        If necessary, or if the `force_scan` flag is set, the requirement is
        searched for in the (online) package index as well as the locally
        installed packages.  If a distribution matching `requirement` is found,
        the returned distribution's ``location`` is the value you would have
        gotten from calling the ``download()`` method with the matching
        distribution's URL or filename.  If no matching distribution is found,
        ``None`` is returned.

        If the `source` flag is set, only source distributions and source
        checkout links will be considered.  Unless the `develop_ok` flag is
        set, development and system eggs (i.e., those using the ``.egg-info``
        format) will be ignored.