Skip to content

feat: add conda/outputs backend protocol#4056

Closed
baszalmstra wants to merge 27 commits intoprefix-dev:mainfrom
baszalmstra:feat/split-protocol
Closed

feat: add conda/outputs backend protocol#4056
baszalmstra wants to merge 27 commits intoprefix-dev:mainfrom
baszalmstra:feat/split-protocol

Conversation

@baszalmstra
Copy link
Contributor

@baszalmstra baszalmstra commented Jun 30, 2025

This PR adds the conda/outputs backend protocol method. Instead of letting the build backends solve the host and build environments, with this PR pixi itself takes care of that. We do this to allow pixi to act as the build orchestrator and to allow host and build environments of packages to also contain source dependencies.

The protocol method is not finalized since we already identified some weaknesses. Im putting this PR up now so we can already start doing initial reviews.

Some notable changes:

  • I tried to remove references to (Nameless)MatchSpec as much as possible in favour of PixiSpec/BinarySpec. This provides a more homogeneous API on the pixi side.

@@ -0,0 +1,211 @@
//! Describes the `conda/outputs` request and its parameters.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please take a very close look at this file. This describes the conda/outputs protocol. We want to make sure we dont have to change this.

// #[serde_as]
// #[derive(Debug, Serialize, Deserialize, Clone, Hash, Eq, PartialEq)]
// #[serde(rename_all = "camelCase")]
// pub struct CondaCacheMetadata {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I explicitly left this in


// Determine the cache key for the environment.
let cache_key = self.cache_key();
let name = self.requirement.0.as_source().to_string();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the code below because I always want to solve the environment to ensure we get the latest versions.

Copy link
Contributor

Choose a reason for hiding this comment

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

😿

Copy link
Contributor

@Hofer-Julian Hofer-Julian left a comment

Choose a reason for hiding this comment

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

Another part of the review :)

/// subdir) or for the current architecture if the target is `noarch`.
///
/// For C++ packages these would be libraries to link against.
pub host_dependencies: Option<CondaOutputDependencies>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Really like the way you write docs :)

Copy link
Contributor

@Hofer-Julian Hofer-Julian left a comment

Choose a reason for hiding this comment

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

I had a look at all code changes now, but didn't try it out locally yet

@nichmor
Copy link
Contributor

nichmor commented Jul 2, 2025

First observations while testing:

context of testing:
pixi-build-backends: I'm using this branch https://github.com/prefix-dev/pixi-build-backends/pull/220/files

On pixi side, I'm running ``PIXI_BUILD_BACKEND_OVERRIDE_ALL=1 cargo run -- install`
for examples/pixi-build/cpp-sdl.

The first time it builds fine. Then if I modify:

  • pixi.toml and add boltons in host-dependenices, it doesnt rebuild
  • main.cc it doesnt rebuild


impl BuildEnvironment {
/// Constructs a new build environment where the host environment is the same as the build environment.
pub fn to_build_from_build(&self) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe rename from_host_env?


// Determine the cache key for the environment.
let cache_key = self.cache_key();
let name = self.requirement.0.as_source().to_string();
Copy link
Contributor

Choose a reason for hiding this comment

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

😿

#[serde(rename_all = "camelCase")]
pub struct CondaOutputMetadata {
/// The identifier of the output.
pub identifier: CondaOutputIdentifier,
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can rename it to metadata ? I would expect identifier to be an id or something, but here it is more like a subset of some metadata kind

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah better!

@@ -1,3 +1,5 @@
//! This API was introduced in Pixi Build API version 0.
Copy link
Contributor

Choose a reason for hiding this comment

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

this will be deprecated in a way that we will not use conda-getmetadata but conda-outputs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes


// Try to acquire a lock on the cache file.
let cache_file_path = cache_dir.join(input.hash_key()).with_extension("json");
let cache_file_path = cache_dir.join("metadata.json");
Copy link
Contributor

Choose a reason for hiding this comment

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

why it is metadata.json? I can't find a place where this file is created/written

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will be created in something like .pixi/build/meta-v0/<hash>/metadata.json

@baszalmstra
Copy link
Contributor Author

The first time it builds fine. Then if I modify:

This PR only modifies locking so installing with the new backends does not work yet. Thats also likely why you dont see a change. Changes to the host section should cause a relock though. So if you add boltons to the host-dependencies then the lock-file should be out of date but it doesnt necesarlly cause a rebuild.

@baszalmstra
Copy link
Contributor Author

Continued in #4118

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.

3 participants