Skip to content

Commit

Permalink
Add packages to variants if special selectors used
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
  • Loading branch information
mbargull committed Jan 16, 2024
1 parent f07c0ab commit f5eab4d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
19 changes: 17 additions & 2 deletions conda_build/variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,14 +746,29 @@ def find_used_variables_in_text(variant, recipe_text, selectors_only=False):
]
else:
variant_lines = [
line for line in recipe_lines if v in line.replace("-", "_")
line
for line in recipe_lines
if v in line.replace("-", "_")
or any(v_sel in line for v_sel in PACKAGE_SELECTOR_MAP.get(v, ())
)
]
if not variant_lines:
continue

v_regex = re.escape(v)
# Recognize package-dependent selectors: e.g., "py>2" marks "python" as used.
v_sel_regex = "|".join(
(
v_regex,
*(re.escape(sel) for sel in PACKAGE_SELECTOR_MAP.get(v, ()) if False),
)
)
v_req_regex = "[-_]".join(map(re.escape, v.split("_")))

variant_regex = r"\{\s*(?:pin_[a-z]+\(\s*?['\"])?%s[^'\"]*?\}\}" % v_regex
selector_regex = r"^[^#\[]*?\#?\s\[[^\]]*?(?<![_\w\d])%s[=\s<>!\]]" % v_regex
selector_regex = (
r"^[^#\[]*?\#?\s\[[^\]]*?(?<![_\w\d])(%s)[=\s<>!\]]" % v_sel_regex
)
conditional_regex = (
r"(?:^|[^\{])\{%\s*(?:el)?if\s*.*" + v_regex + r"\s*(?:[^%]*?)?%\}"
)
Expand Down
19 changes: 19 additions & 0 deletions news/5139-special-selector-variants
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* Add python (et al.) to used variants even if only referenced via special selectors. (#5139)

### Bug fixes

* <news item>

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>

0 comments on commit f5eab4d

Please sign in to comment.