Repository: conda/conda-build

Issue:
Wrong addition of vc package?
This is happening only with 3.1.2 and not with 3.1.1

I suspect the commit which caused this is: https://github.com/conda/conda-build/commit/2a71071d8fab8dc83d7d4a08d4c3df201a611899

Steps to reproduce:

```
(root) F:\nwani\aggregate\test-feedstock>type meta.yaml
package:
  name: test
  version: 1.0.0

requirements:
  host:
    - openssl
  build:
    - {{ compiler('c') }}

(root) F:\nwani\aggregate\test-feedstock>type conda_build_config.yaml
c_compiler:
  - vs2008                     # [win]
  - vs2015                     # [win]
cross_compiler_target_platform:
  - win-32                     # [win]
  - win-64                     # [win]
target_platform:
  - win-64                     # [win]
  - win-32                     # [win]
vc:
  - 9
  - 14
zip_keys:
  -                             # [win]
    - vc                        # [win]
    - c_compiler                # [win]
```

```
(root) F:\nwani\aggregate\test-feedstock>conda build . -m conda_build_config.yaml
Attempting to finalize metadata for test
INFO:conda_build.metadata:Attempting to finalize metadata for test
failed to get install actions, retrying.  exception was: The following specifications were found to be in conflict:
  - vc 14 h2379b0c_2
  - vc 9.*
Use "conda info <package>" to see the dependencies for each package.
WARNING:conda_build.environ:failed to get install actions, retrying.  exception was: The following specifications were found to be i
  - vc 14 h2379b0c_2
  - vc 9.*
Use "conda info <package>" to see the dependencies for each package.
Failed to get install actions, max retries exceeded.
ERROR:conda_build.environ:Failed to get install actions, max retries exceeded.
Traceback (most recent call last):
  File "f:\nwani\conda-build\conda_build\environ.py", line 691, in get_install_actions
    actions = install_actions(prefix, index, specs, force=True)
  File "F:\nwani\mc3\lib\site-packages\conda\plan.py", line 461, in install_actions
    update_deps, pinned)
  File "F:\nwani\mc3\lib\site-packages\conda\plan.py", line 631, in get_actions_for_dists
    pkgs = r.install(specs, installed, update_deps=update_deps)
  File "F:\nwani\mc3\lib\site-packages\conda\resolve.py", line 813, in install
    pkgs = self.solve(specs, returnall=returnall)
  File "F:\nwani\mc3\lib\site-packages\conda\resolve.py", line 868, in solve
    self.find_conflicts(specs)
  File "F:\nwani\mc3\lib\site-packages\conda\resolve.py", line 369, in find_conflicts
    raise UnsatisfiableError(bad_deps)
conda.exceptions.UnsatisfiableError: The following specifications were found to be in conflict:
  - vc 14 h2379b0c_2
  - vc 9.*
Use "conda info <package>" to see the dependencies for each package.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "f:\nwani\conda-build\conda_build\environ.py", line 691, in get_install_actions
    actions = install_actions(prefix, index, specs, force=True)
  File "F:\nwani\mc3\lib\site-packages\conda\plan.py", line 461, in install_actions
    update_deps, pinned)
  File "F:\nwani\mc3\lib\site-packages\conda\plan.py", line 631, in get_actions_for_dists
    pkgs = r.install(specs, installed, update_deps=update_deps)
  File "F:\nwani\mc3\lib\site-packages\conda\resolve.py", line 813, in install
    pkgs = self.solve(specs, returnall=returnall)
  File "F:\nwani\mc3\lib\site-packages\conda\resolve.py", line 868, in solve
    self.find_conflicts(specs)
  File "F:\nwani\mc3\lib\site-packages\conda\resolve.py", line 369, in find_conflicts
    raise UnsatisfiableError(bad_deps)
conda.exceptions.UnsatisfiableError: The following specifications were found to be in conflict:
  - vc 14 h2379b0c_2
  - vc 9.*
Use "conda info <package>" to see the dependencies for each package.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "f:\nwani\conda-build\conda_build\environ.py", line 691, in get_install_actions
    actions = install_actions(prefix, index, specs, force=True)
  File "F:\nwani\mc3\lib\site-packages\conda\plan.py", line 461, in install_actions
    update_deps, pinned)
  File "F:\nwani\mc3\lib\site-packages\conda\plan.py", line 631, in get_actions_for_dists
    pkgs = r.install(specs, installed, update_deps=update_deps)
  File "F:\nwani\mc3\lib\site-packages\conda\resolve.py", line 813, in install
    pkgs = self.solve(specs, returnall=returnall)
  File "F:\nwani\mc3\lib\site-packages\conda\resolve.py", line 868, in solve
    self.find_conflicts(specs)
  File "F:\nwani\mc3\lib\site-packages\conda\resolve.py", line 369, in find_conflicts
    raise UnsatisfiableError(bad_deps)
conda.exceptions.UnsatisfiableError: The following specifications were found to be in conflict:
  - vc 14 h2379b0c_2
  - vc 9.*
Use "conda info <package>" to see the dependencies for each package.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "F:\nwani\mc3\Scripts\conda-build-script.py", line 11, in <module>
    load_entry_point('conda-build', 'console_scripts', 'conda-build')()
  File "f:\nwani\conda-build\conda_build\cli\main_build.py", line 388, in main
    execute(sys.argv[1:])
  File "f:\nwani\conda-build\conda_build\cli\main_build.py", line 379, in execute
    verify=args.verify)
  File "f:\nwani\conda-build\conda_build\api.py", line 187, in build
    need_source_download=need_source_download, config=config, variants=variants)
  File "f:\nwani\conda-build\conda_build\build.py", line 1828, in build_tree
    notest=notest,
  File "f:\nwani\conda-build\conda_build\build.py", line 916, in build
    output_metas = expand_outputs([(m, need_source_download, need_reparse_in_env)])
  File "f:\nwani\conda-build\conda_build\render.py", line 621, in expand_outputs
    for (output_dict, m) in _m.get_output_metadata_set(permit_unsatisfiable_variants=False):
  File "f:\nwani\conda-build\conda_build\metadata.py", line 1770, in get_output_metadata_set
    permit_unsatisfiable_variants=permit_unsatisfiable_variants)
  File "f:\nwani\conda-build\conda_build\metadata.py", line 655, in finalize_outputs_pass
    fm = finalize_metadata(om, permit_unsatisfiable_variants=permit_unsatisfiable_variants)
  File "f:\nwani\conda-build\conda_build\render.py", line 390, in finalize_metadata
    permit_unsatisfiable_variants=permit_unsatisfiable_variants)
  File "f:\nwani\conda-build\conda_build\render.py", line 119, in get_env_dependencies
    channel_urls=tuple(m.config.channel_urls))
  File "f:\nwani\conda-build\conda_build\environ.py", line 727, in get_install_actions
    channel_urls=tuple(channel_urls))
  File "f:\nwani\conda-build\conda_build\environ.py", line 727, in get_install_actions
    channel_urls=tuple(channel_urls))
  File "f:\nwani\conda-build\conda_build\environ.py", line 727, in get_install_actions
    channel_urls=tuple(channel_urls))
  File "f:\nwani\conda-build\conda_build\environ.py", line 691, in get_install_actions
    actions = install_actions(prefix, index, specs, force=True)
  File "F:\nwani\mc3\lib\site-packages\conda\plan.py", line 461, in install_actions
    update_deps, pinned)
  File "F:\nwani\mc3\lib\site-packages\conda\plan.py", line 631, in get_actions_for_dists
    pkgs = r.install(specs, installed, update_deps=update_deps)
  File "F:\nwani\mc3\lib\site-packages\conda\resolve.py", line 813, in install
    pkgs = self.solve(specs, returnall=returnall)
  File "F:\nwani\mc3\lib\site-packages\conda\resolve.py", line 868, in solve
    self.find_conflicts(specs)
  File "F:\nwani\mc3\lib\site-packages\conda\resolve.py", line 369, in find_conflicts
    raise UnsatisfiableError(bad_deps)
conda.exceptions.UnsatisfiableError: The following specifications were found to be in conflict:
  - vc 14 h2379b0c_2
  - vc 9.*
Use "conda info <package>" to see the dependencies for each package.
```


