We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `conda_build/cli/main_metapackage.py`
Content:
```
1 # (c) Continuum Analytics, Inc. / http://continuum.io
2 # All Rights Reserved
3 #
4 # conda is distributed under the terms of the BSD 3-clause license.
5 # Consult LICENSE.txt or http://opensource.org/licenses/BSD-3-Clause.
6 
7 from __future__ import absolute_import, division, print_function
8 
9 import argparse
10 import logging
11 import sys
12 
13 from conda_build.conda_interface import binstar_upload
14 from conda_build.conda_interface import ArgumentParser
15 from conda_build import api
16 
17 logging.basicConfig(level=logging.INFO)
18 
19 
20 def parse_args(args):
21     p = ArgumentParser(
22         description='''
23 Tool for building conda metapackages.  A metapackage is a package with no
24 files, only metadata.  They are typically used to collect several packages
25 together into a single package via dependencies.
26 
27 NOTE: Metapackages can also be created by creating a recipe with the necessary
28 metadata in the meta.yaml, but a metapackage can be created entirely from the
29 command line with the conda metapackage command.
30 ''',
31     )
32 
33     p.add_argument(
34         "--no-anaconda-upload",
35         action="store_false",
36         help="Do not ask to upload the package to anaconda.org.",
37         dest='anaconda_upload',
38         default=binstar_upload,
39     )
40     p.add_argument(
41         "--no-binstar-upload",
42         action="store_false",
43         help=argparse.SUPPRESS,
44         dest='anaconda_upload',
45         default=binstar_upload,
46     )
47     p.add_argument(
48         '--token',
49         help="Token to pass through to anaconda upload"
50     )
51     p.add_argument(
52         '--user',
53         help="User/organization to upload packages to on anaconda.org"
54     )
55     p.add_argument(
56         "name",
57         help="Name of the created package.",
58     )
59     p.add_argument(
60         "version",
61         help="Version of the created package.",
62     )
63     p.add_argument(
64         "--build-number",
65         type=int,
66         default=0,
67         help="Build number for the package (default is 0).",
68     )
69     p.add_argument(
70         "--build-string",
71         default=None,
72         help="Build string for the package (default is automatically generated).",
73     )
74     p.add_argument(
75         "--dependencies", "-d",
76         nargs='*',
77         default=(),
78         help="""The dependencies of the package. To specify a version restriction for a
79         dependency, wrap the dependency in quotes, like 'package >=2.0'.""",
80     )
81     p.add_argument(
82         "--home",
83         help="The homepage for the metapackage.",
84 
85     )
86     p.add_argument(
87         "--license",
88         help="The license of the metapackage.",
89         dest='license_name'
90     )
91     p.add_argument(
92         "--summary",
93         help="""Summary of the package.  Pass this in as a string on the command
94         line, like --summary 'A metapackage for X'. It is recommended to use
95         single quotes if you are not doing variable substitution to avoid
96         interpretation of special characters.""",
97     )
98     p.add_argument(
99         "--entry-points",
100         nargs='*',
101         default=(),
102         help="""Python entry points to create automatically. They should use the same
103         syntax as in the meta.yaml of a recipe, e.g., --entry-points
104         bsdiff4=bsdiff4.cli:main_bsdiff4 will create an entry point called
105         bsdiff4 that calls bsdiff4.cli.main_bsdiff4(). """,
106     )
107 
108     args = p.parse_args(args)
109     return p, args
110 
111 
112 def execute(args):
113     _, args = parse_args(args)
114     api.create_metapackage(**args.__dict__)
115 
116 
117 def main():
118     return execute(sys.argv[1:])
119
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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 @@
         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():

{"golden_diff": "diff --git a/conda_build/cli/main_metapackage.py b/conda_build/cli/main_metapackage.py\n--- a/conda_build/cli/main_metapackage.py\n+++ b/conda_build/cli/main_metapackage.py\n@@ -12,6 +12,7 @@\n \n from conda_build.conda_interface import binstar_upload\n from conda_build.conda_interface import ArgumentParser\n+from conda_build.conda_interface import add_parser_channels\n from conda_build import api\n \n logging.basicConfig(level=logging.INFO)\n@@ -105,13 +106,15 @@\n         bsdiff4 that calls bsdiff4.cli.main_bsdiff4(). \"\"\",\n     )\n \n+    add_parser_channels(p)\n     args = p.parse_args(args)\n     return p, args\n \n \n def execute(args):\n     _, args = parse_args(args)\n-    api.create_metapackage(**args.__dict__)\n+    channel_urls = args.__dict__.get('channel') or args.__dict__.get('channels') or ()\n+    api.create_metapackage(channel_urls=channel_urls, **args.__dict__)\n \n \n def main():\n", "issue": "metapackage does not seem to accept channel arguments, but fails if depenencies are in non-default channel\nexample:\r\n\r\n```\r\nconda 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\r\n```\r\nfails with:\r\n\r\n```\r\n> 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\r\nAttempting to finalize metadata for acme-unified\r\nINFO:conda_build.metadata:Attempting to finalize metadata for acme-unified\r\nBUILD START: [u'acme-unified-1.1-hdfe7718_0.tar.bz2']\r\n\r\nLeaving build/test directories:\r\n  Work:\t ../../home/doutriaux1/anaconda2/conda-bld/acme-unified_1500932469544/work \r\n  Test:\t ../../home/doutriaux1/anaconda2/conda-bld/acme-unified_1500932469544/test_tmp \r\nLeaving build/test environments:\r\n  Test:\tsource 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 \r\n  Build:\tsource 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 \r\n\r\n\r\nTraceback (most recent call last):\r\n  File \"/home/doutriaux1/anaconda2/bin/conda-metapackage\", line 6, in <module>\r\n    sys.exit(conda_build.cli.main_metapackage.main())\r\n  File \"/home/doutriaux1/anaconda2/lib/python2.7/site-packages/conda_build/cli/main_metapackage.py\", line 118, in main\r\n    return execute(sys.argv[1:])\r\n  File \"/home/doutriaux1/anaconda2/lib/python2.7/site-packages/conda_build/cli/main_metapackage.py\", line 114, in execute\r\n    api.create_metapackage(**args.__dict__)\r\n  File \"/home/doutriaux1/anaconda2/lib/python2.7/site-packages/conda_build/api.py\", line 347, in create_metapackage\r\n    license_name=license_name, summary=summary, config=config)\r\n  File \"/home/doutriaux1/anaconda2/lib/python2.7/site-packages/conda_build/metapackage.py\", line 29, in create_metapackage\r\n    return build(m, config=config, need_source_download=False)\r\n  File \"/home/doutriaux1/anaconda2/lib/python2.7/site-packages/conda_build/api.py\", line 184, in build\r\n    need_source_download=need_source_download, config=config, variants=variants)\r\n  File \"/home/doutriaux1/anaconda2/lib/python2.7/site-packages/conda_build/build.py\", line 1633, in build_tree\r\n    notest=notest,\r\n  File \"/home/doutriaux1/anaconda2/lib/python2.7/site-packages/conda_build/build.py\", line 980, in build\r\n    raise e\r\nconda_build.exceptions.DependencyNeedsBuildingError: Unsatisfiable dependencies for platform linux-64: set(['netCDF4', 'output_viewer', 'cartopy', 'uvcdat', 'cdp', 'nco', 'cibots', 'bottleneck', 'scitools', 'pyevtk', 'shapely'])\r\n```\r\n\r\nOn a linux system using latest conda and conda-build\r\n\r\noriginally at:\r\nhttps://github.com/conda/conda/issues/5720#issuecomment-335941008\r\n\r\nputting channels in conda defaults works, but it is a persistent thing which is annoying.\n", "before_files": [{"content": "# (c) Continuum Analytics, Inc. / http://continuum.io\n# All Rights Reserved\n#\n# conda is distributed under the terms of the BSD 3-clause license.\n# Consult LICENSE.txt or http://opensource.org/licenses/BSD-3-Clause.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport argparse\nimport logging\nimport sys\n\nfrom conda_build.conda_interface import binstar_upload\nfrom conda_build.conda_interface import ArgumentParser\nfrom conda_build import api\n\nlogging.basicConfig(level=logging.INFO)\n\n\ndef parse_args(args):\n    p = ArgumentParser(\n        description='''\nTool for building conda metapackages.  A metapackage is a package with no\nfiles, only metadata.  They are typically used to collect several packages\ntogether into a single package via dependencies.\n\nNOTE: Metapackages can also be created by creating a recipe with the necessary\nmetadata in the meta.yaml, but a metapackage can be created entirely from the\ncommand line with the conda metapackage command.\n''',\n    )\n\n    p.add_argument(\n        \"--no-anaconda-upload\",\n        action=\"store_false\",\n        help=\"Do not ask to upload the package to anaconda.org.\",\n        dest='anaconda_upload',\n        default=binstar_upload,\n    )\n    p.add_argument(\n        \"--no-binstar-upload\",\n        action=\"store_false\",\n        help=argparse.SUPPRESS,\n        dest='anaconda_upload',\n        default=binstar_upload,\n    )\n    p.add_argument(\n        '--token',\n        help=\"Token to pass through to anaconda upload\"\n    )\n    p.add_argument(\n        '--user',\n        help=\"User/organization to upload packages to on anaconda.org\"\n    )\n    p.add_argument(\n        \"name\",\n        help=\"Name of the created package.\",\n    )\n    p.add_argument(\n        \"version\",\n        help=\"Version of the created package.\",\n    )\n    p.add_argument(\n        \"--build-number\",\n        type=int,\n        default=0,\n        help=\"Build number for the package (default is 0).\",\n    )\n    p.add_argument(\n        \"--build-string\",\n        default=None,\n        help=\"Build string for the package (default is automatically generated).\",\n    )\n    p.add_argument(\n        \"--dependencies\", \"-d\",\n        nargs='*',\n        default=(),\n        help=\"\"\"The dependencies of the package. To specify a version restriction for a\n        dependency, wrap the dependency in quotes, like 'package >=2.0'.\"\"\",\n    )\n    p.add_argument(\n        \"--home\",\n        help=\"The homepage for the metapackage.\",\n\n    )\n    p.add_argument(\n        \"--license\",\n        help=\"The license of the metapackage.\",\n        dest='license_name'\n    )\n    p.add_argument(\n        \"--summary\",\n        help=\"\"\"Summary of the package.  Pass this in as a string on the command\n        line, like --summary 'A metapackage for X'. It is recommended to use\n        single quotes if you are not doing variable substitution to avoid\n        interpretation of special characters.\"\"\",\n    )\n    p.add_argument(\n        \"--entry-points\",\n        nargs='*',\n        default=(),\n        help=\"\"\"Python entry points to create automatically. They should use the same\n        syntax as in the meta.yaml of a recipe, e.g., --entry-points\n        bsdiff4=bsdiff4.cli:main_bsdiff4 will create an entry point called\n        bsdiff4 that calls bsdiff4.cli.main_bsdiff4(). \"\"\",\n    )\n\n    args = p.parse_args(args)\n    return p, args\n\n\ndef execute(args):\n    _, args = parse_args(args)\n    api.create_metapackage(**args.__dict__)\n\n\ndef main():\n    return execute(sys.argv[1:])\n", "path": "conda_build/cli/main_metapackage.py"}], "after_files": [{"content": "# (c) Continuum Analytics, Inc. / http://continuum.io\n# All Rights Reserved\n#\n# conda is distributed under the terms of the BSD 3-clause license.\n# Consult LICENSE.txt or http://opensource.org/licenses/BSD-3-Clause.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport argparse\nimport logging\nimport sys\n\nfrom conda_build.conda_interface import binstar_upload\nfrom conda_build.conda_interface import ArgumentParser\nfrom conda_build.conda_interface import add_parser_channels\nfrom conda_build import api\n\nlogging.basicConfig(level=logging.INFO)\n\n\ndef parse_args(args):\n    p = ArgumentParser(\n        description='''\nTool for building conda metapackages.  A metapackage is a package with no\nfiles, only metadata.  They are typically used to collect several packages\ntogether into a single package via dependencies.\n\nNOTE: Metapackages can also be created by creating a recipe with the necessary\nmetadata in the meta.yaml, but a metapackage can be created entirely from the\ncommand line with the conda metapackage command.\n''',\n    )\n\n    p.add_argument(\n        \"--no-anaconda-upload\",\n        action=\"store_false\",\n        help=\"Do not ask to upload the package to anaconda.org.\",\n        dest='anaconda_upload',\n        default=binstar_upload,\n    )\n    p.add_argument(\n        \"--no-binstar-upload\",\n        action=\"store_false\",\n        help=argparse.SUPPRESS,\n        dest='anaconda_upload',\n        default=binstar_upload,\n    )\n    p.add_argument(\n        '--token',\n        help=\"Token to pass through to anaconda upload\"\n    )\n    p.add_argument(\n        '--user',\n        help=\"User/organization to upload packages to on anaconda.org\"\n    )\n    p.add_argument(\n        \"name\",\n        help=\"Name of the created package.\",\n    )\n    p.add_argument(\n        \"version\",\n        help=\"Version of the created package.\",\n    )\n    p.add_argument(\n        \"--build-number\",\n        type=int,\n        default=0,\n        help=\"Build number for the package (default is 0).\",\n    )\n    p.add_argument(\n        \"--build-string\",\n        default=None,\n        help=\"Build string for the package (default is automatically generated).\",\n    )\n    p.add_argument(\n        \"--dependencies\", \"-d\",\n        nargs='*',\n        default=(),\n        help=\"\"\"The dependencies of the package. To specify a version restriction for a\n        dependency, wrap the dependency in quotes, like 'package >=2.0'.\"\"\",\n    )\n    p.add_argument(\n        \"--home\",\n        help=\"The homepage for the metapackage.\",\n\n    )\n    p.add_argument(\n        \"--license\",\n        help=\"The license of the metapackage.\",\n        dest='license_name'\n    )\n    p.add_argument(\n        \"--summary\",\n        help=\"\"\"Summary of the package.  Pass this in as a string on the command\n        line, like --summary 'A metapackage for X'. It is recommended to use\n        single quotes if you are not doing variable substitution to avoid\n        interpretation of special characters.\"\"\",\n    )\n    p.add_argument(\n        \"--entry-points\",\n        nargs='*',\n        default=(),\n        help=\"\"\"Python entry points to create automatically. They should use the same\n        syntax as in the meta.yaml of a recipe, e.g., --entry-points\n        bsdiff4=bsdiff4.cli:main_bsdiff4 will create an entry point called\n        bsdiff4 that calls bsdiff4.cli.main_bsdiff4(). \"\"\",\n    )\n\n    add_parser_channels(p)\n    args = p.parse_args(args)\n    return p, args\n\n\ndef execute(args):\n    _, args = parse_args(args)\n    channel_urls = args.__dict__.get('channel') or args.__dict__.get('channels') or ()\n    api.create_metapackage(channel_urls=channel_urls, **args.__dict__)\n\n\ndef main():\n    return execute(sys.argv[1:])\n", "path": "conda_build/cli/main_metapackage.py"}]}