def add_distribution(self, dist, dist_name=None):
    """Add a :class:`pkg_resources.Distribution` from its handle.

    :param dist: The distribution to add to this environment.
    :keyword dist_name: (optional) The name of the distribution e.g. 'Flask-0.10.0'.  By default
      this will be inferred from the distribution itself should it be formatted in a standard way.
    :type dist: :class:`pkg_resources.Distribution`
    """
    self._ensure_unfrozen('Adding a distribution')
    dist_name = dist_name or os.path.basename(dist.location)
    self._distributions.add(dist)

    if os.path.isdir(dist.location):
      dist_hash = self._add_dist_dir(dist.location, dist_name)
    else:
      dist_hash = self._add_dist_zip(dist.location, dist_name)

    # add dependency key so that it can rapidly be retrieved from cache
    self._pex_info.add_distribution(dist_name, dist_hash)
Add a :class:`pkg_resources.Distribution` from its handle.

    :param dist: The distribution to add to this environment.
    :keyword dist_name: (optional) The name of the distribution e.g. 'Flask-0.10.0'.  By default
      this will be inferred from the distribution itself should it be formatted in a standard way.
    :type dist: :class:`pkg_resources.Distribution`