Skip to content

Commit 78bed8b

Browse files
authored
docs: document custom build-variant keys as environment variables (#5796)
1 parent 9559c8b commit 78bed8b

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

docs/build/backends/pixi-build-rattler-build.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,33 @@ The rattler-build backend follows this build process:
160160
5. **Package Creation**: Creates conda packages according to the recipe specification
161161

162162

163+
## Custom Build Variants as Environment Variables
164+
165+
When using `[workspace.build-variants]`, any variant key that is not a recognized language key (like `python`, `numpy`, `r`, etc.) is automatically exported as an environment variable during the build.
166+
167+
This is useful for passing configuration to build scripts without modifying the recipe.
168+
For example, to override the macOS sysroot used during compilation:
169+
170+
```toml title="pixi.toml"
171+
[workspace.target.osx.build-variants]
172+
CONDA_BUILD_SYSROOT = ["/Library/Developer/CommandLineTools/SDKs/MacOSX15.4.sdk"]
173+
```
174+
175+
During the build, `CONDA_BUILD_SYSROOT` will be set as an environment variable available to the build script.
176+
Custom variant keys can also be used in recipe templates via Jinja:
177+
178+
```yaml title="recipe.yaml"
179+
build:
180+
script:
181+
env:
182+
MY_FLAG: ${{ my_custom_flag }}
183+
```
184+
185+
```toml title="pixi.toml"
186+
[workspace.build-variants]
187+
my_custom_flag = ["enabled"]
188+
```
189+
163190
## Limitations
164191

165192
- Requires an existing rattler-build recipe file - cannot infer build instructions automatically

0 commit comments

Comments
 (0)