Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate README with channels from conda_build_config.yaml #1752

Merged
merged 5 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand Down
2 changes: 1 addition & 1 deletion conda_smithy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
)

Expand Down
29 changes: 22 additions & 7 deletions conda_smithy/configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this change. I would appreciate some more info if someone knows!

)
finally:
if os.path.exists(_recipe_cbc + ".conda.smithy.bak"):
Expand Down Expand Up @@ -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(" "))
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)]
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion conda_smithy/templates/README.md.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{%- set channel_name = channels.targets[0][0] -%}
{%- set channel_name = channel_targets[0] -%}
{#-
# -*- mode: jinja -*-
-#}
Expand Down
23 changes: 23 additions & 0 deletions news/1752-readme-channels.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**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:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
12 changes: 3 additions & 9 deletions tests/test_configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,19 +743,15 @@ 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):
load_forge_config()

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):
Expand Down Expand Up @@ -797,9 +793,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):
Expand Down
Loading