diff --git a/docs/reference/pixi_manifest.md b/docs/reference/pixi_manifest.md index 7ac377c132..9edb112094 100644 --- a/docs/reference/pixi_manifest.md +++ b/docs/reference/pixi_manifest.md @@ -253,6 +253,64 @@ Both PyPi and conda packages are considered. !! note Note that for Pypi package indexes the package index must support the `upload-time` field as specified in [`PEP 700`](https://peps.python.org/pep-0700/). If the field is not present for a given distribution, the distribution will be treated as unavailable. PyPI provides `upload-time` for all packages. +### `build-variants` (optional) + +!!! warning "Preview Feature" + Build variants require the `pixi-build` preview feature to be enabled: + ```toml + [workspace] + preview = ["pixi-build"] + ``` + +Build variants allow you to specify different dependency versions for building packages in your workspace, creating a "build matrix" that targets multiple configurations. This is particularly useful for testing packages against different compiler versions, Python versions, or other critical dependencies. + +Build variants are defined as key-value pairs where each key represents a dependency name and the value is a list of version specifications to build against. + +#### Basic Usage + +```toml +[workspace.build-variants] +python = ["3.11.*", "3.12.*"] +c_compiler_version = ["11.4", "14.0"] +``` + +#### How Build Variants Work + +When build variants are specified, Pixi will: + +1. **Create variant combinations**: Generate all possible combinations of the specified variants +2. **Build separate packages**: Create distinct package builds for each variant combination +3. **Resolve dependencies**: Ensure each variant resolves with compatible dependency versions +4. **Generate unique build strings**: Each variant gets a unique build identifier in the package name + +#### Platform-Specific Variants + +Build variants can also be specified per-platform: + +```toml +[workspace.build-variants] +python = ["3.11.*", "3.12.*"] + +# Windows-specific variants +[workspace.target.win-64.build-variants] +python = ["3.11.*"] # Only Python 3.11 on Windows +c_compiler = ["vs2019"] + +# Linux-specific variants +[workspace.target.linux-64.build-variants] +c_compiler = ["gcc"] +c_compiler_version = ["11.4", "13.0"] +``` + +#### Common Use Cases + +- **Multi-version Python packages**: Build against Python 3.11 and 3.12 +- **Compiler variants**: Test with different compiler versions for C/C++ packages +- **Dependency compatibility**: Ensure packages work with different versions of key dependencies +- **Cross-platform builds**: Different build configurations per operating system + +For detailed examples and tutorials, see the [build variants documentation](../build/variants.md). + ## The `tasks` table Tasks are a way to automate certain custom commands in your workspace. @@ -1023,5 +1081,3 @@ The `run-dependencies` are the packages that will be installed in the environmen ```toml --8<-- "docs/source_files/pixi_tomls/pixi-package-manifest.toml:run-dependencies" ``` - - diff --git a/schema/model.py b/schema/model.py index 4cdca218bc..31250c12ac 100644 --- a/schema/model.py +++ b/schema/model.py @@ -184,6 +184,9 @@ class Workspace(StrictBaseModel): description="The required version spec for pixi itself to resolve and build the project.", examples=[">=0.40"], ) + target: dict[TargetName, WorkspaceTarget] | None = Field( + None, description="The workspace targets" + ) ######################## @@ -480,6 +483,14 @@ class Activation(StrictBaseModel): TargetName = NonEmptyStr +class WorkspaceTarget(StrictBaseModel): + """Target-specific configuration for a workspace""" + + build_variants: dict[NonEmptyStr, list[str]] | None = Field( + None, description="The build variants for this workspace target" + ) + + class Target(StrictBaseModel): """A machine-specific configuration of dependencies and tasks""" diff --git a/schema/schema.json b/schema/schema.json index a122d90122..d2f2c04789 100644 --- a/schema/schema.json +++ b/schema/schema.json @@ -2311,6 +2311,17 @@ "$ref": "#/$defs/S3Options" } }, + "target": { + "title": "Target", + "description": "The workspace targets", + "type": "object", + "additionalProperties": { + "$ref": "#/$defs/WorkspaceTarget" + }, + "propertyNames": { + "minLength": 1 + } + }, "version": { "title": "Version", "description": "The version of the project; we advise use of [SemVer](https://semver.org)", @@ -2338,6 +2349,28 @@ "const": true } } + }, + "WorkspaceTarget": { + "title": "WorkspaceTarget", + "description": "Target-specific configuration for a workspace", + "type": "object", + "additionalProperties": false, + "properties": { + "build-variants": { + "title": "Build-Variants", + "description": "The build variants for this workspace target", + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + }, + "propertyNames": { + "minLength": 1 + } + } + } } } }