Skip to content

conda_build_config variables have different types in selector expressions and JINJA expressions #5852

@msentissi

Description

@msentissi

Checklist

  • I added a descriptive title
  • I searched open reports and couldn't find a duplicate

What happened?

CBC variables will be strings in JINJA Expressions no matter what type they are in the CBC file. In Selector Expressions, they will be "coerced into a reasonable type", again independent of the type chosen in the CBC file. Other available variables (such as platform booleans: win, unix, etc..) are not affected by this.

Consider the following recipe:

package:
  name: var_is_int # [var == 1]
  name: var_is_str # [var == "1"]
  version: 1.0.0.{{ var == 1 }}

source:
  url: https://github.com/conda-forge/test-feedstock/archive/refs/tags/v1.0.0.tar.gz
  sha256: 1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef

requirements:
  build:
    - python
    - numpy
  run:
    - python
    - numpy

test:
  commands:
    - python -c "import sys; print(sys.version)"
    - python -c "import numpy; print(numpy.__version__)"

And accompanying CBC file:

var:
  - "1"

OR

var:
  - 1

No matter the type chosen for var inr the CBC, conda render will produce:

package:
  name: var_is_int
  version: 1.0.0.False

In other words, var is always an int in the selector expression, and always a str in the JINJA expression.

Conda Info

Conda Config

Conda list

Additional Context

No response

Metadata

Metadata

Assignees

Labels

type::bugdescribes erroneous operation, use severity::* to classify the type

Type

No type

Projects

Status

Done 💪🏾

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions