Skip to content

Commit

Permalink
Avoid undefined jinja errors for skipped recipes (#5458)
Browse files Browse the repository at this point in the history
  • Loading branch information
msarahan authored Sep 4, 2024
1 parent f702c3a commit 23c5797
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions conda_build/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,10 @@ def parse_until_resolved(
)
self.final = final

if self.skip():
self.final = True
return

# recursively parse again so long as each iteration has fewer undefined jinja variables
undefined_jinja_vars = ()
while set(undefined_jinja_vars) != set(self.undefined_jinja_vars):
Expand Down
19 changes: 19 additions & 0 deletions news/5458-avoid-undefined-jinja-in-skipped
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Allow undefined jinja variables when a particular metadata block evaluates as skipped. (#5458)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
24 changes: 24 additions & 0 deletions tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,3 +623,27 @@ def test_parse_until_resolved(testing_metadata: MetaData, tmp_path: Path) -> Non
match=("Failed to render jinja template"),
):
testing_metadata.parse_until_resolved()


def test_parse_until_resolved_skip_avoids_undefined_jinja(
testing_metadata: MetaData, tmp_path: Path
) -> None:
(recipe := tmp_path / (name := "meta.yaml")).write_text(
"""
package:
name: dummy
version: {{version}}
build:
skip: True
"""
)
testing_metadata._meta_path = recipe
testing_metadata._meta_name = name

# because skip is True, we should not error out here - so no exception should be raised
try:
testing_metadata.parse_until_resolved()
except CondaBuildUserError:
pytest.fail(
"Undefined variable caused error, even though this build is skipped"
)

0 comments on commit 23c5797

Please sign in to comment.