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

more calls to flatten_v1_if_else #2212

Merged
merged 1 commit into from
Jan 9, 2025
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
14 changes: 12 additions & 2 deletions conda_smithy/lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
EXPECTED_SECTION_ORDER,
RATTLER_BUILD_TOOL,
find_local_config_file,
flatten_v1_if_else,
get_section,
load_linter_toml_metdata,
)
Expand Down Expand Up @@ -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 {{<one space>var<one space>}}
Expand Down Expand Up @@ -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])
Expand All @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion conda_smithy/linter/lints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
23 changes: 23 additions & 0 deletions news/v1-flatten-pins-more.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* Fix more linter errors for v1 recipes with conditional dependencies (#2212)

**Security:**

* <news item>
18 changes: 12 additions & 6 deletions tests/test_lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
Loading