Skip to content

feat(pixi-build): support package.run-constraints#5982

Merged
baszalmstra merged 3 commits intoprefix-dev:mainfrom
hunger:push-ytztwmlmxykn
May 6, 2026
Merged

feat(pixi-build): support package.run-constraints#5982
baszalmstra merged 3 commits intoprefix-dev:mainfrom
hunger:push-ytztwmlmxykn

Conversation

@hunger
Copy link
Copy Markdown
Contributor

@hunger hunger commented Apr 30, 2026

Add [package.run-constraints] (and [package.target.<sel>.run-constraints]) to express conda run_constrained metadata on packages built with pixi. Constraints apply to packages in the run environment only when they are pulled in by another dependency — they never cause installation on their own, mirroring conda's existing semantics.

The new field is threaded end-to-end:

  • pixi_manifest: new SpecType::RunConstraints; TOML parsing for the [package.run-constraints] and target-scoped variants.
  • pixi_build_types: new Target.run_constraints field on the protocol type, included in is_empty/Hash and round-tripped via serde.
  • pixi_build_type_conversions: to_target_v1 propagates the bucket.
  • pixi_build_backend: PackageSpecDependencies and the Targets / Dependencies trait surfaces gain the new field; from_targets_v1_to_conditional_requirements emits constraints into Requirements.run_constraints for both default and per-selector targets. The wire protocol's CondaBuildV1Params.run_constraints was already in place; the dispatcher already routes them to rattler-build.
  • schema/model.py + regenerated schema.json / pyproject schemas so IDE autocomplete and validators see the new field.
  • docs: new section in docs/reference/pixi_manifest.md, a brief entry in docs/build/dependency_types.md, and a snippet block in the package-manifest TOML fixture.

Tests cover each conversion layer: TOML parsing, target-specific routing, the pixi-build preview gate on source specs in run-constraints, the to_target_v1 and From<&Target> conversions, from_targets_v1_to_conditional_requirements populating both default and platform-conditional entries, and a regression test for Target::is_empty so a future copy-paste bug can't silently drop a target whose only payload is run-constraints.

Closes #4871
Closes #5418

How Has This Been Tested?

New unit tests. I think this covers the functionality quite well. I also tried a manual test project, which worked fine for me.

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: Claude

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.

@hunger hunger force-pushed the push-ytztwmlmxykn branch 3 times, most recently from 54a1229 to 1278987 Compare May 4, 2026 21:01
Comment thread crates/pixi_build_backend/src/traits/targets.rs Outdated
@ruben-arts
Copy link
Copy Markdown
Contributor

I tested it locally and it works with a pixi-build-rust backend.

@hunger hunger force-pushed the push-ytztwmlmxykn branch 2 times, most recently from ac478c3 to 61a19b9 Compare May 6, 2026 13:38
Copy link
Copy Markdown
Contributor

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have only one comment! Otherwise look good!

Comment thread docs/build/dependency_types.md Outdated
@baszalmstra baszalmstra changed the title feat(pixi-build): support run-constraints on packages feat(pixi-build): support package.run-constraints May 6, 2026
Add `[package.run-constraints]` (and `[package.target.<sel>.run-constraints]`)
to express conda `run_constrained` metadata on packages built with pixi.
Constraints apply to packages in the run environment only when they are
pulled in by another dependency — they never cause installation on their
own, mirroring conda's existing semantics.

The new field is threaded end-to-end:

- pixi_manifest: new `SpecType::RunConstraints`; TOML parsing for the
  `[package.run-constraints]` and target-scoped variants.
- pixi_build_types: new `Target.run_constraints` field on the protocol
  type, included in `is_empty`/`Hash` and round-tripped via serde.
- pixi_build_type_conversions: `to_target_v1` propagates the bucket.
- pixi_build_backend: `PackageSpecDependencies` and the `Targets` /
  `Dependencies` trait surfaces gain the new field;
  `from_targets_v1_to_conditional_requirements` emits constraints into
  `Requirements.run_constraints` for both default and per-selector
  targets. The wire protocol's `CondaBuildV1Params.run_constraints` was
  already in place; the dispatcher already routes them to rattler-build.
- schema/model.py + regenerated `schema.json` / pyproject schemas so
  IDE autocomplete and validators see the new field.
- docs: new section in `docs/reference/pixi_manifest.md`, a brief entry
  in `docs/build/dependency_types.md`, and a snippet block in the
  package-manifest TOML fixture.

Tests cover each conversion layer: TOML parsing, target-specific
routing, the pixi-build preview gate on source specs in
`run-constraints`, the `to_target_v1` and `From<&Target>` conversions,
`from_targets_v1_to_conditional_requirements` populating both default
and platform-conditional entries, and a regression test for
`Target::is_empty` so a future copy-paste bug can't silently drop a
target whose only payload is `run-constraints`.
@hunger hunger force-pushed the push-ytztwmlmxykn branch from 61a19b9 to 6b119d9 Compare May 6, 2026 15:32
@baszalmstra baszalmstra enabled auto-merge (squash) May 6, 2026 17:54
@baszalmstra baszalmstra self-requested a review May 6, 2026 18:09
@baszalmstra baszalmstra merged commit d78ad97 into prefix-dev:main May 6, 2026
41 checks passed
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.

Support Conda's run-constrained concept in pixi-build-python feat(build): Add [package.run-constraints] support

3 participants