Repository: conda/conda-build

Issue:
metapackage does not seem to accept channel arguments, but fails if depenencies are in non-default channel
example:

```
conda metapackage acme-unified 1.1  --build-number 0 --dependencies "uvcdat ==2.10" "cibots ==0.2" "cdp ==1.0.3" "output_viewer ==1.2.2" "netCDF4 ==1.2.7" "xarray ==0.9.5" "dask ==0.14.3" "bottleneck ==1.0.6" "lxml ==3.7.3" "nco ==4.6.7" "sympy ==1.0" "pyproj ==1.9.5.1" "pytest ==3.0.7" "shapely ==1.5.17" "cartopy ==0.15.1" pyevtk progressbar scitools
```
fails with:

```
> conda metapackage acme-unified 1.1  --build-number 0 --dependencies "uvcdat ==2.10" "cibots ==0.2" "cdp ==1.0.3" "output_viewer ==1.2.2" "netCDF4 ==1.2.7" "xarray ==0.9.5" "dask ==0.14.3" "bottleneck ==1.0.6" "lxml ==3.7.3" "nco ==4.6.7" "sympy ==1.0" "pyproj ==1.9.5.1" "pytest ==3.0.7" "shapely ==1.5.17" "cartopy ==0.15.1" pyevtk progressbar scitools
Attempting to finalize metadata for acme-unified
INFO:conda_build.metadata:Attempting to finalize metadata for acme-unified
BUILD START: [u'acme-unified-1.1-hdfe7718_0.tar.bz2']

Leaving build/test directories:
  Work:	 ../../home/doutriaux1/anaconda2/conda-bld/acme-unified_1500932469544/work 
  Test:	 ../../home/doutriaux1/anaconda2/conda-bld/acme-unified_1500932469544/test_tmp 
Leaving build/test environments:
  Test:	source activate  ../../home/doutriaux1/anaconda2/conda-bld/acme-unified_1500932469544/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p 
  Build:	source activate  ../../home/doutriaux1/anaconda2/conda-bld/acme-unified_1500932469544/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac 


Traceback (most recent call last):
  File "/home/doutriaux1/anaconda2/bin/conda-metapackage", line 6, in <module>
    sys.exit(conda_build.cli.main_metapackage.main())
  File "/home/doutriaux1/anaconda2/lib/python2.7/site-packages/conda_build/cli/main_metapackage.py", line 118, in main
    return execute(sys.argv[1:])
  File "/home/doutriaux1/anaconda2/lib/python2.7/site-packages/conda_build/cli/main_metapackage.py", line 114, in execute
    api.create_metapackage(**args.__dict__)
  File "/home/doutriaux1/anaconda2/lib/python2.7/site-packages/conda_build/api.py", line 347, in create_metapackage
    license_name=license_name, summary=summary, config=config)
  File "/home/doutriaux1/anaconda2/lib/python2.7/site-packages/conda_build/metapackage.py", line 29, in create_metapackage
    return build(m, config=config, need_source_download=False)
  File "/home/doutriaux1/anaconda2/lib/python2.7/site-packages/conda_build/api.py", line 184, in build
    need_source_download=need_source_download, config=config, variants=variants)
  File "/home/doutriaux1/anaconda2/lib/python2.7/site-packages/conda_build/build.py", line 1633, in build_tree
    notest=notest,
  File "/home/doutriaux1/anaconda2/lib/python2.7/site-packages/conda_build/build.py", line 980, in build
    raise e
conda_build.exceptions.DependencyNeedsBuildingError: Unsatisfiable dependencies for platform linux-64: set(['netCDF4', 'output_viewer', 'cartopy', 'uvcdat', 'cdp', 'nco', 'cibots', 'bottleneck', 'scitools', 'pyevtk', 'shapely'])
```

On a linux system using latest conda and conda-build

originally at:
https://github.com/conda/conda/issues/5720#issuecomment-335941008

putting channels in conda defaults works, but it is a persistent thing which is annoying.


Discussion:
It doesn't look like channels are supported: https://github.com/conda/conda-build/blob/master/conda_build/cli/main_metapackage.py

However, I agree that they should be.  I'll try to add it sometime soon.
I guess one other really tricky thing about this is that the metapackage doesn't retain your channel list.  You need to pass compatible ``-c`` arguments both at build time and at install time.  Conda 4.4 allows per-package channel specs, which will dramatically improve this, but we still need to figure out how to fit them into conda-build.

Resolving patch:
diff --git a/conda_build/cli/main_metapackage.py b/conda_build/cli/main_metapackage.py
--- a/conda_build/cli/main_metapackage.py
+++ b/conda_build/cli/main_metapackage.py
@@ -12,6 +12,7 @@
 
 from conda_build.conda_interface import binstar_upload
 from conda_build.conda_interface import ArgumentParser
+from conda_build.conda_interface import add_parser_channels
 from conda_build import api
 
 logging.basicConfig(level=logging.INFO)
@@ -105,13 +106,15 @@ def parse_args(args):
         bsdiff4 that calls bsdiff4.cli.main_bsdiff4(). """,
     )
 
+    add_parser_channels(p)
     args = p.parse_args(args)
     return p, args
 
 
 def execute(args):
     _, args = parse_args(args)
-    api.create_metapackage(**args.__dict__)
+    channel_urls = args.__dict__.get('channel') or args.__dict__.get('channels') or ()
+    api.create_metapackage(channel_urls=channel_urls, **args.__dict__)
 
 
 def main():


Test patch: