Repository: conda/conda-build

Issue:
conda_build_config.yaml affecting run specs?
```
(jaegar) [root@80ca205d2ef4 dummy]# cat meta.yaml 
package:
  name: dummy
  version: 1.0

requirements:
  run:
    - numpy
    - python

# I deliberately added a version for which there is no conda package in defaults
(jaegar) [root@80ca205d2ef4 dummy]# cat conda_build_config.yaml 
numpy:
  - 1.5.0
```
Build fails with:
```
Traceback (most recent call last):
  File "/opt/conda/lib/python3.6/site-packages/conda_build/environ.py", line 691, in get_install_actions
    actions = install_actions(prefix, index, specs, force=True)
  File "/opt/conda/lib/python3.6/site-packages/conda/plan.py", line 461, in install_actions
    update_deps, pinned)
  File "/opt/conda/lib/python3.6/site-packages/conda/plan.py", line 631, in get_actions_for_dists
    pkgs = r.install(specs, installed, update_deps=update_deps)
  File "/opt/conda/lib/python3.6/site-packages/conda/resolve.py", line 813, in install
    pkgs = self.solve(specs, returnall=returnall)
  File "/opt/conda/lib/python3.6/site-packages/conda/resolve.py", line 853, in solve
    reduced_index = self.get_reduced_index(specs)
  File "/opt/conda/lib/python3.6/site-packages/conda/resolve.py", line 374, in get_reduced_index
    specs, features = self.verify_specs(specs)
  File "/opt/conda/lib/python3.6/site-packages/conda/resolve.py", line 300, in verify_specs
    raise ResolvePackageNotFound(bad_deps)
conda.exceptions.ResolvePackageNotFound: 
  - numpy 1.5.0.*
```

IIUC, stuff in conda_build_config.yaml shouldn't be affecting run specs.


Discussion:
This comes in because of https://github.com/conda/conda-build/blob/master/conda_build/build.py#L985

It's not being permanently inserted into the recipe, but it does affect the test for what's installable for test time.  We discussed numpy in your example on flowdock.  I thought the behavior was clearly wrong there.  In looking at this, I'm not so sure.  It is important to impose these variant versions, so that the satisfiability test reflects all of the configured conda_build_config.yaml settings.  Your problem was with pyopengl was that py3.6 builds exist, but they're only built against numpy 1.13, not the new standard of build against an old numpy and gain forward compatibility.

To restate what conda-build's behavior is here:
- conda_build_config.yaml is establishing baseline compatibility
- you have previously built packages that do not conform to this compatibility
- conda-build is refusing to build something that depends on those previously built packages, because they do not conform to the baseline compatibility.

I think the answer here is not a fix to conda-build, but a rebuild of pyopengl.  If you need help on editing the pyopengl recipe, let me know.  You need to get rid of ``numpy x.x`` and replace it with ``numpy`` in build deps and ``{{ pin_compatible('numpy') }}`` in the run deps.
Reopening.  This is a special case - where things in run are not present in build.  It is valid, and needs a fix.

Resolving patch:
diff --git a/conda_build/utils.py b/conda_build/utils.py
--- a/conda_build/utils.py
+++ b/conda_build/utils.py
@@ -1270,13 +1270,14 @@ def ensure_valid_spec(spec, warn=False):
 
 
 def insert_variant_versions(requirements_dict, variant, env):
+    build_deps = requirements_dict.get('build', []) + requirements_dict.get('host', [])
     reqs = requirements_dict.get(env, [])
     for key, val in variant.items():
         regex = re.compile(r'^(%s)(?:\s*$)' % key.replace('_', '[-_]'))
         matches = [regex.match(pkg) for pkg in reqs]
         if any(matches):
             for i, x in enumerate(matches):
-                if x:
+                if x and (env in ('build', 'host') or x.group(1) in build_deps):
                     del reqs[i]
                     reqs.insert(i, ensure_valid_spec(' '.join((x.group(1), val))))
 


Test patch: