Skip to content

feat(build): support if(...) conditional package dependencies#6269

Draft
Hofer-Julian wants to merge 1 commit into
prefix-dev:mainfrom
Hofer-Julian:conditional-package-dependencies
Draft

feat(build): support if(...) conditional package dependencies#6269
Hofer-Julian wants to merge 1 commit into
prefix-dev:mainfrom
Hofer-Julian:conditional-package-dependencies

Conversation

@Hofer-Julian
Copy link
Copy Markdown
Contributor

Description

Add support for conditional dependencies in the [package] section using an if(<expression>) key inside the dependency tables, e.g. [package.build-dependencies."if(host_platform != build_platform)"]. The expression is passed through to rattler-build. The old [package.target.*] syntax keeps working but emits a deprecation warning.

Fixes #4625

How Has This Been Tested?

pixi run test

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: {e.g., Claude, Codex, GitHub Copilot, ChatGPT, etc.}

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added sufficient tests to cover my changes.
  • I have verified that changes that would impact the JSON schema have been made in schema/model.py.

@Hofer-Julian Hofer-Julian force-pushed the conditional-package-dependencies branch 3 times, most recently from 8b45cf3 to d01ad12 Compare June 5, 2026 09:46
Comment thread tests/data/pixi-build/rattler-build-backend/smokey2/pixi.toml
Add support for conditional dependencies in the [package] section using
an if(<expression>) key inside the dependency tables, e.g.
[package.build-dependencies."if(host_platform != build_platform)"]. The
expression is passed through to rattler-build. The old [package.target.*]
syntax keeps working but emits a deprecation warning.


fix(build): fail loudly on inevaluable if() selectors

The passthrough backend silently dropped if(...) conditional dependencies
because matches_target_selector returned false for Expression selectors.
A bool predicate conflated "does not match this platform" with "cannot
evaluate this selector". Panic instead so a test backend never produces
quietly-incomplete outputs.

Harden the manifest TargetSelector::matches twin with unreachable!, since
the parser already rejects expression selectors outside [package] tables.


refactor(build): model if() conditionals as a dedicated type instead of a selector variant
@Hofer-Julian Hofer-Julian force-pushed the conditional-package-dependencies branch from d01ad12 to 8e47274 Compare June 5, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(build): design platform specific package dependencies

3 participants