diff --git a/recipe/conda_forge_ci_setup/build_utils.py b/recipe/conda_forge_ci_setup/build_utils.py index e760d15c..78058b88 100644 --- a/recipe/conda_forge_ci_setup/build_utils.py +++ b/recipe/conda_forge_ci_setup/build_utils.py @@ -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 = { @@ -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: @@ -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)