Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
cf697b9
fix: use type to better capture cache data
tdejager Oct 31, 2025
e09e2cb
Merge branch 'main' into fix/out-of-tree-caching
tdejager Oct 31, 2025
e1974f1
wip: some logging
tdejager Oct 31, 2025
8660fe4
Merge branch 'main' into fix/out-of-tree-caching
tdejager Nov 2, 2025
cb72663
Merge branch 'main' into fix/out-of-tree-caching
tdejager Nov 3, 2025
5cc68bb
Merge branch 'main' into fix/out-of-tree-caching
tdejager Nov 3, 2025
3370546
fix: out-of-source caching
tdejager Nov 3, 2025
4d5dfb1
feat: refactor to use SourceCodeLocation in more places
tdejager Nov 3, 2025
8ee5630
feat: remove from and update snap
tdejager Nov 3, 2025
aec69da
Merge branch 'main' into fix/out-of-tree-caching
tdejager Nov 3, 2025
e60d90d
snapshot
tdejager Nov 3, 2025
6a0cff8
fix: always make build_source relative to workspace
baszalmstra Nov 4, 2025
1975d42
wip: include the workspace root when serializing and deserializing th…
baszalmstra Nov 5, 2025
889ca9d
feat: correct round-trip conversion for build sources
tdejager Nov 6, 2025
eaa6edd
fix: clippy
tdejager Nov 7, 2025
903cd3b
added roundtrip snapshot test and fix
tdejager Nov 7, 2025
407eff2
fix: clippy
tdejager Nov 7, 2025
7aa0e5c
fix: satisfiability
tdejager Nov 7, 2025
a061514
fix: path normalization
tdejager Nov 7, 2025
df644f1
Merge branch 'main' into fix/out-of-tree-caching
tdejager Nov 7, 2025
397d350
fix: more tests
tdejager Nov 7, 2025
7df20ae
fix: clippy
tdejager Nov 7, 2025
b517bc3
feat: pull out path dependencies
tdejager Nov 7, 2025
1d76082
fix: clippy
tdejager Nov 7, 2025
a84faf0
fix: fix windows path handling again
tdejager Nov 7, 2025
f91017d
fix: codex attempts to fix path handling once again
tdejager Nov 8, 2025
0910693
feat: added some doc comments
tdejager Nov 8, 2025
2fa69cd
Merge branch 'main' into fix/out-of-tree-caching
tdejager Nov 10, 2025
9307160
fix import
tdejager Nov 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions crates/pixi_build_discovery/src/backend_spec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pixi_spec::{BinarySpec, PixiSpec, SourceAnchor};
use pixi_spec::{BinarySpec, PixiSpec, SourceAnchor, SourceSpec};
use pixi_spec_containers::DependencyMap;
use rattler_conda_types::ChannelUrl;
/// Describes how a backend should be instantiated.
Expand Down Expand Up @@ -45,8 +45,10 @@ impl JsonRpcBackendSpec {
let maybe_source_spec = env_spec.requirement.1.try_into_source_spec();
let pixi_spec = match maybe_source_spec {
Ok(source_spec) => {
let resolved_spec = source_anchor.resolve(source_spec);
PixiSpec::from(resolved_spec)
let resolved_spec = source_anchor.resolve(source_spec.location);
PixiSpec::from(SourceSpec {
location: resolved_spec,
})
}
Err(pixi_spec) => pixi_spec,
};
Expand Down Expand Up @@ -133,8 +135,10 @@ impl EnvironmentSpec {
let maybe_source_spec = self.requirement.1.try_into_source_spec();
let pixi_spec = match maybe_source_spec {
Ok(source_spec) => {
let resolved_spec = source_anchor.resolve(source_spec);
PixiSpec::from(resolved_spec)
let resolved_spec = source_anchor.resolve(source_spec.location);
PixiSpec::from(SourceSpec {
location: resolved_spec,
})
}
Err(pixi_spec) => pixi_spec,
};
Expand Down
6 changes: 3 additions & 3 deletions crates/pixi_cli/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use indicatif::ProgressBar;
use miette::{Context, IntoDiagnostic};
use pixi_command_dispatcher::{
BuildBackendMetadataSpec, BuildEnvironment, BuildProfile, CacheDirs, SourceBuildSpec,
build::SourceCodeLocation,
};
use pixi_config::ConfigCli;
use pixi_core::WorkspaceLocator;
Expand Down Expand Up @@ -146,13 +147,13 @@ pub async fn execute(args: Args) -> miette::Result<()> {
// Create the build backend metadata specification.
let backend_metadata_spec = BuildBackendMetadataSpec {
manifest_source: manifest_source.clone(),
preferred_build_source: None,
channels: channels.clone(),
channel_config: channel_config.clone(),
build_environment: build_environment.clone(),
variants: Some(variants.clone()),
variant_files: Some(variant_files.clone()),
enabled_protocols: Default::default(),
pin_override: None,
};
let backend_metadata = command_dispatcher
.build_backend_metadata(backend_metadata_spec.clone())
Expand Down Expand Up @@ -183,8 +184,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
package,
// Build into a temporary directory first
output_directory: Some(temp_output_dir.path().to_path_buf()),
manifest_source: manifest_source.clone(),
build_source: None,
source: SourceCodeLocation::new(manifest_source.clone(), None),
channels: channels.clone(),
channel_config: channel_config.clone(),
build_environment: build_environment.clone(),
Expand Down
4 changes: 2 additions & 2 deletions crates/pixi_command_dispatcher/src/build/build_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use thiserror::Error;
use tokio::io::{AsyncReadExt, AsyncSeekExt, AsyncWriteExt};
use xxhash_rust::xxh3::Xxh3;

use crate::build::source_checkout_cache_key;
use crate::build::{SourceCodeLocation, source_checkout_cache_key};

/// A cache for caching build artifacts of a source checkout.
#[derive(Clone)]
Expand Down Expand Up @@ -249,7 +249,7 @@ pub struct BuildHostPackage {
pub repodata_record: RepoDataRecord,

/// The source location from which the package was built.
pub source: Option<PinnedSourceSpec>,
pub source: Option<SourceCodeLocation>,
}

/// A cache entry returned by [`BuildCache::entry`] which enables
Expand Down
10 changes: 5 additions & 5 deletions crates/pixi_command_dispatcher/src/build/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use pixi_build_types::{
},
};
use pixi_record::PixiRecord;
use pixi_spec::{BinarySpec, DetailedSpec, PixiSpec, SourceAnchor, UrlBinarySpec};
use pixi_spec::{BinarySpec, DetailedSpec, PixiSpec, SourceAnchor, SourceSpec, UrlBinarySpec};
use pixi_spec_containers::DependencyMap;
use rattler_conda_types::{
InvalidPackageNameError, MatchSpec, NamedChannelOrUrl, NamelessMatchSpec, PackageName,
Expand Down Expand Up @@ -95,12 +95,12 @@ impl Dependencies {
})?;
match conversion::from_package_spec_v1(depend.spec.clone()).into_source_or_binary() {
Either::Left(source) => {
let source = if let Some(anchor) = &source_anchor {
anchor.resolve(source)
let location = if let Some(anchor) = &source_anchor {
anchor.resolve(source.location)
} else {
source
source.location
};
dependencies.insert(name, PixiSpec::from(source).into());
dependencies.insert(name, PixiSpec::from(SourceSpec { location }).into());
}
Either::Right(binary) => {
dependencies.insert(name, PixiSpec::from(binary).into());
Expand Down
67 changes: 67 additions & 0 deletions crates/pixi_command_dispatcher/src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,79 @@ pub use dependencies::{
};
pub(crate) use move_file::{MoveError, move_file};
use pixi_record::PinnedSourceSpec;
use serde::{Deserialize, Serialize};
use url::Url;
pub use work_dir_key::{SourceRecordOrCheckout, WorkDirKey};
use xxhash_rust::xxh3::Xxh3;

const KNOWN_SUFFIXES: [&str; 3] = [".git", ".tar.gz", ".zip"];

/// Stores the two possible locations for the source code,
/// in the case of an out-of-tree source build.
///
/// Something which looks like:
/// ```toml
/// [package.build]
/// source = { path = "some-path" }
/// ```
///
/// We want to prefer that location for our cache checks
#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct SourceCodeLocation {
/// The location of the manifest and the possible source code
manifest_source: PinnedSourceSpec,
/// The location of the source code that should be queried and build
build_source: Option<PinnedSourceSpec>,
}

impl SourceCodeLocation {
pub fn new(manifest_source: PinnedSourceSpec, build_source: Option<PinnedSourceSpec>) -> Self {
Self {
manifest_source,
build_source,
}
}

/// Get the reference to the manifest source
pub fn manifest_source(&self) -> &PinnedSourceSpec {
&self.manifest_source
}

/// Get the pinned source spec to the actual source code
/// This is the normally the path to the manifest_source
/// but when set is the path to the build_source
pub fn source_code(&self) -> &PinnedSourceSpec {
self.build_source.as_ref().unwrap_or(&self.manifest_source)
}

/// Get the optional explicit build source override.
pub fn build_source(&self) -> Option<&PinnedSourceSpec> {
self.build_source.as_ref()
}

pub fn as_source_and_alternative_root(&self) -> (&PinnedSourceSpec, Option<&PinnedSourceSpec>) {
if let Some(build_source) = &self.build_source {
(build_source, Some(&self.manifest_source))
} else {
(&self.manifest_source, None)
}
}
}

impl std::fmt::Display for SourceCodeLocation {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"(manifest-src: {}, build-src: {})",
self.manifest_source(),
self.build_source
.as_ref()
.map(|build| format!("{build}"))
.unwrap_or("undefined".to_string())
)
}
}

/// Try to deduce a name from a url.
fn pretty_url_name(url: &Url) -> String {
if let Some(last_segment) = url
Expand Down
Loading
Loading