Detect Odoo version from an addons directory

def _get_odoo_version_info(addons_dir, odoo_version_override=None):
    """ Detect Odoo version from an addons directory """
    odoo_version_info = None
    addons = os.listdir(addons_dir)
    for addon in addons:
        addon_dir = os.path.join(addons_dir, addon)
        if is_installable_addon(addon_dir):
            manifest = read_manifest(addon_dir)
            _, _, addon_odoo_version_info = _get_version(
                addon_dir, manifest, odoo_version_override,
                git_post_version=False)
            if odoo_version_info is not None and \
                    odoo_version_info != addon_odoo_version_info:
                raise DistutilsSetupError("Not all addons are for the same "
                                          "odoo version in %s (error detected "
                                          "in %s)" % (addons_dir, addon))
            odoo_version_info = addon_odoo_version_info
    return odoo_version_info