Repository: conda/conda-build

Issue:
Build variants does not work with source repo revision variations
With a `meta.yaml` that contains:
```
source:
  svn_url: an_url
  svn_rev: {{ version }}
```
and a `conda_build_config.yaml` with:
```
version:
  - 1
  - 2
```
Both packages are built from the same sources of the first version, the repo is only checked out once.

Am I doing it properly or is it a bug?



Discussion:
This seems like a bug.  What version of conda-build is it?  This seems like something similar I fixed recently.
I use version 3.0.19, but being stuck on redhat 5 I understood that I shall not go beyond that version.
ah, no, that's not quite accurate, but it is a sticky situation.  It's safe to update conda-build to 3.0.27 (the latest version), but that version is only available as a package on the ``main`` channel, which also includes all of the other redhat 5 incompatible stuff.  I think your best option might be to download the 3.0.27 package you want (the one that matches your python version) from https://repo.continuum.io/pkgs/main/linux-64/ and then manually install it using the path to your downloaded file.  This will not install any dependencies, but since you already have 3.0.19, you should be fine.

```conda install path/to/local/conda-build-3.0.27-(full file name).tar.bz2```
I updated to conda-build 3.0.27, thx!
Unfortunately the issue remains.
At the time of the initial issue, I did find a workaround, but after I updated conda-build to 3.8 (still on RHEL 5), I'm facing a similar issue where `version` is zipped with other keys:
`ValueError: variant config in config.variant is ambiguous because it does not fully implement all zipped keys, or specifies a subspace that is not fully implemented.`

If I rename the key `version` to something else, then that issue is gone.

Is there something special about using the key `version` with zipped keys?
It actually has nothing to do with the `version` key, I managed to reproduce the issue with the following recipes:

- `x/meta.yaml`
```
package:
        name: x
        version: {{ bar }}
```
- `x/conda_build_config.yaml`
```
foo:
        - a
        - a
bar:
        - 1
        - 2
zip_keys:
        - bar
        - foo
```
- `xx/meta.yaml`
```
package:
        name: xx
        version: {{ bar }}

requirements:
        build:
                - x
```
- `xx/conda_build_config.yaml`
```
bar:
        - 0
```

The recipe `xx` requires the package `x`, `x` recipe uses `zip_keys` with the same `bar` key as for `xx` but with the `bar` value of `xx` is not in the values of `bar` for `x`.
None of the package shall be already built, then run `conda build xx` and then:
```
Traceback (most recent call last):
  File "/anaconda2/bin/conda-build", line 11, in <module>
    sys.exit(main())
  File "/anaconda2/lib/python2.7/site-packages/conda_build/cli/main_build.py", line 420, in main
    execute(sys.argv[1:])
  File "/anaconda2/lib/python2.7/site-packages/conda_build/cli/main_build.py", line 411, in execute
    verify=args.verify)
  File "/anaconda2/lib/python2.7/site-packages/conda_build/api.py", line 199, in build
    notest=notest, need_source_download=need_source_download, variants=variants)
  File "/anaconda2/lib/python2.7/site-packages/conda_build/build.py", line 2157, in build_tree
    dep_metas = render_recipe(recipe_dir, config=metadata.config)
  File "/anaconda2/lib/python2.7/site-packages/conda_build/render.py", line 662, in render_recipe
    variants = get_package_variants(m, variants=variants)
  File "/anaconda2/lib/python2.7/site-packages/conda_build/variants.py", line 499, in get_package_variants
    combined_spec, extend_keys = combine_specs(specs, log_output=config.verbose)
  File "/anaconda2/lib/python2.7/site-packages/conda_build/variants.py", line 270, in combine_specs
    log_output=log_output)
  File "/anaconda2/lib/python2.7/site-packages/conda_build/variants.py", line 245, in _combine_spec_dictionaries
    spec_source))
ValueError: variant config in config.variant is ambiguous because it does not fully implement all zipped keys, or specifies a subspace that is not fully implemented.
```

It looks like there is a mismatch of key and context in the `_combine_spec_dictionaries` function.
I think that points to some caching or global variable nonsense.  Thanks for the reproducer code.  I'll work that into a test and try to fix it from there.

Resolving patch:
diff --git a/conda_build/environ.py b/conda_build/environ.py
--- a/conda_build/environ.py
+++ b/conda_build/environ.py
@@ -154,7 +154,6 @@ def verify_git_repo(git_exe, git_dir, git_url, git_commits_since_tag, debug=Fals
     return OK
 
 
-@memoized
 def get_git_info(git_exe, repo, debug):
     """
     Given a repo to a git repo, return a dictionary of:


Test patch:
diff --git a/tests/test-recipes/variants/29_different_git_vars/conda_build_config.yaml b/tests/test-recipes/variants/29_different_git_vars/conda_build_config.yaml
new file mode 100644
--- /dev/null
+++ b/tests/test-recipes/variants/29_different_git_vars/conda_build_config.yaml
@@ -0,0 +1,3 @@
+git_tag:
+  - 1.21.11
+  - 1.20.0
diff --git a/tests/test-recipes/variants/29_different_git_vars/meta.yaml b/tests/test-recipes/variants/29_different_git_vars/meta.yaml
new file mode 100644
--- /dev/null
+++ b/tests/test-recipes/variants/29_different_git_vars/meta.yaml
@@ -0,0 +1,15 @@
+package:
+  name: conda-build-test-variant-git
+  version: {{ GIT_DESCRIBE_TAG }}
+
+source:
+  git_url: https://github.com/conda/conda_build_test_recipe
+  git_tag: {{ git_tag }}
+
+build:
+  number: {{ GIT_DESCRIBE_NUMBER }}
+
+requirements:
+  build:
+    - python
+
diff --git a/tests/test_variants.py b/tests/test_variants.py
--- a/tests/test_variants.py
+++ b/tests/test_variants.py
@@ -441,3 +441,11 @@ def test_custom_compiler():
     recipe = os.path.join(recipe_dir, '28_custom_compiler')
     ms = api.render(recipe, permit_unsatisfiable_variants=True, finalize=False, bypass_env_check=True)
     assert len(ms) == 3
+
+
+def test_different_git_vars():
+    recipe = os.path.join(recipe_dir, '29_different_git_vars')
+    ms = api.render(recipe)
+    versions = [m[0].version() for m in ms]
+    assert "1.20.0" in versions
+    assert "1.21.11" in versions