Skip to content

Commit 1f65810

Browse files
authored
fix: coerce true/false strings to bools in jinja2
Add option to coerce string 'true'/'false' to boolean.
1 parent 6bef51f commit 1f65810

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

conda_build/environ.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ def get_dict(
352352
skip_build_id=False,
353353
escape_backslash=False,
354354
variant=None,
355+
true_false_as_bool=False,
355356
):
356357
if not prefix:
357358
prefix = m.config.host_prefix
@@ -379,7 +380,11 @@ def get_dict(
379380
variant = variant or m.config.variant
380381
for k, v in variant.items():
381382
if not for_env or (k.upper() not in d and k.upper() not in LANGUAGES):
382-
d[k] = v
383+
# coerce true and false as strings to bools
384+
if true_false_as_bool and isinstance(v, str) and v.lower() in ['true', 'false']:
385+
d[k] = v.lower() == 'true'
386+
else:
387+
d[k] = v
383388
return d
384389

385390

0 commit comments

Comments
 (0)