def best_match(<EOL>self, req, working_set, installer=None, replace_conflicting=False):
try:<EOL><INDENT>dist = working_set.find(req)<EOL><DEDENT>except VersionConflict:<EOL><INDENT>if not replace_conflicting:<EOL><INDENT>raise<EOL><DEDENT>dist = None<EOL><DEDENT>if dist is not None:<EOL><INDENT>return dist<EOL><DEDENT>for dist in self[req.key]:<EOL><INDENT>if dist in req:<EOL><INDENT>return dist<EOL><DEDENT><DEDENT>return self.obtain(req, installer)<EOL>
Find distribution best matching `req` and usable on `working_set`

        This calls the ``find(req)`` method of the `working_set` to see if a
        suitable distribution is already active.  (This may raise
        ``VersionConflict`` if an unsuitable version of the project is already
        active in the specified `working_set`.)  If a suitable distribution
        isn't active, this method returns the newest distribution in the
        environment that meets the ``Requirement`` in `req`.  If no suitable
        distribution is found, and `installer` is supplied, then the result of
        calling the environment's ``obtain(req, installer)`` method will be
        returned.