Repository: conda/conda-build

Issue:
RECIPE_PATH can be a meta.yaml
### Actual Behavior

When running `conda build /path/to/meta.yaml` the package builds correctly

### Expected Behavior

`RECIPE_PATH` is suppossed to be a dircetory, so passing in a file should fail.

### Steps to Reproduce

<!-- Steps to reproduce issue. -->


##### `Output of conda info`
<!-- Between the ticks below, paste the output of 'conda info' -->
```

```

CC @dillonroach


Discussion:
According to the documentation, it should be a directory, indeed
```
positional arguments:
       RECIPE_PATH
              Path  to  recipe  directory. Pass 'purge' here to clean the work
              and test intermediates.
```

However, I don't see this behavior as a problem. or is it? 
I am not against to raise an error when the ``RECIPE_PATH`` receives a filepath.
I think we have two options here, we might update the docs to also cover this possibility or to raise an error when a file is passed, that should be simple to implement

cc: @msarahan @jjhelmus 
Yeah, maybe this is just a docs error, but it was unexpected
[Theses lines](https://github.com/conda/conda-build/blob/master/conda_build/utils.py#L1203-L1204) in utils.py look to be responsible for `meta.yaml` being a valid argument to RECIPE_PATH.  This seems to case of the [robustness principle](https://en.wikipedia.org/wiki/Robustness_principle), "be liberal in what you accept from others".  conda build will accept a meta.yaml file as a recipe path because users tend to pass those in and it is not difficult to determine the intention.  That said I'm split as to if this should be documented as such.  Although passing a path to a meta.yaml file is allow it is not the recommended use.  
It might be valuable then to just add a warning? Say.. leave the handling and docs the same, but add a warning toss that says something like 'you have specified a meta.yaml instead of a directory, re-assigning the containing directory as the target'

That way the edge cases are handled without a hard-stop error, but there's at least feedback to a newer user that the line they called isn't the ideal.. nor is it actually what's being executed under the hood
I think a warning as @dillonroach mentioned is a good idea indeed.

Resolving patch:
diff --git a/conda_build/utils.py b/conda_build/utils.py
--- a/conda_build/utils.py
+++ b/conda_build/utils.py
@@ -1,5 +1,6 @@
 from __future__ import absolute_import, division, print_function
 
+import warnings
 from collections import OrderedDict, defaultdict
 import contextlib
 import fnmatch
@@ -893,7 +894,7 @@ def comma_join(items):
     'a'
     >>> comma_join(['a', 'b'])
     'a and b'
-    >>> comma_join(['a', 'b', 'c])
+    >>> comma_join(['a', 'b', 'c'])
     'a, b, and c'
     """
     return ' and '.join(items) if len(items) <= 2 else ', '.join(items[:-1]) + ', and ' + items[-1]
@@ -1196,6 +1197,12 @@ def find_recipe(path):
 
     If we have a base level meta.yaml and other supplemental ones, use that first"""
     if os.path.isfile(path) and os.path.basename(path) in ["meta.yaml", "conda.yaml"]:
+        warnings.warn(
+            "RECIPE_PATH received is a file. File: {}\n"
+            "It should be a path to a folder. \n"
+            "Forcing conda-build to use the recipe file.".format(path),
+            UserWarning
+        )
         return os.path.dirname(path)
     results = rec_glob(path, ["meta.yaml", "conda.yaml"])
     if len(results) > 1:


Test patch:
diff --git a/tests/test_utils.py b/tests/test_utils.py
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -7,6 +7,7 @@
 
 from conda_build.exceptions import BuildLockError
 import conda_build.utils as utils
+from conda_build.utils import find_recipe
 
 
 def makefile(name, contents=""):
@@ -337,3 +338,18 @@ def test_get_lock(testing_workdir):
     # ...even when not normalized
     lock1_unnormalized = utils.get_lock(os.path.join(testing_workdir, 'foo', '..', 'lock1'))
     assert lock1.lock_file == lock1_unnormalized.lock_file
+
+
+def test_recipe_path_meta(tmpdir, recwarn):
+    dir_recipe_path = tmpdir.mkdir("recipe-path")
+    recipe_path = dir_recipe_path.join("meta.yaml")
+    recipe_path.write("")
+
+    assert find_recipe(str(recipe_path)) == str(dir_recipe_path)
+    assert "RECIPE_PATH received is a file. File: {}\n" \
+           "It should be a path to a folder. \n" \
+           "Forcing conda-build to use the recipe file.".format(str(recipe_path)) \
+           == str(recwarn.pop(UserWarning).message)
+
+    assert find_recipe(str(dir_recipe_path)) == str(recipe_path)
+    assert not recwarn.list