code: def distribution_from_path(cls, path, name=None):
      
      # Monkeypatch pkg_resources finders should it not already be so.
      register_finders()
      if name is None:
        distributions = set(find_distributions(path))
        if len(distributions) == 1:
          return distributions.pop()
      else:
        for dist in find_distributions(path):
          if dist.project_name == name:
            return dist
docs: Return a distribution from a path.
  
      If name is provided, find the distribution.  If none is found matching the name,
      return None.  If name is not provided and there is unambiguously a single
      distribution, return that distribution otherwise None.