def get_latest_package(name, range_=None, paths=None, error=False):
    """Get the latest package for a given package name.

    Args:
        name (str): Package name.
        range_ (`VersionRange`): Version range to search within.
        paths (list of str, optional): paths to search for package families,
            defaults to `config.packages_path`.
        error (bool): If True, raise an error if no package is found.

    Returns:
        `Package` object, or None if no package is found.
    """
    it = iter_packages(name, range_=range_, paths=paths)
    try:
        return max(it, key=lambda x: x.version)
    except ValueError:  # empty sequence
        if error:
            # FIXME this isn't correct, since the pkg fam may exist but a pkg
            # in the range does not.
            raise PackageFamilyNotFoundError("No such package family %r" % name)
        return None
def get_latest_package ( name , range_ = None , paths = None , error = False ) : it = iter_packages ( name , range_ = range_ , paths = paths ) try : return max ( it , key = lambda x : x . version ) except ValueError : if error : raise PackageFamilyNotFoundError ( "No such package family %r" % name ) return None
Get the latest package for a given package name.

    Args:
        name (str): Package name.
        range_ (`VersionRange`): Version range to search within.
        paths (list of str, optional): paths to search for package families,
            defaults to `config.packages_path`.
        error (bool): If True, raise an error if no package is found.

    Returns:
        `Package` object, or None if no package is found.