Skip to content

PKG_HASH erroring on undefined when rendering recipe #2257

@beckermr

Description

@beckermr

When only rendering a recipe, the new undefined jinja2 checks error when standard variables that rattler-build is supposed to insert are not present.

I get that the PKG_HASH is not yet defined, but erroring on it being missing is not the right thing to do here. The reason to error on undefined variables is to alert the user of a mistake. However, this is not a mistake by thew user. Instead rattler-build should insert a sentinel value or do something else.

Here is a reproducer:

$ cat slepc.yaml 
schema_version: 1

context:
  version: 3.19.1
  sha256: 280737e9ef762d7f0079ad3ad29913215c799ebf124651c723c1972f71fbc0db
  build: 0

package:
  name: slepc
  version: ${{ version }}

source:
  url: http://slepc.upv.es/download/distrib/slepc-${{ version }}.tar.gz
  sha256: ${{ sha256 }}

build:
  number: ${{ build }}
  string: real_h${{ PKG_HASH }}_${{ build }}
  skip:
    - win

requirements:
  run:
    - petsc
    - suitesparse
  run_exports:
    - ${{ pin_subpackage('slepc', upper_bound='x.x') }}

about:
  summary: SLEPc Scalable Library for Eigenvalue Problem Computations
  license: BSD-2-Clause
  license_file: LICENSE.md
  homepage: http://slepc.upv.es/

extra:
  recipe-maintainers:
    - dalcinl
    - joseeroman
    - minrk
$ rattler-build build --render-only -r slepc.yaml
 Processing recipe at path: /Users/beckermr/Desktop/conda-forge/cf-scripts/tests/test_recipe_yaml/slepc.yaml
Error:   × Failed to render recipe with variants
  ╰─▶ Jinja template error: Failed to render build string template: undefined value (in <string>:1)
    ╭─[/Users/beckermr/Desktop/conda-forge/cf-scripts/tests/test_recipe_yaml/slepc.yaml:18:11]
 17 │   number: ${{ build }}
 18 │   string: real_h${{ PKG_HASH }}_${{ build }}
    ·           ────┬────
    ·               ╰── Failed to render build string template: undefined value (in <string>:1)
 19 │   skip:
    ╰────

cc @wolfv @Hofer-Julian

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions