parameters: (req_name)
return_statement: return _search_distribution(req_name)
docstring: Given a requirement name, return the installed Distribution object.
  
      This searches from *all* distributions available in the environment, to
      match the behavior of ``pkg_resources.get_distribution()``.
docstring_summary: Given a requirement name, return the installed Distribution object.
docstring_tokens: Given a requirement name return the installed Distribution object .
function: def get_distribution(req_name):
      # type: (str) -> Optional[Distribution]
      """Given a requirement name, return the installed Distribution object.
  
      This searches from *all* distributions available in the environment, to
      match the behavior of ``pkg_resources.get_distribution()``.
      """
  
      # Search the distribution by looking through the working set
      dist = _search_distribution(req_name)
  
      # If distribution could not be found, call working_set.require
      # to update the working set, and try to find the distribution
      # again.
      # This might happen for e.g. when you install a package
      # twice, once using setup.py develop and again using setup.py install.
      # Now when run pip uninstall twice, the package gets removed
      # from the working set in the first uninstall, so we have to populate
      # the working set again so that pip knows about it and the packages
      # gets picked up and is successfully uninstalled the second time too.
      if not dist:
          try:
              pkg_resources.working_set.require(req_name)
          except pkg_resources.DistributionNotFound:
              return None
      return _search_distribution(req_name)
function_tokens: def get_distribution ( req_name ) : # type: (str) -> Optional[Distribution] # Search the distribution by looking through the working set dist = _search_distribution ( req_name ) # If distribution could not be found, call working_set.require # to update the working set, and try to find the distribution # again. # This might happen for e.g. when you install a package # twice, once using setup.py develop and again using setup.py install. # Now when run pip uninstall twice, the package gets removed # from the working set in the first uninstall, so we have to populate # the working set again so that pip knows about it and the packages # gets picked up and is successfully uninstalled the second time too. if not dist : try : pkg_resources . working_set . require ( req_name ) except pkg_resources . DistributionNotFound : return None return _search_distribution ( req_name )