diff --git a/conda_smithy/lint_recipe.py b/conda_smithy/lint_recipe.py index 1fb1c227b..176152be3 100644 --- a/conda_smithy/lint_recipe.py +++ b/conda_smithy/lint_recipe.py @@ -71,6 +71,7 @@ EXPECTED_SECTION_ORDER, RATTLER_BUILD_TOOL, find_local_config_file, + flatten_v1_if_else, get_section, load_linter_toml_metdata, ) @@ -324,7 +325,11 @@ def lintify_meta_yaml( # 23: non noarch builds shouldn't use version constraints on python and r-base lint_non_noarch_builds( - requirements_section, outputs_section, noarch_value, lints + requirements_section, + outputs_section, + noarch_value, + lints, + recipe_version, ) # 24: jinja2 variable references should be {{var}} @@ -589,8 +594,11 @@ def run_conda_forge_specific( run_reqs += _req specific_hints = (load_linter_toml_metdata() or {}).get("hints", []) + all_reqs = build_reqs + host_reqs + run_reqs + if recipe_version == 1: + all_reqs = flatten_v1_if_else(all_reqs) - for rq in build_reqs + host_reqs + run_reqs: + for rq in all_reqs: dep = rq.split(" ")[0].strip() if dep in specific_hints and specific_hints[dep] not in hints: hints.append(specific_hints[dep]) @@ -613,6 +621,8 @@ def run_conda_forge_specific( host_or_build_reqs = (requirements_section.get("host") or []) or ( requirements_section.get("build") or [] ) + if recipe_version == 1: + host_or_build_reqs = flatten_v1_if_else(host_or_build_reqs) hint_pip_no_build_backend(host_or_build_reqs, recipe_name, hints) for out in outputs_section: if recipe_version == 1: diff --git a/conda_smithy/linter/lints.py b/conda_smithy/linter/lints.py index 0e7c75f64..1dadb7022 100644 --- a/conda_smithy/linter/lints.py +++ b/conda_smithy/linter/lints.py @@ -497,11 +497,14 @@ def lint_single_space_in_pinned_requirements( def lint_non_noarch_builds( - requirements_section, outputs_section, noarch_value, lints + requirements_section, outputs_section, noarch_value, lints, recipe_version ): check_languages = ["python", "r-base"] host_reqs = requirements_section.get("host") or [] run_reqs = requirements_section.get("run") or [] + if recipe_version == 1: + host_reqs = flatten_v1_if_else(host_reqs) + run_reqs = flatten_v1_if_else(run_reqs) for language in check_languages: if noarch_value is None and not outputs_section: filtered_host_reqs = [ diff --git a/news/v1-flatten-pins-more.rst b/news/v1-flatten-pins-more.rst new file mode 100644 index 000000000..8c2d32535 --- /dev/null +++ b/news/v1-flatten-pins-more.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* Fix more linter errors for v1 recipes with conditional dependencies (#2212) + +**Security:** + +* diff --git a/tests/test_lint_recipe.py b/tests/test_lint_recipe.py index fdaeda88a..f469c0289 100644 --- a/tests/test_lint_recipe.py +++ b/tests/test_lint_recipe.py @@ -2754,12 +2754,6 @@ def test_v1_recipes(): lints, hints = linter.main(str(recipe_dir), return_hints=True) assert not lints - with get_recipe_in_dir( - "v1_recipes/recipe-fenics-dolfinx.yaml" - ) as recipe_dir: - lints, hints = linter.main(str(recipe_dir), return_hints=True) - assert not lints - with get_recipe_in_dir("v1_recipes/torchaudio.yaml") as recipe_dir: lints, hints = linter.main(str(recipe_dir), return_hints=True) assert not lints @@ -2773,6 +2767,18 @@ def test_v1_recipes(): assert not lints +def test_v1_recipes_conda_forge(): + with get_recipe_in_dir( + "v1_recipes/recipe-fenics-dolfinx.yaml" + ) as recipe_dir: + lints, hints = linter.main( + str(recipe_dir), return_hints=True, conda_forge=True + ) + assert lints == [ + "The feedstock has no `.ci_support` files and thus will not build any packages." + ] + + def test_v1_recipes_ignore_run_exports(): with get_recipe_in_dir( "v1_recipes/recipe-ignore_run_exports-no-lint.yaml"