From 4ca2fda236051ccb07ff70a8468bea2639baae75 Mon Sep 17 00:00:00 2001 From: Casey Clements Date: Wed, 2 Nov 2016 16:48:59 -0400 Subject: [PATCH] Update to ensure_valid_license_family so that existing recipes don't break --- conda_build/license_family.py | 14 ++++++++++++++ conda_build/metadata.py | 15 +-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/conda_build/license_family.py b/conda_build/license_family.py index d68398d124..cdd5251c11 100644 --- a/conda_build/license_family.py +++ b/conda_build/license_family.py @@ -3,6 +3,8 @@ from difflib import get_close_matches import re import string +from conda_build import exceptions +from conda_build.utils import comma_join allowed_license_families = """ AGPL @@ -94,6 +96,18 @@ def guess_license_family(license_name=None, return 'OTHER' +def ensure_valid_license_family(meta): + try: + license_family = meta['about']['license_family'] + except KeyError: + return + if (remove_special_characters(normalize(license_family)) + not in allowed_license_families): + raise RuntimeError(exceptions.indent( + "about/license_family '%s' not allowed. Allowed families are %s." % + (license_family, comma_join(sorted(allowed_license_families))))) + + def deprecated_guess_license_family(license_name, recognized=allowed_license_families): """Deprecated guess of license_family from license diff --git a/conda_build/metadata.py b/conda_build/metadata.py index 3fbb7ca1e0..642a002f7c 100644 --- a/conda_build/metadata.py +++ b/conda_build/metadata.py @@ -16,7 +16,7 @@ from conda_build.features import feature_list from conda_build.config import Config from conda_build.utils import rec_glob, ensure_list -from conda_build.license_family import allowed_license_families +from conda_build.license_family import ensure_valid_license_family try: import yaml @@ -30,8 +30,6 @@ sys.exit('Error: could not import yaml (required to read meta.yaml ' 'files of conda recipes)') -from conda_build.utils import comma_join - on_win = (sys.platform == 'win32') log = logging.getLogger(__file__) @@ -137,17 +135,6 @@ def yamlize(data): raise exceptions.UnableToParse(original=e) -def ensure_valid_license_family(meta): - try: - license_family = meta['about']['license_family'] - except KeyError: - return - if license_family not in allowed_license_families: - raise RuntimeError(exceptions.indent( - "about/license_family '%s' not allowed. Allowed families are %s." % - (license_family, comma_join(sorted(allowed_license_families))))) - - def ensure_valid_fields(meta): try: pin_depends = meta['build']['pin_depends']