Skip to content

Commit

Permalink
Fix flattening nested if/else blocks
Browse files Browse the repository at this point in the history
Probably fixes conda-forge#2165
  • Loading branch information
mgorny committed Dec 26, 2024
1 parent ea94be1 commit 2041df2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions conda_smithy/linter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ def flatten_v1_if_else(requirements: list[str | dict]) -> list[str]:
flattened_requirements = []
for req in requirements:
if isinstance(req, dict):
flattened_requirements.extend(req["then"])
flattened_requirements.extend(req.get("else") or [])
flattened_requirements.extend(flatten_v1_if_else(req["then"]))
flattened_requirements.extend(flatten_v1_if_else(req.get("else") or []))
else:
flattened_requirements.append(req)
return flattened_requirements
1 change: 1 addition & 0 deletions news/fix-if-else-in-run.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
**Fixed:**

* Fix handling ``if``/``else`` blocks in ``run`` and ``run_constraints`` requirements, for v1 recipes (#2197)
* Fix flattening nested ``if``/``else`` blocks in v1 recipes (#2197)

**Security:**

Expand Down
12 changes: 6 additions & 6 deletions tests/recipes/v1_recipes/torchvision.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,18 @@ outputs:
- ${{ compiler('cuda') }}
# avoid nested conditions because of
# https://github.com/conda-forge/conda-smithy/issues/2165
- if: build_platform != target_platform and cuda_compiler_version != "None"
then:
- libcublas-dev
- libcusolver-dev
- libcusparse-dev
- libnvjpeg-dev
- if: build_platform != target_platform
then:
- python
- cross-python_${{ target_platform }}
# - numpy
- pytorch ${{ compatible_pytorch }}.* [build=${{ torch_proc_type }}*]
- if: cuda_compiler_version != "None"
then:
- libcublas-dev
- libcusolver-dev
- libcusparse-dev
- libnvjpeg-dev
host:
- python
# - numpy
Expand Down

0 comments on commit 2041df2

Please sign in to comment.