Repository: conda-forge/conda-smithy

Issue:
recipe-lint parser error on template
Issue:

`conda smithy recipe-lint` encounters a parser error when running on [this recipe](https://github.com/conda-forge/staged-recipes/pull/8838/files#diff-857178a7191e6e87c83b1b9b76ec0e19):

```
   100% (...)   ~/src/staged-recipes/recipes/itk-meshtopolydata     cf2ec104  add-itk-meshtopolydata  INSERT  conda smithy recipe-lint .    Traceback (most recent call last):
  File "/home/matt/bin/miniconda3/bin/conda-smithy", line 10, in <module>
    sys.exit(main())
  File "/home/matt/bin/miniconda3/lib/python3.7/site-packages/conda_smithy/cli.py", line 471, in main
    args.subcommand_func(args)
  File "/home/matt/bin/miniconda3/lib/python3.7/site-packages/conda_smithy/cli.py", line 366, in __call__
    return_hints=True,
  File "/home/matt/bin/miniconda3/lib/python3.7/site-packages/conda_smithy/lint_recipe.py", line 536, in main
    meta = ruamel.yaml.load(content, ruamel.yaml.RoundTripLoader)
  File "/home/matt/bin/miniconda3/lib/python3.7/site-packages/ruamel/yaml/main.py", line 935, in load
    return loader._constructor.get_single_data()
  File "/home/matt/bin/miniconda3/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 109, in get_single_data
    node = self.composer.get_single_node()
  File "/home/matt/bin/miniconda3/lib/python3.7/site-packages/ruamel/yaml/composer.py", line 78, in get_single_node
    document = self.compose_document()
  File "/home/matt/bin/miniconda3/lib/python3.7/site-packages/ruamel/yaml/composer.py", line 101, in compose_document
    node = self.compose_node(None, None)
  File "/home/matt/bin/miniconda3/lib/python3.7/site-packages/ruamel/yaml/composer.py", line 138, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/home/matt/bin/miniconda3/lib/python3.7/site-packages/ruamel/yaml/composer.py", line 218, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/home/matt/bin/miniconda3/lib/python3.7/site-packages/ruamel/yaml/composer.py", line 138, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/home/matt/bin/miniconda3/lib/python3.7/site-packages/ruamel/yaml/composer.py", line 211, in compose_mapping_node
    while not self.parser.check_event(MappingEndEvent):
  File "/home/matt/bin/miniconda3/lib/python3.7/site-packages/ruamel/yaml/parser.py", line 141, in check_event
    self.current_event = self.state()
  File "/home/matt/bin/miniconda3/lib/python3.7/site-packages/ruamel/yaml/parser.py", line 581, in parse_block_mapping_key
    token.start_mark,
ruamel.yaml.parser.ParserError: while parsing a block mapping
  in "<unicode string>", line 30, column 3:
      number: 0
      ^ (line: 30)
expected <block end>, but found '<scalar>'
  in "<unicode string>", line 35, column 71:
     ... vv itk_meshtopolydata-0.3.4-cp["0"]["2"]-cp["0"]["2"]m-macosx_10 ...
                                         ^ (line: 35)


```
<br/>
Environment (<code>conda list</code>):
<details>

```
$ conda list
# packages in environment at /home/matt/bin/miniconda3/envs/itk-recipes:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
asn1crypto                0.24.0                py37_1003    conda-forge
beautifulsoup4            4.7.1                 py37_1001    conda-forge
bzip2                     1.0.8                h516909a_0    conda-forge
ca-certificates           2019.6.16            hecc5488_0    conda-forge
certifi                   2019.6.16                py37_1    conda-forge
cffi                      1.12.3           py37h8022711_0    conda-forge
chardet                   3.0.4                 py37_1003    conda-forge
click                     7.0                        py_0    conda-forge
conda                     4.7.5                    py37_0    conda-forge
conda-build               3.18.7                   py37_1    conda-forge
conda-package-handling    1.3.11                   py37_0    conda-forge
conda-verify              3.1.1                 py37_1000    conda-forge
cryptography              2.7              py37h72c5cf5_0    conda-forge
filelock                  3.0.10                     py_0    conda-forge
future                    0.17.1                py37_1000    conda-forge
glob2                     0.7                        py_0    conda-forge
icu                       58.2              hf484d3e_1000    conda-forge
idna                      2.8                   py37_1000    conda-forge
jinja2                    2.10.1                     py_0    conda-forge
libarchive                3.3.3             hb44662c_1005    conda-forge
libffi                    3.2.1             he1b5a44_1006    conda-forge
libgcc-ng                 9.1.0                hdf63c60_0  
libiconv                  1.15              h516909a_1005    conda-forge
liblief                   0.9.0                hf8a498c_1    conda-forge
libstdcxx-ng              9.1.0                hdf63c60_0  
libxml2                   2.9.9                h13577e0_1    conda-forge
lz4-c                     1.8.3             he1b5a44_1001    conda-forge
lzo                       2.10              h14c3975_1000    conda-forge
markupsafe                1.1.1            py37h14c3975_0    conda-forge
ncurses                   6.1               hf484d3e_1002    conda-forge
openssl                   1.1.1c               h516909a_0    conda-forge
patchelf                  0.10                 he1b5a44_0    conda-forge
pip                       19.1.1                   py37_0    conda-forge
pkginfo                   1.5.0.1                    py_0    conda-forge
psutil                    5.6.3            py37h516909a_0    conda-forge
py-lief                   0.9.0            py37he1b5a44_1    conda-forge
pycosat                   0.6.3           py37h14c3975_1001    conda-forge
pycparser                 2.19                     py37_1    conda-forge
pyopenssl                 19.0.0                   py37_0    conda-forge
pysocks                   1.7.0                    py37_0    conda-forge
python                    3.7.3                h33d41f4_1    conda-forge
python-libarchive-c       2.8                   py37_1004    conda-forge
pytz                      2019.1                     py_0    conda-forge
pyyaml                    5.1.1            py37h516909a_0    conda-forge
readline                  8.0                  hf8c457e_0    conda-forge
requests                  2.22.0                   py37_1    conda-forge
ruamel_yaml               0.15.71         py37h14c3975_1000    conda-forge
setuptools                41.0.1                   py37_0    conda-forge
six                       1.12.0                py37_1000    conda-forge
soupsieve                 1.9.2                    py37_0    conda-forge
sqlite                    3.29.0               hcee41ef_0    conda-forge
tk                        8.6.9             hed695b0_1002    conda-forge
tqdm                      4.32.2                     py_0    conda-forge
urllib3                   1.25.3                   py37_0    conda-forge
wheel                     0.33.4                   py37_0    conda-forge
xz                        5.2.4             h14c3975_1001    conda-forge
yaml                      0.1.7             h14c3975_1001    conda-forge
zlib                      1.2.11            h516909a_1005    conda-forge
zstd                      1.4.0                h3b9ef0a_0    conda-forge

```
</details>

<br/>
Details about  <code>conda</code> and system ( <code>conda info</code> ):
<details>

```
$ conda info

     active environment : itk-recipes
    active env location : /home/matt/bin/miniconda3/envs/itk-recipes
            shell level : 2
       user config file : /home/matt/.condarc
 populated config files : /home/matt/.condarc
          conda version : 4.7.8
    conda-build version : 3.18.8
         python version : 3.7.3.final.0
       virtual packages : __cuda=9.1
       base environment : /home/matt/bin/miniconda3  (writable)
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/matt/bin/miniconda3/pkgs
                          /home/matt/.conda/pkgs
       envs directories : /home/matt/bin/miniconda3/envs
                          /home/matt/.conda/envs
               platform : linux-64
             user-agent : conda/4.7.8 requests/2.21.0 CPython/3.7.3 Linux/4.15.0-54-generic ubuntu/18.04.2 glibc/2.27
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False


```
</details>

@scopatz @ocefpaf 


Discussion:
PRs welcome. You have to add a default value for PY_VER in https://github.com/conda-forge/conda-smithy/blob/master/conda_smithy/utils.py#L45
Thanks for opening this @thewtex!

Resolving patch:
diff --git a/conda_smithy/utils.py b/conda_smithy/utils.py
--- a/conda_smithy/utils.py
+++ b/conda_smithy/utils.py
@@ -4,6 +4,7 @@
 import datetime
 import time
 import os
+import sys
 from collections import defaultdict
 from contextlib import contextmanager
 
@@ -13,7 +14,7 @@
 # define global yaml API
 # roundrip-loader and allowing duplicate keys
 # for handling # [filter] / # [not filter]
-yaml = ruamel.yaml.YAML(typ='rt')
+yaml = ruamel.yaml.YAML(typ="rt")
 yaml.allow_duplicate_keys = True
 
 
@@ -60,7 +61,9 @@ def render_meta_yaml(text):
         )
     )
     mockos = MockOS()
-    content = env.from_string(text).render(os=mockos, environ=mockos.environ)
+    py_ver = "3.7"
+    context = {"os": mockos, "environ": mockos.environ, "PY_VER": py_ver}
+    content = env.from_string(text).render(context)
     return content
 
 


Test patch: