diff --git a/README.md b/README.md index 837a85032..8d1925d19 100644 --- a/README.md +++ b/README.md @@ -96,10 +96,6 @@ out of by specifying `--without-anaconda-token`, as such execpted package upload ``` github: user_or_org: YOUR_GITHUB_USER_OR_ORG - channels: - targets: - - - - YOUR_ANACONDA_CHANNEL ``` 6. **Re-render the feedstock:** ``conda smithy rerender --feedstock_directory ./foo-feedstock`` diff --git a/conda_smithy/cli.py b/conda_smithy/cli.py index f46bee960..477d0fbc2 100644 --- a/conda_smithy/cli.py +++ b/conda_smithy/cli.py @@ -141,7 +141,7 @@ def __call__(self, args): ) print( - "\nRepository created, please edit conda-forge.yml to configure the upload channels\n" + "\nRepository created, please edit recipe/conda_build_config.yaml to configure the upload channels\n" "and afterwards call 'conda smithy register-github'" ) diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index f0ecbbc6b..59415c797 100644 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -733,6 +733,9 @@ def _render_ci_provider( if os.path.exists(_recipe_cbc): os.rename(_recipe_cbc, _recipe_cbc + ".conda.smithy.bak") + channel_sources = migrated_combined_variant_spec.get( + "channel_sources", [""] + )[0].split(",") metas = conda_build.api.render( os.path.join(forge_dir, forge_config["recipe_dir"]), platform=platform, @@ -742,9 +745,7 @@ def _render_ci_provider( permit_undefined_jinja=True, finalize=False, bypass_env_check=True, - channel_urls=forge_config.get("channels", {}).get( - "sources", [] - ), + channel_urls=channel_sources, ) finally: if os.path.exists(_recipe_cbc + ".conda.smithy.bak"): @@ -1612,11 +1613,23 @@ def render_README(jinja_env, forge_config, forge_dir, render_info=None): ci_support_path = os.path.join(forge_dir, ".ci_support") variants = [] + channel_targets = [] if os.path.exists(ci_support_path): for filename in os.listdir(ci_support_path): if filename.endswith(".yaml"): variant_name, _ = os.path.splitext(filename) variants.append(variant_name) + with open(os.path.join(ci_support_path, filename)) as fh: + data = yaml.safe_load(fh) + for channel in data.get("channel_targets", ()): + # channel_targets are in the form of "channel_name label" + channel_targets.append(channel.split(" ")) + if not channel_targets: + # default to conda-forge if no channel_targets are specified (shouldn't happen) + channel_targets = ["conda-forge main"] + else: + # de-duplicate in-order + channel_targets = list(dict.fromkeys(channel_targets)) subpackages_metas = OrderedDict((meta.name(), meta) for meta in metas) subpackages_about = [(package_name, package_about)] @@ -1648,6 +1661,7 @@ def render_README(jinja_env, forge_config, forge_dir, render_info=None): ) ) ) + forge_config["channel_targets"] = channel_targets if forge_config["azure"].get("build_id") is None: @@ -1824,10 +1838,6 @@ def _load_forge_config(forge_dir, exclusive_config_file, forge_yml=None): "max_py_ver": "37", "min_r_ver": "34", "max_r_ver": "34", - "channels": { - "sources": ["conda-forge"], - "targets": [["conda-forge", "main"]], - }, "github": { "user_or_org": "conda-forge", "repo_name": "", @@ -1902,6 +1912,11 @@ def _load_forge_config(forge_dir, exclusive_config_file, forge_yml=None): "Setting docker image in conda-forge.yml is removed now." " Use conda_build_config.yaml instead" ) + if file_config.get("channels"): + raise ValueError( + "Setting channels in conda-forge.yml is removed now." + " Use conda_build_config.yaml instead" + ) for plat in ["linux", "osx", "win"]: if config["azure"]["timeout_minutes"] is not None: diff --git a/conda_smithy/templates/README.md.tmpl b/conda_smithy/templates/README.md.tmpl index f12c816be..c00ab4a7c 100644 --- a/conda_smithy/templates/README.md.tmpl +++ b/conda_smithy/templates/README.md.tmpl @@ -1,4 +1,4 @@ -{%- set channel_name = channels.targets[0][0] -%} +{%- set channel_name = channel_targets[0] -%} {#- # -*- mode: jinja -*- -#} diff --git a/news/1752-readme-channels.rst b/news/1752-readme-channels.rst new file mode 100644 index 000000000..921a60cf9 --- /dev/null +++ b/news/1752-readme-channels.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* Use the channels defined in `conda_build_config.yaml` (instead of those in `conda-forge.yml`) to render `README.md`. (#897 via #752) + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/tests/test_configure_feedstock.py b/tests/test_configure_feedstock.py index 59dcd124e..7c8f80ef4 100644 --- a/tests/test_configure_feedstock.py +++ b/tests/test_configure_feedstock.py @@ -750,9 +750,7 @@ def test_conda_forge_yaml_empty(config_yaml): ), ) - assert ["conda-forge", "main"] in load_forge_config()["channels"][ - "targets" - ] + assert load_forge_config()["recipe_dir"] == "recipe" os.unlink(os.path.join(config_yaml, "conda-forge.yml")) with pytest.raises(RuntimeError): @@ -760,9 +758,7 @@ def test_conda_forge_yaml_empty(config_yaml): with open(os.path.join(config_yaml, "conda-forge.yml"), "w"): pass - assert ["conda-forge", "main"] in load_forge_config()["channels"][ - "targets" - ] + assert load_forge_config()["recipe_dir"] == "recipe" def test_noarch_platforms_bad_yaml(config_yaml): @@ -804,9 +800,7 @@ def test_forge_yml_alt_path(config_yaml): with pytest.raises(RuntimeError): load_forge_config(None) - assert ["conda-forge", "main"] in load_forge_config(forge_yml_alt)[ - "channels" - ]["targets"] + assert load_forge_config(forge_yml_alt)["recipe_dir"] == "recipe" def test_cos7_env_render(py_recipe, jinja_env):