Skip to content

Commit

Permalink
docs: document jinja functions (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
swarnimarun authored Jan 18, 2024
1 parent 85d9547 commit ee47240
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
41 changes: 33 additions & 8 deletions docs/recipe_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -970,17 +970,19 @@ package:
name: ${{ name }} # correct
```

For more information, see the [Jinja2 template
documentation](http://jinja.pocoo.org/docs/dev/templates/) and the list of
available environment variables \<env-vars\>.
For more information, see the [Jinja template
documentation](https://jinja.palletsprojects.com/en/3.1.x/) and the list of
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.
Jinja templates are evaluated during the build process.
<!-- TODO: implement the command to do below
To retrieve a fully rendered `recipe.yaml`, use the `` command.
-->

#### 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`,
available during the rattler-build process: `pin_compatible`, `pin_subpackage`,
and `compiler`.

The compiler function takes `c`, `cxx`, `fortran` and other values as argument
Expand All @@ -997,7 +999,7 @@ the supplied parameters.
Similarly, the `pin_compatible` function will pin a package according to the
specified rules.
### Pin expressions
#### Pin expressions
`rattler-build` knows pin expressions. A pin expression can have a `min_pin`,
`max_pin` and `exact` value. A `max_pin` and `min_pin` are specified with a
Expand Down Expand Up @@ -1069,6 +1071,29 @@ build:
string: ${{ env.get("GIT_BUILD_STRING") }}_${{ PKG_HASH }}
```

#### `cmp` function

This function matches the first argument(package's MatchSpec) against the second argument(the version spec) and returns the resulting boolean.

```yaml
cmp(python, '>=3.4')
```

Example: [cmp usage example](https://github.com/prefix-dev/rattler-build/tree/main/examples/cmpcdt/recipe.yaml)

#### `cdt` function

This function helps add Core Dependency Tree packages as dependencies by converting packages as required according to hard-coded logic.

```yaml
# on x86_64 system
cdt('package-name') # outputs: package-name-cos6-x86_64
# on aarch64 system
cdt('package-name') # outputs: package-name-cos6-aarch64
```

Example: [cdt usage example](https://github.com/prefix-dev/rattler-build/tree/main/examples/cmpcdt/recipe.yaml)

Preprocessing selectors
-----------------------

Expand Down Expand Up @@ -1237,4 +1262,4 @@ Now, by default building `libarchive` will use the dynamic build of `bzip2`. Whe

Features work by requiring a special build string. When compiling with features, the build string will be composed of all features and the build hash. For example, the following active features [zlib, bzip2] will be first alphabetically sorted and then concatenated to a build string of the form `+bzip2+zlib_h123123_0`. A deactivated feature will be prefixed with a `-`. To match packages against required build time features boa will compose a regex-based match string. E.g. when asking for at least `[bzip2]`, boa will use a build string of the form `+bzip2*`.

-->
-->
14 changes: 14 additions & 0 deletions examples/cmpcdt/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# this is an example recipe to show how you may use cmp and
# cdt in actual recipe code

package:
name: async-cairo
version: dev

requirements:
host:
- if: linux
then: ${{ cdt("cairo") }}
run:
- if: cmp("python", "==3.3")
then: asyncio

0 comments on commit ee47240

Please sign in to comment.