Skip to content

Commit

Permalink
docs: add env functions to docs (prefix-dev#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv authored Nov 9, 2023
1 parent 2ebd162 commit c2d63f0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 112 deletions.
131 changes: 21 additions & 110 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion docs/recipe_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ available environment variables \<env-vars\>.
Jinja templates are evaluated during the build process. To retrieve a fully
rendered `recipe.yaml`, use the commands/boa-render command.

#### Additional Jinja2 functionality in Boa
#### Additional Jinja2 functionality in rattler-build

Besides the default Jinja2 functionality, additional Jinja functions are
available during the conda-build process: `pin_compatible`, `pin_subpackage`,
Expand Down Expand Up @@ -934,6 +934,22 @@ requirements:
- ${{ pin_compatible('numpy', min_pin='x.x', max_pin='x') }}
```
#### The env Jinja functions
You can access the current environment variables using the `env` object in Jinja.

There are three functions:

- `env.get("ENV_VAR")` will insert the value of "ENV_VAR" into the recipe.
- `env.get_default("ENV_VAR", "undefined")` will insert the value of "ENV_VAR" into the recipe or, if "ENV_VAR" is not defined, the specified default value (in this case "undefined")
- `env.exists("ENV_VAR")` returns a boolean true of false if the env var is set to any value

This can be used for some light templating, e.g.

```yaml
build:
string: ${{ env.get("GIT_BUILD_STRING") }}_${{ PKG_HASH }}
```

Preprocessing selectors
-----------------------
Expand Down
2 changes: 1 addition & 1 deletion rust-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ edition = "2021"
[dependencies]
glob = "0.3.1"
itertools = "0.11.0"
rattler_package_streaming = { git = "https://github.com/mamba-org/rattler.git" }
rattler_package_streaming = { version = "0.11.0", default-features = false }
serde_json = "1.0.108"
sha1 = "0.10.6"

0 comments on commit c2d63f0

Please sign in to comment.