Repository: conda/conda-build

Issue:
Metadata parse failure when building apsw pypi package
To generate the output below, I added some print output to `conda_build.metadata.yamlize`:

``` python
@memoized
def yamlize(data):
    print(72*'*')
    print(data)
    try:
        return yaml.load(data, Loader=BaseLoader)
```

Here is the build failure:

```
bash-3.2$ conda build apsw
************************************************************************
package:
  name: uninitialized

************************************************************************
package:
  name: apsw
  version: "3.9.2-r1"

source:
  fn: apsw-3.9.2-r1.tar.gz
  url: https://pypi.python.org/packages/source/a/apsw/apsw-3.9.2-r1.tar.gz
  md5: 8cfdf9fea2904e3cc4c212ab41760fdd




requirements:
  build:
    - python

  run:
    - python






about:
  home: https://github.com/rogerbinns/apsw/
  license: OSI Approved ::
  summary: 'Another Python SQLite Wrapper'


Traceback (most recent call last):
  File "/Users/alx/anaconda/bin/conda-build", line 5, in <module>
    sys.exit(main())
  File "/Users/alx/anaconda/lib/python2.7/site-packages/conda_build/main_build.py", line 208, in main
    args_func(args, p)
  File "/Users/alx/anaconda/lib/python2.7/site-packages/conda_build/main_build.py", line 493, in args_func
    args.func(args, p)
  File "/Users/alx/anaconda/lib/python2.7/site-packages/conda_build/main_build.py", line 385, in execute
    m = MetaData(recipe_dir)
  File "/Users/alx/anaconda/lib/python2.7/site-packages/conda_build/metadata.py", line 347, in __init__
    self.parse_again(permit_undefined_jinja=True)
  File "/Users/alx/anaconda/lib/python2.7/site-packages/conda_build/metadata.py", line 358, in parse_again
    self.meta = parse(self._get_contents(permit_undefined_jinja))
  File "/Users/alx/anaconda/lib/python2.7/site-packages/conda_build/metadata.py", line 146, in parse
    res = yamlize(data)
  File "/Users/alx/anaconda/lib/python2.7/site-packages/conda/utils.py", line 118, in __call__
    value = self.func(*args, **kw)
  File "/Users/alx/anaconda/lib/python2.7/site-packages/conda_build/metadata.py", line 101, in yamlize
    return yaml.load(data, Loader=BaseLoader)
  File "/Users/alx/anaconda/lib/python2.7/site-packages/yaml/__init__.py", line 71, in load
    return loader.get_single_data()
  File "/Users/alx/anaconda/lib/python2.7/site-packages/yaml/constructor.py", line 37, in get_single_data
    node = self.get_single_node()
  File "_yaml.pyx", line 707, in _yaml.CParser.get_single_node (ext/_yaml.c:8308)
  File "_yaml.pyx", line 725, in _yaml.CParser._compose_document (ext/_yaml.c:8581)
  File "_yaml.pyx", line 776, in _yaml.CParser._compose_node (ext/_yaml.c:9306)
  File "_yaml.pyx", line 890, in _yaml.CParser._compose_mapping_node (ext/_yaml.c:10838)
  File "_yaml.pyx", line 776, in _yaml.CParser._compose_node (ext/_yaml.c:9306)
  File "_yaml.pyx", line 892, in _yaml.CParser._compose_mapping_node (ext/_yaml.c:10868)
  File "_yaml.pyx", line 905, in _yaml.CParser._parse_next_event (ext/_yaml.c:11045)
yaml.scanner.ScannerError: mapping values are not allowed in this context
  in "<unicode string>", line 27, column 26
bash-3.2$ 
```



Discussion:
This is happening because of the `::` in the `about: licence` entry.

Also have to remove the `-r1` from the `version:` entry.

> This is happening because of the :: in the about: licence entry.

I guess the solution is to put that entry in quotes.

> Also have to remove the -r1 from the version: entry.

Yup, as [described in the conda-build docs](http://conda.pydata.org/docs/building/meta-yaml.html#package-version), the version must never contain a dash character.  Fortunately, conda-build already issues a helpful error message in such cases:

```
Error: bad character '-' in package/version: 3.9.2-r1
```

I guess there are no problems in conda-build to address here.  Would you mind closing this issue?

> I guess there are no problems in conda-build to address here.

The error message from `::` was extremely cryptic.  I figured out that that was the problem by breaking out the debugger.  I would advise making the message more informative.


Resolving patch:
diff --git a/conda_build/metadata.py b/conda_build/metadata.py
--- a/conda_build/metadata.py
+++ b/conda_build/metadata.py
@@ -97,7 +97,7 @@ def select_lines(data, namespace):
 def yamlize(data):
     try:
         return yaml.load(data, Loader=BaseLoader)
-    except yaml.parser.ParserError as e:
+    except yaml.error.YAMLError as e:
         if '{{' in data:
             try:
                 import jinja2


Test patch: