Repository: conda/conda-build

Issue:
feature names with '-' is bugged
If a feature is named for example `python-debug`, building the recipes fails with:

      File "/home/vagrant/miniconda3/bin/conda-build", line 6, in <module>
        sys.exit(conda_build.cli.main_build.main())
      File "/home/vagrant/miniconda3/lib/python3.5/site-packages/conda_build/cli/main_build.py", line 247, in main
        execute(sys.argv[1:])
      File "/home/vagrant/miniconda3/lib/python3.5/site-packages/conda_build/cli/main_build.py", line 239, in execute
        already_built=None, config=config, noverify=args.no_verify)
      File "/home/vagrant/miniconda3/lib/python3.5/site-packages/conda_build/api.py", line 77, in build
        need_source_download=need_source_download, config=config)
      File "/home/vagrant/miniconda3/lib/python3.5/site-packages/conda_build/build.py", line 1088, in build_tree
        config=recipe_config)
      File "/home/vagrant/miniconda3/lib/python3.5/site-packages/conda_build/build.py", line 817, in build
        tarcheck.check_all(tmp_path)
      File "/home/vagrant/miniconda3/lib/python3.5/site-packages/conda_build/tarcheck.py", line 91, in check_all
        x.index_json()
      File "/home/vagrant/miniconda3/lib/python3.5/site-packages/conda_build/tarcheck.py", line 62, in index_json
        getattr(self, varname)))
    Exception: name: 'python' != 'python-3.5.2'

In [tarcheck.py](https://github.com/conda/conda-build/blob/7016ee81371a26970583cf292f2eb331d51362c1/conda_build/tarcheck.py#L25), if `dist = python-3.5.2-python-debug_3`, we get `name, version, build = 'python-3.5.2', 'python', 'debug_3'`, which is wrong.

If `dist = python-3.5.2-python_debug_3`, we get `name, version, build = 'python', '3.5.2', 'python_debug_3`, which is correct.


Discussion:
unfortunately, there is a ton of legacy logic that assumes a particular number of ```-``` characters, split from the right backwards.  Changing conda-build to allow dashes in features is asking for a lot of trouble.

Instead, I'd propose to raise error messages when features with - are defined.  Is that an acceptable solution to you?
Hi, absolutely, I think raising a error message would be perfect! Thanks @msarahan 

Resolving patch:
diff --git a/conda_build/metadata.py b/conda_build/metadata.py
--- a/conda_build/metadata.py
+++ b/conda_build/metadata.py
@@ -423,26 +423,25 @@ def parse_again(self, config=None, permit_undefined_jinja=False):
         permit_undefined_jinja: If True, *any* use of undefined jinja variables will
                                 evaluate to an emtpy string, without emitting an error.
         """
-        if not self.meta_path:
-            return
+        if self.meta_path:
+            if not config:
+                config = self.config
+            try:
+                os.environ["CONDA_BUILD_STATE"] = "RENDER"
+                self.meta = parse(self._get_contents(permit_undefined_jinja, config=config),
+                                config=config, path=self.meta_path)
+            except:
+                raise
+            finally:
+                del os.environ["CONDA_BUILD_STATE"]
 
-        if not config:
-            config = self.config
+            if (isfile(self.requirements_path) and
+                    not self.meta['requirements']['run']):
+                self.meta.setdefault('requirements', {})
+                run_requirements = specs_from_url(self.requirements_path)
+                self.meta['requirements']['run'] = run_requirements
 
-        try:
-            os.environ["CONDA_BUILD_STATE"] = "RENDER"
-            self.meta = parse(self._get_contents(permit_undefined_jinja, config=config),
-                              config=config, path=self.meta_path)
-        except:
-            raise
-        finally:
-            del os.environ["CONDA_BUILD_STATE"]
-
-        if (isfile(self.requirements_path) and
-                   not self.meta['requirements']['run']):
-            self.meta.setdefault('requirements', {})
-            run_requirements = specs_from_url(self.requirements_path)
-            self.meta['requirements']['run'] = run_requirements
+        self.validate_features()
 
     def parse_until_resolved(self, config):
         # undefined_jinja_vars is refreshed by self.parse again
@@ -867,3 +866,8 @@ def uses_vcs_in_build(self):
                                 vcs = "mercurial"
                             return vcs
         return None
+
+    def validate_features(self):
+        if any('-' in feature for feature in self.get_value('build/features')):
+            raise ValueError("- is a disallowed character in features.  Please change this "
+                             "character in your recipe.")


Test patch:
diff --git a/tests/test_metadata.py b/tests/test_metadata.py
--- a/tests/test_metadata.py
+++ b/tests/test_metadata.py
@@ -115,3 +115,11 @@ def test_disallow_leading_period_in_version(test_metadata):
     test_metadata.meta['package']['version'] = '.ste.ve'
     with pytest.raises(AssertionError):
         test_metadata.version()
+
+
+def test_disallow_dash_in_features(test_metadata):
+    test_metadata.meta['build']['features'] = ['abc']
+    test_metadata.parse_again()
+    with pytest.raises(ValueError):
+        test_metadata.meta['build']['features'] = ['ab-c']
+        test_metadata.parse_again()