Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-rendering with conditionally defined Jinja variables fails under conda-build 24.7 #2011

Open
jakirkham opened this issue Aug 3, 2024 · 1 comment

Comments

@jakirkham
Copy link
Member

jakirkham commented Aug 3, 2024

Recently have encountered the following bug when re-rendering with conda-smithy depending on the conda-build version used. This is very likely is a conda-build bug. However conda-build itself does not encounter the issue when building recipes. So it could be how conda-smithy and conda-build interact, which causes the issue

The core of the bug is involves Jinja variables that are conditionally defined (meaning there are cases where they are undefined). Previously if a Jinja variable would be undefined for a certain condition (like an OS), this was not an issue if that condition was skipped. However now the conditionally defined variable is a problem even in case where it is never used

Take this recipe (a boiled down example to show the core bug), version here is conditionally defined. It will only be defined on linux. Otherwise version is undefined. Previously the top-level skip, which limited the build to linux, would have been sufficient to ensure version was defined for the relevant condition. So the version would have been defined anywhere this recipe would build

{% set version = "1" %}  # [linux]

package:
  name: undef_jinja_tst
  # Fails with conda-build 24.7 (works for conda-build 24.5)
  version: {{ version }}
  # Passes with conda-build 24.7
  #version: {{ version }}  # [linux]

build:
  skip: true  # [not linux]

test:
  commands:
    - exit 0

Also when re-rendering this recipe using conda-build version 24.5, this would work ok. However starting with conda-build version 24.7, the following recipe fails to re-render

To workaround this with conda-build version 24.7, it seems one needs to do one of the following:

  1. Add more version definitions for other conditions until it passes (so osx, win, etc.)
  2. Define a fallback for version: Adding this to line 2 {% set version = version|default("") %}
  3. Add selectors to all lines that use version (shown above)

Ideally none of this would be needed. However it appears something has changed about how conda-build renders recipes and where conda-smithy interacts with that rendering functionality. As a result this now produces errors for conditions the recipe cannot actually be built for anyways (because of the skip)

Edit - Also surfaced this upstream: conda/conda#13995 (comment)

@jakirkham
Copy link
Member Author

Looks like this would be addressed in upstream PR: conda/conda-build#5458

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant