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

Allow some condarc values in conda-forge.yml #364

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
41 changes: 39 additions & 2 deletions recipe/conda_forge_ci_setup/build_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,32 @@
}
}

cf_allowed_condarc_keys = {
"allow_softlinks",
"always_copy",
"always_softlink",
# "conda_build" is handled separately
"default_threads",
"envvars_force_uppercase",
"execute_threads",
"extra_safety_checks",
"json",
"number_channel_notices",
"path_conflict",
"quiet",
"remote_backoff_factor",
"remote_connect_timeout_secs",
"remote_max_retries",
"repodata_use_zst",
"report_errors",
"safety_checks",
"separate_format_cache",
"shortcuts",
"unsatisfiable_hints",
"unsatisfiable_hints_check_depth",
"verify_threads",
}

cf_conda_build_defaults = {"pkg_format": "2", "zstd_compression_level": 19}

DEFAULTS_ALLOWED_FEEDSTOCKS = {
Expand Down Expand Up @@ -113,12 +139,23 @@ def fail_if_travis_not_allowed_for_arch(config_file, feedstock_root):
raise RuntimeError("Travis CI cannot be used on x86_64 in conda-forge!")


def maybe_use_dot_conda(feedstock_root):
def apply_cf_yml_condarc_settings(feedstock_root):
"""Maybe set the .condarc to use .conda files."""
if os.path.exists(os.path.join(feedstock_root, "conda-forge.yml")):
with open(os.path.join(feedstock_root, "conda-forge.yml")) as f:
repo_config = safe_load(f)

conda_config_vars = repo_config.get("conda", {})
disallowed_keys = conda_config_vars.keys() - cf_allowed_condarc_keys
if disallowed_keys:
raise RuntimeError(f"""conda-forge.yml's "conda" key had the following disallowed values: {", ".join(disallowed_keys)}""")
for k, v in conda_config_vars.items():
if v is not None:
call([
"conda", "config", "--env", "--set",
f"{k}", str(v)
])

conda_build_config_vars = repo_config.get("conda_build", {})
for k, v in cf_conda_build_defaults.items():
if k not in conda_build_config_vars:
Expand All @@ -142,7 +179,7 @@ def setup_conda_rc(feedstock_root, recipe_root, config_file):

fail_if_travis_not_allowed_for_arch(config_file, feedstock_root)

maybe_use_dot_conda(feedstock_root)
apply_cf_yml_condarc_settings(feedstock_root)

with open(config_file) as f:
specific_config = safe_load(f)
Expand Down