Repository: conda/conda-build

Issue:
Regression in 2.1.0: conda render raises incorrect assertion
While the assertion is fine, it fails in the first pass of render, before the source is downloaded. With the source downloaded, it would not fail.

Relevant version metadata is:

```
  version: {{ GIT_DESCRIBE_TAG.lstrip('v') }}.{{ GIT_DESCRIBE_NUMBER }}.{{ GIT_DESCRIBE_HASH }}
```

Assertion is:

```
Traceback (most recent call last):
  File "C:\Anaconda3\Scripts\conda-render-script.py", line 5, in <module>
    sys.exit(conda_build.cli.main_render.main())
  File "C:\Anaconda3\lib\site-packages\conda_build\cli\main_render.py", line 130, in main
    return execute(sys.argv[1:])
  File "C:\Anaconda3\lib\site-packages\conda_build\cli\main_render.py", line 122, in execute
    config=config)
  File "C:\Anaconda3\lib\site-packages\conda_build\render.py", line 157, in render_recipe
    config=config)
  File "C:\Anaconda3\lib\site-packages\conda_build\render.py", line 90, in parse_or_try_download
    metadata.parse_again(config=config, permit_undefined_jinja=False)
  File "C:\Anaconda3\lib\site-packages\conda_build\metadata.py", line 431, in parse_again
    self.meta = parse(self._get_contents(permit_undefined_jinja, config=config),
  File "C:\Anaconda3\lib\site-packages\conda_build\metadata.py", line 770, in _get_contents
    permit_undefined_jinja=permit_undefined_jinja))
  File "C:\Anaconda3\lib\site-packages\conda_build\jinja_context.py", line 213, in context_processor
    ctx = get_environ(config=config, m=initial_metadata)
  File "C:\Anaconda3\lib\site-packages\conda_build\environ.py", line 222, in get_dict
    d.update(meta_vars(m, config))
  File "C:\Anaconda3\lib\site-packages\conda_build\environ.py", line 331, in meta_vars
    d['PKG_VERSION'] = meta.version()
  File "C:\Anaconda3\lib\site-packages\conda_build\metadata.py", line 547, in version
    assert not res.startswith('.'), "Version can't start with leading period -  got %s" % res
AssertionError: Version can't start with leading period -  got ..
```



Discussion:
Dang.  I'll fix this for 2.1.1.

Resolving patch:
diff --git a/conda_build/metadata.py b/conda_build/metadata.py
--- a/conda_build/metadata.py
+++ b/conda_build/metadata.py
@@ -544,7 +544,8 @@ def version(self):
         if res is None:
             sys.exit("Error: package/version missing in: %r" % self.meta_path)
         check_bad_chrs(res, 'package/version')
-        assert not res.startswith('.'), "Version can't start with leading period -  got %s" % res
+        assert self.undefined_jinja_vars or not res.startswith('.'), "Fully-rendered version can't\
+        start with leading period -  got %s" % res
         return res
 
     def build_number(self):


Test patch:
diff --git a/tests/test-recipes/metadata/_git_describe_number_branch/meta.yaml b/tests/test-recipes/metadata/_git_describe_number_branch/meta.yaml
--- a/tests/test-recipes/metadata/_git_describe_number_branch/meta.yaml
+++ b/tests/test-recipes/metadata/_git_describe_number_branch/meta.yaml
@@ -1,6 +1,6 @@
 package:
   name: git_describe_number_branch
-  version: {{ GIT_DESCRIBE_TAG }}
+  version: {{ GIT_DESCRIBE_TAG }}.0
 
 source:
   git_url: https://github.com/conda/conda_build_test_recipe
diff --git a/tests/test_api_build.py b/tests/test_api_build.py
--- a/tests/test_api_build.py
+++ b/tests/test_api_build.py
@@ -125,7 +125,7 @@ def test_no_anaconda_upload_condarc(service_name, testing_workdir, test_config,
 def test_git_describe_info_on_branch(test_config):
     output = api.get_output_file_path(os.path.join(metadata_dir, "_git_describe_number_branch"))
     test_path = os.path.join(sys.prefix, "conda-bld", test_config.subdir,
-                             "git_describe_number_branch-1.20.2-1_g82c6ba6.tar.bz2")
+                             "git_describe_number_branch-1.20.2.0-1_g82c6ba6.tar.bz2")
     assert test_path == output