Skip to content

feat(tasks): support template strings in env entries #5446

@lucascolley

Description

@lucascolley

Manifest

[workspace]
channels = ["https://prefix.dev/conda-forge"]
platforms = ["osx-arm64"]

[tasks.subroutine]
cmd = "echo $FOOBAR"
env.FOOBAR = "{{ input }}"
args = ["input"]

[tasks.foo]
depends-on = [{ task = "subroutine", args = ["foo"] }]

[tasks.bar]
depends-on = [{ task = "subroutine", args = ["bar"] }]

Expected behaviour

foo task outputs foo, bar task outputs bar.

Actual behaviour

~/sandbox/template-env via 🧚 v0.63.2pixi run foo
✨ Pixi task (subroutine): echo $FOOBAR
{{ input }}

~/sandbox/template-env via 🧚 v0.63.2pixi run bar
✨ Pixi task (subroutine): echo $FOOBAR
{{ input }}

Motivation

This example is trivially solved via templating in cmd instead, but I believe there is a real use-case for this not covered by that:

[feature.xp-tests.tasks._xp-tests]
cmd = "..."
env.SPARSE_BACKEND = "{{ SPARSE_BACKEND }}"
args = [{ arg = "SPARSE_BACKEND", default = "Numba" }]

[feature.xp-tests.tasks.xp-tests-numba]
depends-on = [{ task = "_xp-tests", args = [{ "SPARSE_BACKEND" = "Numba" }] }]

[feature.xp-tests.tasks.xp-tests-finch]
depends-on = [
  "_precompile_finch",
  { task = "_xp-tests", args = [{ "SPARSE_BACKEND" = "Finch" }]},
]

where SPARSE_BACKEND has runtime effects on the _xp-tests command.

Implementation

I think

pub env: Option<IndexMap<String, String>>,
needs to be adjusted to be able to take a template string for env values instead of just String.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions