From 9a6eaea807b9fc75b3f795290d95e613c1c289f0 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 26 Jul 2023 15:32:59 +0200 Subject: [PATCH 1/5] Populate README with channels from conda_build_config.yaml --- README.md | 4 ---- conda_smithy/cli.py | 2 +- conda_smithy/configure_feedstock.py | 29 ++++++++++++++++++++------- conda_smithy/templates/README.md.tmpl | 2 +- tests/test_configure_feedstock.py | 13 ++++-------- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 4627821fd..f013bfcbc 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 cf5558933..10d630aea 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 57cc92907..f18c28c47 100644 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -711,6 +711,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, @@ -720,9 +723,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"): @@ -1584,11 +1585,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()[0]) + 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)] @@ -1620,6 +1633,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: @@ -1795,10 +1809,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": "", @@ -1869,6 +1879,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/tests/test_configure_feedstock.py b/tests/test_configure_feedstock.py index fed0b9877..f0218c19e 100644 --- a/tests/test_configure_feedstock.py +++ b/tests/test_configure_feedstock.py @@ -743,9 +743,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): @@ -753,9 +751,8 @@ 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): @@ -797,9 +794,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): From 5a34aa20f0ea5718a621ad13fc5ca59f72524301 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 26 Jul 2023 17:37:12 +0200 Subject: [PATCH 2/5] Update conda_smithy/configure_feedstock.py Co-authored-by: Isuru Fernando --- conda_smithy/configure_feedstock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index f18c28c47..320ed7d58 100644 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -1595,7 +1595,7 @@ def render_README(jinja_env, forge_config, forge_dir, render_info=None): 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()[0]) + 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"] From aadce20864edaec804ff6b8a6d9abe358254a0d0 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 27 Jul 2023 13:35:25 +0200 Subject: [PATCH 3/5] pre-commit --- conda_smithy/configure_feedstock.py | 2 +- tests/test_configure_feedstock.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index 320ed7d58..71d6407cd 100644 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -1599,7 +1599,7 @@ def render_README(jinja_env, forge_config, forge_dir, render_info=None): if not channel_targets: # default to conda-forge if no channel_targets are specified (shouldn't happen) channel_targets = ["conda-forge main"] - else: + else: # de-duplicate in-order channel_targets = list(dict.fromkeys(channel_targets)) diff --git a/tests/test_configure_feedstock.py b/tests/test_configure_feedstock.py index f0218c19e..f06321c9f 100644 --- a/tests/test_configure_feedstock.py +++ b/tests/test_configure_feedstock.py @@ -754,7 +754,6 @@ def test_conda_forge_yaml_empty(config_yaml): assert load_forge_config()["recipe_dir"] == "recipe" - def test_noarch_platforms_bad_yaml(config_yaml): load_forge_config = lambda: cnfgr_fdstk._load_forge_config( # noqa config_yaml, From baa5121f45e866c0f5f3dc61ee02df77032eabb2 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 17 Oct 2023 09:55:39 +0200 Subject: [PATCH 4/5] Add news --- news/1752-readme-channels | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 news/1752-readme-channels diff --git a/news/1752-readme-channels b/news/1752-readme-channels new file mode 100644 index 000000000..921a60cf9 --- /dev/null +++ b/news/1752-readme-channels @@ -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:** + +* From 97a2c1f0865f36624ea605dac458bd80d04ce665 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Wed, 18 Oct 2023 11:51:40 -0500 Subject: [PATCH 5/5] Rename 1752-readme-channels to 1752-readme-channels.rst --- news/{1752-readme-channels => 1752-readme-channels.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename news/{1752-readme-channels => 1752-readme-channels.rst} (100%) diff --git a/news/1752-readme-channels b/news/1752-readme-channels.rst similarity index 100% rename from news/1752-readme-channels rename to news/1752-readme-channels.rst