Skip to content

Commit

Permalink
simplify comment-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Nov 14, 2021
1 parent 089ae8c commit c7b70ad
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions conda_smithy/configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,15 +595,11 @@ def _render_ci_provider(
os.path.join(forge_dir, forge_config["recipe_dir"], "meta.yaml")
) as f:
meta_lines = f.readlines()
# looking for `compiler('cuda')` with both quote variants
pat = re.compile(r".*compiler\((\"cuda\"|\'cuda\')\).*")
# looking for `compiler('cuda')` with both quote variants;
# do not match if there is a `#` somewhere before on the line
pat = re.compile(r"^[^\#]*compiler\((\"cuda\"|\'cuda\')\).*")
for ml in meta_lines:
if pat.match(ml):
# since python re-module does not support variable-length
# lookbehind, manually detect if line contains a comment,
# and if `compiler('cuda')` appears _before_ comment-sign.
if '#' in ml and not pat.match(ml.split("#")[0]):
continue
os.environ["CF_CUDA_ENABLED"] = "True"

config = conda_build.config.get_or_merge_config(
Expand Down

0 comments on commit c7b70ad

Please sign in to comment.