Discussion:
Sorry, can confirm.  Will fix ASAP.

Resolving patch:
diff --git a/conda_build/render.py b/conda_build/render.py
--- a/conda_build/render.py
+++ b/conda_build/render.py
@@ -297,6 +297,9 @@ def add_upstream_pins(m, permit_unsatisfiable_variants, exclude_pattern):
 
     # is there a 'host' section?
     if m.is_cross:
+        # this must come before we read upstream pins, because it will enforce things
+        #      like vc version from the compiler.
+        m.meta['requirements']['host'].extend(extra_run_specs_from_build.get('strong', []))
         host_deps, host_unsat, extra_run_specs_from_host = _read_upstream_pin_files(m, 'host',
                                                     permit_unsatisfiable_variants, exclude_pattern)
         extra_run_specs = set(extra_run_specs_from_host.get('strong', []) +
@@ -314,7 +317,6 @@ def add_upstream_pins(m, permit_unsatisfiable_variants, exclude_pattern):
         extra_run_specs = set(extra_run_specs_from_build.get('strong', []) +
                               extra_run_specs_from_build.get('weak', []))
 
-    host_deps.extend(extra_run_specs_from_build.get('strong', []))
     run_deps = extra_run_specs | set(utils.ensure_list(requirements.get('run')))
 
     requirements.update({'build': [utils.ensure_valid_spec(spec, warn=True) for spec in build_deps],


Test patch:
diff --git a/tests/test-recipes/variants/22_run_exports_rerendered_for_other_variants/conda_build_config.yaml b/tests/test-recipes/variants/22_run_exports_rerendered_for_other_variants/conda_build_config.yaml
new file mode 100644
--- /dev/null
+++ b/tests/test-recipes/variants/22_run_exports_rerendered_for_other_variants/conda_build_config.yaml
@@ -0,0 +1,16 @@
+c_compiler:
+  - vs2008                     # [win]
+  - vs2015                     # [win]
+cross_compiler_target_platform:
+  - win-32                     # [win]
+  - win-64                     # [win]
+target_platform:
+  - win-64                     # [win]
+  - win-32                     # [win]
+vc:
+  - 9
+  - 14
+zip_keys:
+  -                             # [win]
+    - vc                        # [win]
+    - c_compiler                # [win]
diff --git a/tests/test-recipes/variants/22_run_exports_rerendered_for_other_variants/meta.yaml b/tests/test-recipes/variants/22_run_exports_rerendered_for_other_variants/meta.yaml
new file mode 100644
--- /dev/null
+++ b/tests/test-recipes/variants/22_run_exports_rerendered_for_other_variants/meta.yaml
@@ -0,0 +1,9 @@
+package:
+  name: test
+  version: 1.0.0
+
+requirements:
+  host:
+    - openssl
+  build:
+    - {{ compiler('c') }}
diff --git a/tests/test_variants.py b/tests/test_variants.py
--- a/tests/test_variants.py
+++ b/tests/test_variants.py
@@ -284,3 +284,10 @@ def test_variants_used_in_jinja2_conditionals(testing_config):
     assert len(ms) == 2
     assert sum(m.config.variant['blas_impl'] == 'mkl' for m, _, _ in ms) == 1
     assert sum(m.config.variant['blas_impl'] == 'openblas' for m, _, _ in ms) == 1
+
+
+def test_build_run_exports_act_on_host(testing_config, caplog):
+    """Regression test for https://github.com/conda/conda-build/issues/2559"""
+    api.render(os.path.join(recipe_dir, '22_run_exports_rerendered_for_other_variants'),
+                    platform='win', arch='64')
+    assert "failed to get install actions, retrying" not in caplog.text