Obtain the ``__version__`` for ``package``, looking at the egg information
    or the source repository's version control if necessary.

def getversion(package):
    """
    Obtain the ``__version__`` for ``package``, looking at the egg information
    or the source repository's version control if necessary.
    """
    distribution = get_distribution(package)
    if distribution is None:
        raise RuntimeError("Can't find distribution {0}".format(package))
    repo_type = get_repo_type(distribution.location)
    if repo_type is None:
        return distribution.version

    return repo_type.get_version(distribution.location)