diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce4f4f6446..b45547c09f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -913,8 +913,7 @@ jobs: steps: - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 with: - repository: nichmor/pixi-build-testsuite - ref: feat/change-manifest-path-to-path-in-pixi-build + repository: prefix-dev/pixi-build-testsuite - name: Set up pixi uses: prefix-dev/setup-pixi@main @@ -945,8 +944,7 @@ jobs: steps: - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 with: - repository: nichmor/pixi-build-testsuite - ref: feat/change-manifest-path-to-path-in-pixi-build + repository: prefix-dev/pixi-build-testsuite - name: Create Dev Drive run: ${{ github.workspace }}/.github/workflows/setup-dev-drive.ps1 @@ -984,8 +982,7 @@ jobs: steps: - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 with: - repository: nichmor/pixi-build-testsuite - ref: feat/change-manifest-path-to-path-in-pixi-build + repository: prefix-dev/pixi-build-testsuite - name: Set up pixi uses: prefix-dev/setup-pixi@main diff --git a/Cargo.lock b/Cargo.lock index 34f8152816..facaf03b9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5163,6 +5163,7 @@ dependencies = [ "pixi_git", "pixi_global", "pixi_manifest", + "pixi_path", "pixi_progress", "pixi_pty", "pixi_pypi_spec", @@ -5234,7 +5235,6 @@ dependencies = [ "miette 7.6.0", "once_cell", "ordermap", - "pathdiff", "pin-project-lite", "pixi_build_backend_passthrough", "pixi_build_discovery", @@ -5244,6 +5244,7 @@ dependencies = [ "pixi_consts", "pixi_git", "pixi_glob", + "pixi_path", "pixi_record", "pixi_spec", "pixi_spec_containers", @@ -5343,6 +5344,7 @@ dependencies = [ "pathdiff", "pep440_rs", "pep508_rs", + "pixi_build_backend_passthrough", "pixi_build_discovery", "pixi_build_frontend", "pixi_command_dispatcher", @@ -5354,6 +5356,7 @@ dependencies = [ "pixi_glob", "pixi_install_pypi", "pixi_manifest", + "pixi_path", "pixi_progress", "pixi_pypi_spec", "pixi_python_status", @@ -5513,6 +5516,7 @@ dependencies = [ "pixi_consts", "pixi_core", "pixi_manifest", + "pixi_path", "pixi_progress", "pixi_reporters", "pixi_spec", @@ -5649,6 +5653,16 @@ dependencies = [ "url", ] +[[package]] +name = "pixi_path" +version = "0.1.0" +dependencies = [ + "fs-err", + "serde", + "tempfile", + "thiserror 2.0.17", +] + [[package]] name = "pixi_progress" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 7b2454e463..d29889db86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,6 +96,7 @@ pixi_glob = { path = "crates/pixi_glob" } pixi_global = { path = "crates/pixi_global" } pixi_install_pypi = { path = "crates/pixi_install_pypi" } pixi_manifest = { path = "crates/pixi_manifest" } +pixi_path = { path = "crates/pixi_path" } pixi_progress = { path = "crates/pixi_progress" } pixi_pypi_spec = { path = "crates/pixi_pypi_spec" } pixi_python_status = { path = "crates/pixi_python_status" } diff --git a/crates/pixi/tests/integration_rust/develop_dependencies_tests.rs b/crates/pixi/tests/integration_rust/develop_dependencies_tests.rs index ccae50b0c1..fe4f282ccf 100644 --- a/crates/pixi/tests/integration_rust/develop_dependencies_tests.rs +++ b/crates/pixi/tests/integration_rust/develop_dependencies_tests.rs @@ -5,9 +5,7 @@ use pixi_consts::consts; use rattler_conda_types::Platform; use crate::{ - common::{ - LockFileExt, PixiControl, - }, + common::{LockFileExt, PixiControl}, setup_tracing, }; use pixi_test_utils::{MockRepoData, Package}; diff --git a/crates/pixi_build_backend_passthrough/src/lib.rs b/crates/pixi_build_backend_passthrough/src/lib.rs index 7d06f94397..6447b90166 100644 --- a/crates/pixi_build_backend_passthrough/src/lib.rs +++ b/crates/pixi_build_backend_passthrough/src/lib.rs @@ -140,7 +140,7 @@ fn generate_variant_outputs( project_model, index_json, params, - &BTreeMap::new(), + BTreeMap::new(), )]; } @@ -162,7 +162,7 @@ fn generate_variant_outputs( project_model, index_json, params, - &BTreeMap::new(), + BTreeMap::new(), )]; } @@ -171,7 +171,7 @@ fn generate_variant_outputs( // Create an output for each variant combination combinations - .iter() + .into_iter() .map(|variant| create_output(project_model, index_json, params, variant)) .collect() } @@ -297,9 +297,40 @@ fn create_output( project_model: &ProjectModelV1, index_json: &Option, params: &CondaOutputsParams, - variant: &BTreeMap, + mut variant: BTreeMap, ) -> CondaOutput { + let subdir = index_json + .as_ref() + .and_then(|j| j.subdir.as_deref()) + .map(|subdir| subdir.parse().unwrap()) + .unwrap_or(Platform::NoArch); + + if !variant.contains_key("target_platform") { + variant.insert( + String::from("target_platform"), + VariantValue::from(subdir.to_string()), + ); + } + CondaOutput { + build_dependencies: Some(extract_dependencies( + &project_model.targets, + |t| t.build_dependencies.as_ref(), + params.host_platform, + &variant, + )), + host_dependencies: Some(extract_dependencies( + &project_model.targets, + |t| t.host_dependencies.as_ref(), + params.host_platform, + &variant, + )), + run_dependencies: extract_dependencies( + &project_model.targets, + |t| t.run_dependencies.as_ref(), + params.host_platform, + &variant, + ), metadata: CondaOutputMetadata { name: project_model .name @@ -326,36 +357,14 @@ fn create_output( .as_ref() .map(|j| j.build_number) .unwrap_or_default(), - subdir: index_json - .as_ref() - .and_then(|j| j.subdir.as_deref()) - .map(|subdir| subdir.parse().unwrap()) - .unwrap_or(Platform::NoArch), + subdir, license: project_model.license.clone(), license_family: None, noarch: index_json.as_ref().map(|j| j.noarch).unwrap_or_default(), purls: None, python_site_packages_path: None, - variant: variant.clone(), - }, - build_dependencies: Some(extract_dependencies( - &project_model.targets, - |t| t.build_dependencies.as_ref(), - params.host_platform, variant, - )), - host_dependencies: Some(extract_dependencies( - &project_model.targets, - |t| t.host_dependencies.as_ref(), - params.host_platform, - variant, - )), - run_dependencies: extract_dependencies( - &project_model.targets, - |t| t.run_dependencies.as_ref(), - params.host_platform, - variant, - ), + }, ignore_run_exports: Default::default(), run_exports: Default::default(), input_globs: None, @@ -498,6 +507,9 @@ pub struct PassthroughBackendConfig { /// The path to a pre-build conda package. pub package: Option, + /// Whether this is a noarch package + pub noarch: Option, + /// Build globs pub build_globs: Option>, } diff --git a/crates/pixi_cli/Cargo.toml b/crates/pixi_cli/Cargo.toml index b4f1e60c2e..ddaacb5ccc 100644 --- a/crates/pixi_cli/Cargo.toml +++ b/crates/pixi_cli/Cargo.toml @@ -51,6 +51,7 @@ pixi_diff = { workspace = true } pixi_git = { workspace = true } pixi_global = { workspace = true } pixi_manifest = { workspace = true, features = ["rattler_lock"] } +pixi_path = { workspace = true } pixi_progress = { workspace = true } pixi_pypi_spec = { workspace = true } pixi_record = { workspace = true } diff --git a/crates/pixi_cli/src/build.rs b/crates/pixi_cli/src/build.rs index affa061cbf..0b2191b12b 100644 --- a/crates/pixi_cli/src/build.rs +++ b/crates/pixi_cli/src/build.rs @@ -16,6 +16,7 @@ use pixi_consts::consts::{ }; use pixi_core::{WorkspaceLocator, environment::sanity_check_workspace, workspace::DiscoveryStart}; use pixi_manifest::FeaturesExt; +use pixi_path::AbsPathBuf; use pixi_progress::global_multi_progress; use pixi_record::{PinnedPathSpec, PinnedSourceSpec}; use pixi_reporters::TopLevelProgress; @@ -187,9 +188,17 @@ pub async fn execute(args: Args) -> miette::Result<()> { // Construct a command dispatcher based on the workspace. let multi_progress = global_multi_progress(); let anchor_pb = multi_progress.add(ProgressBar::hidden()); - let mut cache_dirs = - CacheDirs::new(pixi_config::get_cache_dir()?).with_workspace(workspace.pixi_dir()); + let cache_dir = AbsPathBuf::new(pixi_config::get_cache_dir()?) + .expect("cache dir is not absolute") + .into_assume_dir(); + let workspace_dir = AbsPathBuf::new(workspace.pixi_dir()) + .expect("pixi dir is not absolute") + .into_assume_dir(); + let mut cache_dirs = CacheDirs::new(cache_dir).with_workspace(workspace_dir); if let Some(build_dir) = args.build_dir { + let build_dir = AbsPathBuf::new(build_dir) + .expect("build dir is not absolute") + .into_assume_dir(); cache_dirs.set_working_dirs(build_dir); } let command_dispatcher = workspace diff --git a/crates/pixi_command_dispatcher/Cargo.toml b/crates/pixi_command_dispatcher/Cargo.toml index 41c77bc82e..6ab2f9810d 100644 --- a/crates/pixi_command_dispatcher/Cargo.toml +++ b/crates/pixi_command_dispatcher/Cargo.toml @@ -23,7 +23,6 @@ itertools = { workspace = true } miette = { workspace = true } once_cell = { workspace = true } ordermap = { workspace = true } -pathdiff = { workspace = true } pin-project-lite = { workspace = true } rand = { workspace = true } serde = { workspace = true, features = ["derive"] } @@ -55,6 +54,7 @@ pixi_build_types = { workspace = true } pixi_consts = { workspace = true } pixi_git = { workspace = true } pixi_glob = { workspace = true } +pixi_path = { workspace = true } pixi_record = { workspace = true } pixi_spec = { workspace = true } pixi_spec_containers = { workspace = true } diff --git a/crates/pixi_command_dispatcher/src/backend_source_build/mod.rs b/crates/pixi_command_dispatcher/src/backend_source_build/mod.rs index 4b488c9692..86506c4bdd 100644 --- a/crates/pixi_command_dispatcher/src/backend_source_build/mod.rs +++ b/crates/pixi_command_dispatcher/src/backend_source_build/mod.rs @@ -1,7 +1,7 @@ //! See [`BackendSourceBuildSpec`] use std::{ - collections::{BTreeMap, BTreeSet}, + collections::{BTreeMap, BTreeSet, BinaryHeap}, fmt::Display, path::PathBuf, }; @@ -18,7 +18,7 @@ use pixi_build_types::{ CondaBuildV1PrefixPackage, CondaBuildV1Result, CondaBuildV1RunExports, }, }; -use pixi_record::PinnedSourceSpec; +use pixi_glob::GlobSet; use pixi_spec::{BinarySpec, PixiSpec, SpecConversionError}; use rattler_conda_types::{ ChannelConfig, ChannelUrl, MatchSpec, PackageName, Platform, RepoDataRecord, @@ -46,8 +46,9 @@ pub struct BackendSourceBuildSpec { /// The package that we are building. pub package: PackageIdentifier, - /// The source location of the package that we are building. - pub source: PinnedSourceSpec, + /// The directory where the source code is located on disk. + #[serde(skip)] + pub source_dir: PathBuf, /// The method to use for building the source package. pub method: BackendSourceBuildMethod, @@ -116,7 +117,11 @@ pub struct BackendBuiltSource { /// The globs that were used as input to the build. Use these for /// re-verifying the build. - pub input_globs: BTreeSet, + pub input_globs: BinaryHeap, + + /// The actual files that matched the globs at build time. This allows + /// detecting file deletions and additions. + pub input_files: BTreeSet, } impl BackendSourceBuildSpec { @@ -130,6 +135,7 @@ impl BackendSourceBuildSpec { self.backend, self.package, params, + self.source_dir, self.work_directory, self.channels, self.channel_config, @@ -140,10 +146,12 @@ impl BackendSourceBuildSpec { } } + #[allow(clippy::too_many_arguments)] async fn build_v1( backend: Backend, record: PackageIdentifier, params: BackendSourceBuildV1Method, + source_dir: PathBuf, work_directory: PathBuf, channels: Vec, channel_config: ChannelConfig, @@ -284,8 +292,25 @@ impl BackendSourceBuildSpec { )); }; + // Compute the files that match the input globs. + let glob_set = GlobSet::create(built_package.input_globs.iter().map(String::as_str)); + let input_files = glob_set + .collect_matching(&source_dir) + .map_err(BackendSourceBuildError::GlobSet) + .map_err(CommandDispatcherError::Failed)? + .into_iter() + .filter_map(|entry| { + entry + .into_path() + .strip_prefix(&source_dir) + .ok() + .map(|p| p.to_path_buf()) + }) + .collect(); + Ok(BackendBuiltSource { - input_globs: built_package.input_globs, + input_globs: built_package.input_globs.into_iter().collect(), + input_files, output_file: built_package.output_file, }) } @@ -379,6 +404,9 @@ pub enum BackendSourceBuildError { #[error(transparent)] UnexpectedPackage(UnexpectedPackageError), + + #[error(transparent)] + GlobSet(#[from] pixi_glob::GlobSetError), } /// An error that can occur when the build backend did not return the expected diff --git a/crates/pixi_command_dispatcher/src/build/build_cache.rs b/crates/pixi_command_dispatcher/src/build/build_cache.rs index a23ffeac6e..3cd8d5f1f1 100644 --- a/crates/pixi_command_dispatcher/src/build/build_cache.rs +++ b/crates/pixi_command_dispatcher/src/build/build_cache.rs @@ -1,15 +1,17 @@ use std::{ - collections::BTreeSet, + collections::{BTreeSet, BinaryHeap}, hash::{Hash, Hasher}, io::SeekFrom, - path::{Path, PathBuf}, + path::PathBuf, }; +use crate::build::{SourceCodeLocation, source_checkout_cache_key}; use async_fd_lock::{LockWrite, RwLockWriteGuard}; use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD}; use ordermap::OrderMap; use pixi_build_discovery::{BackendInitializationParams, DiscoveredBackend}; use pixi_build_types::{ProjectModelV1, TargetSelectorV1}; +use pixi_path::{AbsPathBuf, AbsPresumedDirPath, AbsPresumedDirPathBuf, AbsPresumedFilePathBuf}; use pixi_record::PinnedSourceSpec; use pixi_stable_hash::{StableHashBuilder, json::StableJson, map::StableMap}; use rattler_conda_types::{ChannelUrl, GenericVirtualPackage, Platform, RepoDataRecord}; @@ -19,19 +21,17 @@ use thiserror::Error; use tokio::io::{AsyncReadExt, AsyncSeekExt, AsyncWriteExt}; use xxhash_rust::xxh3::Xxh3; -use crate::build::{SourceCodeLocation, source_checkout_cache_key}; - /// A cache for caching build artifacts of a source checkout. #[derive(Clone)] pub struct BuildCache { - pub(crate) root: PathBuf, + pub(crate) root: AbsPresumedDirPathBuf, } #[derive(Debug, Error)] pub enum BuildCacheError { /// An I/O error occurred while reading or writing the cache. #[error("an IO error occurred while {0} {1}")] - IoError(String, PathBuf, #[source] std::io::Error), + IoError(String, AbsPathBuf, #[source] std::io::Error), } /// Defines additional input besides the source files that are used to compute @@ -83,8 +83,15 @@ impl BuildInput { build.hash(&mut hasher); channel_urls.hash(&mut hasher); host_platform.hash(&mut hasher); - host_virtual_packages.hash(&mut hasher); - build_virtual_packages.hash(&mut hasher); + + let mut sorted_host_virtual_packages = host_virtual_packages.clone(); + sorted_host_virtual_packages.sort_by(|a, b| a.name.cmp(&b.name)); + sorted_host_virtual_packages.hash(&mut hasher); + + let mut sorted_build_virtual_packages = build_virtual_packages.clone(); + sorted_build_virtual_packages.sort_by(|a, b| a.name.cmp(&b.name)); + sorted_build_virtual_packages.hash(&mut hasher); + let hash = URL_SAFE_NO_PAD.encode(hasher.finish().to_ne_bytes()); format!("{name}-{version}-{subdir}-{hash}",) @@ -96,7 +103,7 @@ impl BuildCache { pub const CACHE_SUFFIX: &'static str = "v0"; /// Constructs a new instance. - pub fn new(root: PathBuf) -> Self { + pub fn new(root: AbsPresumedDirPathBuf) -> Self { Self { root } } @@ -133,18 +140,19 @@ impl BuildCache { .root .join(source_checkout_cache_key(source)) .join(&input_key); - fs_err::tokio::create_dir_all(&cache_dir) - .await + let cache_dir = cache_dir + .create_dir_all() .map_err(|e| { BuildCacheError::IoError( "creating cache directory".to_string(), cache_dir.clone(), e, ) - })?; + })? + .to_path_buf(); // Try to acquire a lock on the cache file. - let cache_file_path = cache_dir.join(".lock"); + let cache_file_path = cache_dir.join(".lock").into_assume_file(); let cache_file = tokio::fs::OpenOptions::new() .write(true) .read(true) @@ -155,7 +163,7 @@ impl BuildCache { .map_err(|e| { BuildCacheError::IoError( "opening cache file".to_string(), - cache_file_path.clone(), + cache_file_path.clone().into(), e, ) })?; @@ -163,7 +171,7 @@ impl BuildCache { let mut locked_cache_file = cache_file.lock_write().await.map_err(|e| { BuildCacheError::IoError( "locking cache file".to_string(), - cache_file_path.clone(), + cache_file_path.clone().into(), e.error, ) })?; @@ -176,7 +184,7 @@ impl BuildCache { .map_err(|e| { BuildCacheError::IoError( "reading cache file".to_string(), - cache_file_path.clone(), + cache_file_path.clone().into(), e, ) })?; @@ -218,9 +226,17 @@ pub struct CachedBuild { #[derive(Clone, Debug, Serialize, Deserialize)] pub struct CachedBuildSourceInfo { - /// The files that were used during the build process. If any of these - /// change, the build should be considered stale. - pub globs: BTreeSet, + /// Glob patterns that define which files affect the build. If any matching + /// file changes, the build should be considered stale. + #[serde(default, skip_serializing_if = "BinaryHeap::is_empty")] + pub input_globs: BinaryHeap, + + /// The actual files that matched the globs at the time of the build. This + /// allows detecting file deletions and additions by comparing against + /// current glob matches. + #[serde(default, skip_serializing_if = "BTreeSet::is_empty")] + pub input_files: BTreeSet, + /// The packages that were used during the build process. #[serde(default)] pub build: BuildHostEnvironment, @@ -258,13 +274,13 @@ pub struct BuildHostPackage { /// As long as this entry is held, no other process can access this cache entry. pub struct BuildCacheEntry { file: RwLockWriteGuard, - cache_dir: PathBuf, - cache_file_path: PathBuf, + cache_dir: AbsPresumedDirPathBuf, + cache_file_path: AbsPresumedFilePathBuf, } impl BuildCacheEntry { /// The directory where the cache is stored. - pub fn cache_dir(&self) -> &Path { + pub fn cache_dir(&self) -> &AbsPresumedDirPath { &self.cache_dir } @@ -276,7 +292,7 @@ impl BuildCacheEntry { self.file.seek(SeekFrom::Start(0)).await.map_err(|e| { BuildCacheError::IoError( "seeking to start of cache file".to_string(), - self.cache_file_path.clone(), + self.cache_file_path.clone().into(), e, ) })?; @@ -284,7 +300,7 @@ impl BuildCacheEntry { self.file.write_all(&bytes).await.map_err(|e| { BuildCacheError::IoError( "writing metadata to cache file".to_string(), - self.cache_file_path.clone(), + self.cache_file_path.clone().into(), e, ) })?; @@ -295,7 +311,7 @@ impl BuildCacheEntry { .map_err(|e| { BuildCacheError::IoError( "setting length of cache file".to_string(), - self.cache_file_path.clone(), + self.cache_file_path.clone().into(), e, ) })?; diff --git a/crates/pixi_command_dispatcher/src/build/conversion.rs b/crates/pixi_command_dispatcher/src/build/conversion.rs index 8f3e421551..b85d86e096 100644 --- a/crates/pixi_command_dispatcher/src/build/conversion.rs +++ b/crates/pixi_command_dispatcher/src/build/conversion.rs @@ -1,9 +1,6 @@ -use pixi_build_types::{ - BinaryPackageSpecV1, CondaPackageMetadata, PackageSpecV1, SourcePackageSpecV1, -}; -use pixi_record::{InputHash, PinnedSourceSpec, SourceRecord}; +use pixi_build_types::{BinaryPackageSpecV1, PackageSpecV1, SourcePackageSpecV1}; use pixi_spec::{BinarySpec, DetailedSpec, SourceLocationSpec, UrlBinarySpec}; -use rattler_conda_types::{NamedChannelOrUrl, PackageName, PackageRecord}; +use rattler_conda_types::NamedChannelOrUrl; /// Converts a [`SourcePackageSpecV1`] to a [`pixi_spec::SourceSpec`]. pub fn from_source_spec_v1(source: SourcePackageSpecV1) -> pixi_spec::SourceSpec { @@ -96,72 +93,3 @@ pub fn from_package_spec_v1(source: PackageSpecV1) -> pixi_spec::PixiSpec { PackageSpecV1::Binary(binary) => from_binary_spec_v1(*binary).into(), } } - -pub(crate) fn package_metadata_to_source_records( - manifest_source: &PinnedSourceSpec, - build_source: Option<&PinnedSourceSpec>, - packages: &[CondaPackageMetadata], - package: &PackageName, - input_hash: &Option, -) -> Vec { - // Convert the metadata to repodata - - packages - .iter() - .filter(|pkg| pkg.name == *package) - .map(|p| { - SourceRecord { - input_hash: input_hash.clone(), - manifest_source: manifest_source.clone(), - build_source: build_source.cloned(), - sources: p - .sources - .iter() - .map(|(name, source)| (name.clone(), from_source_spec_v1(source.clone()))) - .collect(), - package_record: PackageRecord { - // We cannot now these values from the metadata because no actual package - // was built yet. - size: None, - sha256: None, - md5: None, - - // TODO(baszalmstra): Decide if it makes sense to include the current - // timestamp here. - timestamp: None, - - // These values are derived from the build backend values. - platform: p.subdir.only_platform().map(ToString::to_string), - arch: p.subdir.arch().as_ref().map(ToString::to_string), - - // These values are passed by the build backend - name: p.name.clone(), - build: p.build.clone(), - version: p.version.clone(), - build_number: p.build_number, - license: p.license.clone(), - subdir: p.subdir.to_string(), - license_family: p.license_family.clone(), - noarch: p.noarch, - constrains: p.constraints.iter().map(|c| c.to_string()).collect(), - depends: p.depends.iter().map(|c| c.to_string()).collect(), - - // These are deprecated and no longer used. - features: None, - track_features: vec![], - legacy_bz2_md5: None, - legacy_bz2_size: None, - python_site_packages_path: None, - - // TODO(baszalmstra): Add support for these. - purls: None, - - // These are not important at this point. - run_exports: None, - experimental_extra_depends: Default::default(), - }, - variants: None, - } - }) - .collect() -} diff --git a/crates/pixi_command_dispatcher/src/build/work_dir_key.rs b/crates/pixi_command_dispatcher/src/build/work_dir_key.rs index 1348d446c5..6fb2035e36 100644 --- a/crates/pixi_command_dispatcher/src/build/work_dir_key.rs +++ b/crates/pixi_command_dispatcher/src/build/work_dir_key.rs @@ -62,9 +62,11 @@ impl WorkDirKey { SourceRecordOrCheckout::Record { package_name, .. } => { Some(package_name.as_normalized()) } - SourceRecordOrCheckout::Checkout { checkout } => { - checkout.path.file_name().and_then(OsStr::to_str) - } + SourceRecordOrCheckout::Checkout { checkout } => checkout + .path + .as_std_path() + .file_name() + .and_then(OsStr::to_str), }; match name { diff --git a/crates/pixi_command_dispatcher/src/build_backend_metadata/mod.rs b/crates/pixi_command_dispatcher/src/build_backend_metadata/mod.rs index 0913f0fa32..2362dad9e6 100644 --- a/crates/pixi_command_dispatcher/src/build_backend_metadata/mod.rs +++ b/crates/pixi_command_dispatcher/src/build_backend_metadata/mod.rs @@ -1,39 +1,37 @@ -use std::{ - collections::{BTreeMap, BTreeSet, HashSet}, - hash::{Hash, Hasher}, - path::PathBuf, - sync::Mutex, -}; - use futures::{SinkExt, channel::mpsc::UnboundedSender}; use miette::Diagnostic; use once_cell::sync::Lazy; -use pathdiff::diff_paths; use pixi_build_discovery::{CommandSpec, EnabledProtocols}; use pixi_build_frontend::Backend; -use pixi_build_types::{ProjectModelV1, procedures::conda_outputs::CondaOutputsParams}; -use pixi_glob::GlobHashKey; -use pixi_record::{InputHash, PinnedSourceSpec, VariantValue}; +use pixi_build_types::procedures::conda_outputs::CondaOutputsParams; +use pixi_glob::GlobSet; +use pixi_record::{PinnedSourceSpec, VariantValue}; use pixi_spec::{SourceAnchor, SourceSpec}; -use rand::random; use rattler_conda_types::{ChannelConfig, ChannelUrl}; +use std::time::SystemTime; +use std::{ + collections::{BTreeMap, HashSet}, + hash::Hash, + path::PathBuf, + sync::Mutex, +}; use thiserror::Error; use tracing::instrument; -use xxhash_rust::xxh3::Xxh3; +use crate::cache::build_backend_metadata::CachedCondaMetadataId; +use crate::input_hash::ProjectModelHash; use crate::{ BuildEnvironment, CommandDispatcher, CommandDispatcherError, CommandDispatcherErrorResultExt, InstantiateBackendError, InstantiateBackendSpec, SourceCheckout, SourceCheckoutError, build::{SourceCodeLocation, SourceRecordOrCheckout, WorkDirKey}, cache::{ - build_backend_metadata::{ - self, BuildBackendMetadataKey, CachedCondaMetadata, MetadataKind, - }, + build_backend_metadata::{self, BuildBackendMetadataCacheShard, CachedCondaMetadata}, common::MetadataCache, }, }; use pixi_build_discovery::BackendSpec; use pixi_build_frontend::BackendOverride; +use pixi_path::AbsPath; static WARNED_BACKENDS: Lazy>> = Lazy::new(|| Mutex::new(HashSet::new())); @@ -55,7 +53,7 @@ pub struct BuildBackendMetadataSpec { /// The location that refers to where the manifest is stored. pub manifest_source: PinnedSourceSpec, - /// The optional pinned location of the source code. If not provide the + /// The optional pinned location of the source code. If not provided, the /// location in the manifest is resolved. /// /// This is passed as a hint. If the [`SourceSpec`] in the discovered @@ -92,13 +90,6 @@ pub struct BuildBackendMetadata { /// The manifest and optional build source location for this metadata. pub source: SourceCodeLocation, - /// The cache entry that contains the metadata acquired from the build - /// backend. - /// - /// As long as the cache entry is not dropped, the metadata cannot be - /// accessed by another process. - pub cache_entry: build_backend_metadata::CacheEntry, - /// The metadata that was acquired from the build backend. pub metadata: CachedCondaMetadata, @@ -112,7 +103,7 @@ pub struct BuildBackendMetadata { impl BuildBackendMetadataSpec { #[instrument( skip_all, - name="backend-metadata", + name = "backend-metadata", fields( manifest_source = %self.manifest_source, build_source = self.preferred_build_source.as_ref().map(tracing::field::display), @@ -134,7 +125,7 @@ impl BuildBackendMetadataSpec { // Discover information about the build backend from the source code (cached by path). let discovered_backend = command_dispatcher .discover_backend( - &manifest_source_checkout.path, + manifest_source_checkout.path.as_std_path(), self.channel_config.clone(), self.enabled_protocols.clone(), ) @@ -180,17 +171,11 @@ impl BuildBackendMetadataSpec { } else { (manifest_source_checkout.clone(), None) }; - let source_location = SourceCodeLocation::new( + let manifest_source_location = SourceCodeLocation::new( manifest_source_checkout.pinned.clone(), build_source.clone(), ); - // Calculate the hash of the project model - let additional_glob_hash = calculate_additional_glob_hash( - &discovered_backend.init_params.project_model, - &self.variant_configuration, - ); - // Check if we should skip the metadata cache for this backend let skip_cache = Self::should_skip_metadata_cache( &discovered_backend.backend_spec, @@ -199,28 +184,39 @@ impl BuildBackendMetadataSpec { // Check the source metadata cache, short circuit if there is a cache hit that // is still fresh. - let cache_key = self.cache_key(); - let (metadata, mut cache_entry) = command_dispatcher + let cache_key = self.cache_shard(); + let cache_read_result = command_dispatcher .build_backend_metadata_cache() - .entry(&cache_key) + .read(&cache_key) .await .map_err(BuildBackendMetadataError::Cache) .map_err(CommandDispatcherError::Failed)?; + let (cached_metadata, cache_version) = match cache_read_result { + Some((metadata, version)) => (Some(metadata), version), + // Start at cache version 0 if no cache exists + None => (None, 0), + }; + + let project_model_hash = discovered_backend + .init_params + .project_model + .as_ref() + .map(ProjectModelHash::from); + if !skip_cache { - if let Some(metadata) = Self::verify_cache_freshness( + if let Some(cache_entry) = Self::verify_cache_freshness( + cached_metadata, &build_source_checkout, - &command_dispatcher, - metadata, - &additional_glob_hash, + project_model_hash, &self.variant_configuration, ) .await? { + tracing::debug!("Using cached source metadata for package",); return Ok(BuildBackendMetadata { - source: source_location.clone(), - metadata, - cache_entry, + source: manifest_source_location.clone(), + metadata: cache_entry, skip_cache, }); } @@ -231,7 +227,6 @@ impl BuildBackendMetadataSpec { warn_once_per_backend(backend_name); } - let build_source_dir = build_source_checkout.path.clone(); // Instantiate the backend with the discovered information. let backend = command_dispatcher .instantiate_backend(InstantiateBackendSpec { @@ -239,11 +234,20 @@ impl BuildBackendMetadataSpec { .backend_spec .clone() .resolve(manifest_source_anchor), - build_source_dir, + build_source_dir: build_source_checkout + .path + .as_dir_or_file_parent() + .to_path_buf(), channel_config: self.channel_config.clone(), enabled_protocols: self.enabled_protocols.clone(), - workspace_root: discovered_backend.init_params.workspace_root.clone(), - manifest_path: discovered_backend.init_params.manifest_path.clone(), + workspace_root: AbsPath::new(&discovered_backend.init_params.workspace_root) + .expect("workspace root is not absolute") + .assume_dir() + .to_path_buf(), + manifest_path: AbsPath::new(&discovered_backend.init_params.manifest_path) + .expect("manifest path is not absolute") + .assume_file() + .to_path_buf(), project_model: discovered_backend.init_params.project_model.clone(), configuration: discovered_backend.init_params.configuration.clone(), target_configuration: discovered_backend.init_params.target_configuration.clone(), @@ -264,27 +268,42 @@ impl BuildBackendMetadataSpec { "Using `{}` procedure to get metadata information", pixi_build_types::procedures::conda_outputs::METHOD_NAME ); - let metadata = self + let mut metadata = self .call_conda_outputs( - command_dispatcher, + command_dispatcher.clone(), build_source_checkout, + project_model_hash, backend, - additional_glob_hash, log_sink, ) .await?; - // Store the metadata in the cache for later retrieval - cache_entry - .write(metadata.clone()) + metadata.cache_version = cache_version; + + // Try to store the metadata in the cache with version checking. + // If another process updated the cache while we were computing, we get a conflict. + match command_dispatcher + .build_backend_metadata_cache() + .try_write(&cache_key, metadata.clone(), cache_version) .await .map_err(BuildBackendMetadataError::Cache) - .map_err(CommandDispatcherError::Failed)?; + .map_err(CommandDispatcherError::Failed)? + { + build_backend_metadata::WriteResult::Written => { + tracing::trace!("Cache updated successfully"); + } + build_backend_metadata::WriteResult::Conflict(_other_metadata) => { + // Another process computed and cached metadata while we were computing. + // We use our computed result. + tracing::debug!( + "Cache was updated by another process during computation (version conflict), using our computed result" + ); + } + } Ok(BuildBackendMetadata { - source: source_location, + source: manifest_source_location, metadata, - cache_entry, skip_cache, }) } @@ -343,57 +362,97 @@ impl BuildBackendMetadataSpec { } async fn verify_cache_freshness( - source_checkout: &SourceCheckout, - command_dispatcher: &CommandDispatcher, - metadata: Option, - additional_glob_hash: &[u8], + cache_entry: Option, + build_source_checkout: &SourceCheckout, + project_model_hash: Option, requested_variants: &Option>>, ) -> Result, CommandDispatcherError> { - let Some(metadata) = metadata else { + let Some(cache_entry) = cache_entry else { return Ok(None); }; - let metadata_kind = match metadata.metadata { - MetadataKind::GetMetadata { .. } => "conda/getMetadata", - MetadataKind::Outputs { .. } => { - pixi_build_types::procedures::conda_outputs::METHOD_NAME - } - }; + // Check the project model + if cache_entry.project_model_hash != project_model_hash { + tracing::info!( + "found cached outputs with different project model, invalidating cache." + ); + return Ok(None); + } - // Check if the build variants match - if metadata.build_variants != *requested_variants { - tracing::trace!( - "found cached `{metadata_kind}` response with different variants, invalidating cache." + // Check if the source location changed. + if cache_entry.build_source != build_source_checkout.pinned { + tracing::info!( + "found cached outputs with different source code location, invalidating cache." ); return Ok(None); } - let Some(input_globs) = &metadata.input_hash else { - // No input hash so just assume it is still valid. - tracing::trace!("found cached `{metadata_kind}` response."); - return Ok(Some(metadata)); - }; + // Check if the build variants match + if Some(&cache_entry.build_variants) != requested_variants.as_ref() { + tracing::info!("found cached outputs with different variants, invalidating cache."); + return Ok(None); + } - // Check if the input hash is still valid. - let new_hash = command_dispatcher - .glob_hash_cache() - .compute_hash(GlobHashKey::new( - source_checkout.path.clone(), - input_globs.globs.clone(), - additional_glob_hash.to_vec(), - )) - .await - .map_err(BuildBackendMetadataError::GlobHash) - .map_err(CommandDispatcherError::Failed)?; + // If the build source is immutable, we don't check the contents of the files. + if build_source_checkout.is_immutable() { + return Ok(Some(cache_entry)); + } - if new_hash.hash == input_globs.hash { - tracing::trace!("found up-to-date cached `{metadata_kind}` response.."); - Ok(Some(metadata)) - } else { - tracing::trace!("found stale `{metadata_kind}` response.."); - Ok(None) + let build_source_dir = build_source_checkout.path.as_dir_or_file_parent(); + + // Check the files that were explicitly mentioned. + for source_file_path in cache_entry + .input_files + .iter() + .map(|path| build_source_dir.join(path).into_std_path_buf()) + .chain(cache_entry.build_variant_files.iter().cloned()) + { + match source_file_path.metadata().and_then(|m| m.modified()) { + Ok(modified_date) => { + if modified_date > cache_entry.timestamp { + tracing::info!( + "found cached outputs but '{}' has been modified, invalidating cache.", + source_file_path.display() + ); + return Ok(None); + } + } + Err(err) if err.kind() == std::io::ErrorKind::NotFound => { + tracing::info!( + "found cached outputs but '{}' has been deleted, invalidating cache.", + source_file_path.display() + ); + return Ok(None); + } + Err(err) => { + tracing::info!( + "found cached outputs but requested metadata for '{}' failed with: {}", + source_file_path.display(), + err + ); + return Ok(None); + } + }; } + + let glob_set = GlobSet::create(cache_entry.input_globs.iter().map(String::as_str)); + for matching_file in glob_set + .collect_matching(build_source_dir.as_std_path()) + .map_err(BuildBackendMetadataError::from) + .map_err(CommandDispatcherError::Failed)? + { + let path = matching_file.into_path(); + if cache_entry.input_files.contains(&path) { + tracing::info!( + "found cached outputs but a new matching file at '{}' has been detected, invalidating cache.", + path.display() + ); + return Ok(None); + } + } + + Ok(Some(cache_entry)) } /// Validates that outputs with the same name have unique variants. @@ -449,8 +508,8 @@ impl BuildBackendMetadataSpec { self, command_dispatcher: CommandDispatcher, build_source_checkout: SourceCheckout, + project_model_hash: Option, backend: Backend, - additional_glob_hash: Vec, mut log_sink: UnboundedSender, ) -> Result> { let backend_identifier = backend.identifier().to_string(); @@ -473,16 +532,20 @@ impl BuildBackendMetadataSpec { .collect() }), variant_files: self.variant_files.clone(), - work_directory: command_dispatcher.cache_dirs().working_dirs().join( - WorkDirKey { - source: SourceRecordOrCheckout::Checkout { - checkout: build_source_checkout.clone(), - }, - host_platform: self.build_environment.host_platform, - build_backend: backend_identifier.clone(), - } - .key(), - ), + work_directory: command_dispatcher + .cache_dirs() + .working_dirs() + .join( + WorkDirKey { + source: SourceRecordOrCheckout::Checkout { + checkout: build_source_checkout.clone(), + }, + host_platform: self.build_environment.host_platform, + build_backend: backend_identifier.clone(), + } + .key(), + ) + .into_std_path_buf(), }; let outputs = backend .conda_outputs(params, move |line| { @@ -491,6 +554,7 @@ impl BuildBackendMetadataSpec { .await .map_err(BuildBackendMetadataError::Communication) .map_err(CommandDispatcherError::Failed)?; + let timestamp = SystemTime::now(); // If the backend supports unique variants, validate that outputs with the same name // have unique variants @@ -509,70 +573,41 @@ impl BuildBackendMetadataSpec { ); } - // Compute the input globs for the mutable source checkouts. - let input_globs = extend_input_globs_with_variant_files( - outputs.input_globs.clone(), - &self.variant_files, - &build_source_checkout, - ); - tracing::debug!( - backend = %backend_identifier, - source = %build_source_checkout.pinned, - glob_count = input_globs.len(), - "computing metadata input hash", - ); - let input_hash = Self::compute_input_hash( - command_dispatcher, - &build_source_checkout, - input_globs, - additional_glob_hash, - ) - .await?; + // Determine the files that match the input globs. + let globs_root = build_source_checkout.path.as_dir_or_file_parent(); + let input_glob_set = GlobSet::create(outputs.input_globs.iter().map(String::as_str)); + let globs_root_path = globs_root.as_std_path(); + let input_glob_files = input_glob_set + .collect_matching(globs_root_path) + .map_err(BuildBackendMetadataError::from) + .map_err(CommandDispatcherError::Failed)? + .into_iter() + .map(|entry| { + let path = entry.into_path(); + path.strip_prefix(globs_root_path) + .ok() + .unwrap_or(&path) + .to_path_buf() + }) + .collect(); Ok(CachedCondaMetadata { - id: random(), - input_hash: input_hash.clone(), - metadata: MetadataKind::Outputs { - outputs: outputs.outputs, - }, - build_variants: self.variant_configuration.clone(), + id: CachedCondaMetadataId::random(), + cache_version: 0, + outputs: outputs.outputs, + build_variants: self.variant_configuration.unwrap_or_default(), + build_variant_files: self.variant_files.into_iter().flatten().collect(), + input_globs: outputs.input_globs.into_iter().collect(), + input_files: input_glob_files, + build_source: build_source_checkout.pinned, + project_model_hash, + timestamp, }) } - /// Computes the input hash for metadata returned by the backend. - async fn compute_input_hash( - command_queue: CommandDispatcher, - source: &SourceCheckout, - input_globs: BTreeSet, - additional_glob_hash: Vec, - ) -> Result, CommandDispatcherError> { - if source.pinned.is_immutable() { - // If the source is immutable (e.g., a git commit), we do not need to compute an - // input hash because the contents of the source are fixed. - return Ok(None); - } - - // Compute the input hash based on the manifest path and the input globs. - let input_hash = command_queue - .glob_hash_cache() - .compute_hash(GlobHashKey::new( - &source.path, - input_globs.clone(), - additional_glob_hash, - )) - .await - .map_err(BuildBackendMetadataError::GlobHash) - .map_err(CommandDispatcherError::Failed)?; - - Ok(Some(InputHash { - hash: input_hash.hash, - globs: input_globs, - })) - } - /// Computes the cache key for this instance - pub(crate) fn cache_key(&self) -> BuildBackendMetadataKey { - BuildBackendMetadataKey { + pub(crate) fn cache_shard(&self) -> BuildBackendMetadataCacheShard { + BuildBackendMetadataCacheShard { channel_urls: self.channels.clone(), build_environment: self.build_environment.clone(), enabled_protocols: self.enabled_protocols.clone(), @@ -581,28 +616,6 @@ impl BuildBackendMetadataSpec { } } -/// Returns the input glob set extended with any variant file paths -/// relative to the source checkout root. -/// Paths are normalised to use forward slashes so that they are glob-compatible. -fn extend_input_globs_with_variant_files( - mut input_globs: BTreeSet, - variant_files: &Option>, - source_checkout: &SourceCheckout, -) -> BTreeSet { - if let Some(variant_files) = variant_files { - for variant_file in variant_files { - let relative = match variant_file.strip_prefix(&source_checkout.path) { - Ok(stripped) => stripped.to_path_buf(), - Err(_) => diff_paths(variant_file, &source_checkout.path) - .unwrap_or_else(|| variant_file.clone()), - }; - let glob = relative.to_string_lossy().replace("\\", "/"); - input_globs.insert(glob); - } - } - input_globs -} - #[derive(Debug, Error, Diagnostic)] pub enum BuildBackendMetadataError { #[error(transparent)] @@ -635,25 +648,14 @@ pub enum BuildBackendMetadataError { #[error("could not compute hash of input files")] GlobHash(#[from] pixi_glob::GlobHashError), + #[error("failed to determine input file modification times")] + GlobSet(#[from] pixi_glob::GlobSetError), + #[error(transparent)] Cache(#[from] build_backend_metadata::BuildBackendMetadataCacheError), -} -/// Computes an additional hash to be used in glob hash -pub fn calculate_additional_glob_hash( - project_model: &Option, - variants: &Option>>, -) -> Vec { - let mut hasher = Xxh3::new(); - if let Some(project_model) = project_model { - project_model.hash(&mut hasher); - } - if let Some(variants) = variants { - if !variants.is_empty() { - variants.hash(&mut hasher); - } - } - hasher.finish().to_ne_bytes().to_vec() + #[error("failed to normalize path")] + NormalizePath(#[from] pixi_path::NormalizeError), } #[cfg(test)] diff --git a/crates/pixi_command_dispatcher/src/cache/build_backend_metadata.rs b/crates/pixi_command_dispatcher/src/cache/build_backend_metadata.rs index 9cc75576ef..1145d9bac3 100644 --- a/crates/pixi_command_dispatcher/src/cache/build_backend_metadata.rs +++ b/crates/pixi_command_dispatcher/src/cache/build_backend_metadata.rs @@ -1,23 +1,26 @@ -use std::{ - collections::BTreeMap, - hash::{DefaultHasher, Hash, Hasher}, - path::{Path, PathBuf}, +use super::common::{ + CacheError, CacheKey, CachedMetadata, MetadataCache, VersionedMetadata, + WriteResult as CommonWriteResult, }; - +use crate::input_hash::ProjectModelHash; +use crate::{BuildEnvironment, PackageIdentifier, build::source_checkout_cache_key}; use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD}; use pixi_build_discovery::EnabledProtocols; -use pixi_build_types::{CondaPackageMetadata, procedures::conda_outputs::CondaOutput}; -use pixi_record::{InputHash, PinnedSourceSpec, VariantValue}; +use pixi_build_types::procedures::conda_outputs::CondaOutput; +use pixi_path::AbsPathBuf; +use pixi_record::{PinnedSourceSpec, VariantValue}; use rattler_conda_types::ChannelUrl; use serde::{Deserialize, Serialize}; +use std::collections::{BTreeSet, BinaryHeap}; +use std::{ + collections::BTreeMap, + hash::{DefaultHasher, Hash, Hasher}, + path::{Path, PathBuf}, +}; use thiserror::Error; -use crate::{BuildEnvironment, PackageIdentifier, build::source_checkout_cache_key}; - -use super::common::{CacheError, CacheKey, CachedMetadata, MetadataCache}; - -// Re-export CacheEntry with the correct generic type for this cache -pub type CacheEntry = super::common::CacheEntry; +// Re-export WriteResult with the correct type +pub type WriteResult = CommonWriteResult; /// A cache for caching the metadata of a source checkout. /// @@ -29,7 +32,7 @@ pub type CacheEntry = super::common::CacheEntry; /// some additional properties to determine if the cache is still valid. #[derive(Clone, Debug)] pub struct BuildBackendMetadataCache { - root: PathBuf, + root: AbsPathBuf, } #[derive(Debug, Error)] @@ -42,7 +45,7 @@ pub enum BuildBackendMetadataCacheError { /// Defines additional input besides the source files that are used to compute /// the metadata of a source checkout. This is used to bucket the metadata. #[derive(Debug, Clone, Hash, PartialEq, Eq)] -pub struct BuildBackendMetadataKey { +pub struct BuildBackendMetadataCacheShard { /// The URLs of the channels that were used. pub channel_urls: Vec, @@ -61,18 +64,18 @@ impl BuildBackendMetadataCache { pub const CACHE_SUFFIX: &'static str = "v0"; /// Constructs a new instance. - pub fn new(root: PathBuf) -> Self { + pub fn new(root: AbsPathBuf) -> Self { Self { root } } } impl MetadataCache for BuildBackendMetadataCache { - type Key = BuildBackendMetadataKey; + type Key = BuildBackendMetadataCacheShard; type Metadata = CachedCondaMetadata; type Error = BuildBackendMetadataCacheError; fn root(&self) -> &Path { - &self.root + self.root.as_std_path() } fn cache_file_name(&self) -> &'static str { @@ -82,18 +85,21 @@ impl MetadataCache for BuildBackendMetadataCache { const CACHE_SUFFIX: &'static str = "v0"; } -impl CacheKey for BuildBackendMetadataKey { +impl CacheKey for BuildBackendMetadataCacheShard { /// Computes a unique semi-human-readable hash for this key. fn hash_key(&self) -> String { let mut hasher = DefaultHasher::new(); self.channel_urls.hash(&mut hasher); self.build_environment.build_platform.hash(&mut hasher); - self.build_environment - .build_virtual_packages - .hash(&mut hasher); - self.build_environment - .host_virtual_packages - .hash(&mut hasher); + + let mut build_virtual_packages = self.build_environment.build_virtual_packages.clone(); + build_virtual_packages.sort_by(|a, b| a.name.cmp(&b.name)); + build_virtual_packages.hash(&mut hasher); + + let mut host_virtual_packages = self.build_environment.host_virtual_packages.clone(); + host_virtual_packages.sort_by(|a, b| a.name.cmp(&b.name)); + host_virtual_packages.hash(&mut hasher); + self.enabled_protocols.hash(&mut hasher); let source_dir = source_checkout_cache_key(&self.pinned_source); format!( @@ -110,64 +116,93 @@ impl CacheError for BuildBackendMetadataCacheError { } } -/// Cached result of calling `conda/getMetadata` on a build backend. This is -/// returned by [`SourceMetadataCache::entry`]. +/// Cached result of calling `conda/outputs` on a build backend. This is +/// returned by [`MetadataCache::read`]. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct CachedCondaMetadata { /// A randomly generated identifier that is generated for each metadata /// file. - /// - /// Cache information for each output is stored in a separate file, this ID - /// is present in each file. This is to ensure that the cache can be - /// invalidated if the metadata changes. - pub id: u64, + pub id: CachedCondaMetadataId, + + /// Version number for optimistic locking. Incremented with each cache + /// update. Used to detect when another process has updated the cache + /// during computation. + #[serde(default)] + pub cache_version: u64, + /// The hash of the project model. #[serde(default, skip_serializing_if = "Option::is_none")] - pub input_hash: Option, + pub project_model_hash: Option, - #[serde(flatten)] - pub metadata: MetadataKind, + /// The pinned location of the source code. Although the specification of + /// where to find the source is part of the `project_model_hash`, the + /// resolved location is not. + pub build_source: PinnedSourceSpec, /// The build variants that were used to generate this metadata. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub build_variants: Option>>, + #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] + pub build_variants: BTreeMap>, + + /// The build variant files + #[serde(default, skip_serializing_if = "BinaryHeap::is_empty")] + pub build_variant_files: BinaryHeap, + + /// Globs of files from which the metadata was derived. Globs require + /// recursively iterating the filesystem which can be particularly slow so + /// we prefer to store direct file paths instead. However, this does not + /// work for all backends so we also support globs. + /// + /// If the source itself is immutable this is None. + #[serde(default, skip_serializing_if = "BinaryHeap::is_empty")] + pub input_globs: BinaryHeap, + + /// Paths relative to the source checkout of files that were used to + /// determine the metadata. This is the result of the matching the globs + /// against the filesystem. + #[serde(default, skip_serializing_if = "BTreeSet::is_empty")] + pub input_files: BTreeSet, + + /// The timestamp of when the metadata was computed. + pub timestamp: std::time::SystemTime, + + /// The outputs as reported by the build backend. + pub outputs: Vec, } impl CachedMetadata for CachedCondaMetadata {} -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(tag = "type", rename_all = "snake_case")] -pub enum MetadataKind { - /// The result of calling `conda/getMetadata` on a build backend. - GetMetadata { packages: Vec }, +impl VersionedMetadata for CachedCondaMetadata { + fn cache_version(&self) -> u64 { + self.cache_version + } - /// The result of calling `conda/outputs` on a build backend. - Outputs { outputs: Vec }, + fn set_cache_version(&mut self, version: u64) { + self.cache_version = version; + } } impl CachedCondaMetadata { /// Returns the unique package identifiers for the packages in this /// metadata. pub fn outputs(&self) -> Vec { - match &self.metadata { - MetadataKind::GetMetadata { packages } => packages - .iter() - .map(|pkg| PackageIdentifier { - name: pkg.name.clone(), - version: pkg.version.clone(), - build: pkg.build.clone(), - subdir: pkg.subdir.to_string(), - }) - .collect(), - MetadataKind::Outputs { outputs } => outputs - .iter() - .map(|output| PackageIdentifier { - name: output.metadata.name.clone(), - version: output.metadata.version.clone(), - build: output.metadata.build.clone(), - subdir: output.metadata.subdir.to_string(), - }) - .collect(), - } + self.outputs + .iter() + .map(|output| PackageIdentifier { + name: output.metadata.name.clone(), + version: output.metadata.version.clone(), + build: output.metadata.build.clone(), + subdir: output.metadata.subdir.to_string(), + }) + .collect() + } +} + +#[derive(Debug, Clone, Serialize, Deserialize, Copy, PartialEq, Eq)] +#[serde(transparent)] +pub struct CachedCondaMetadataId(u64); + +impl CachedCondaMetadataId { + pub fn random() -> Self { + Self(rand::random()) } } diff --git a/crates/pixi_command_dispatcher/src/cache/common.rs b/crates/pixi_command_dispatcher/src/cache/common.rs index ab5d8404be..a2ed87ce5d 100644 --- a/crates/pixi_command_dispatcher/src/cache/common.rs +++ b/crates/pixi_command_dispatcher/src/cache/common.rs @@ -1,10 +1,6 @@ -use std::{ - io::SeekFrom, - marker::PhantomData, - path::{Path, PathBuf}, -}; +use std::path::{Path, PathBuf}; -use async_fd_lock::{LockWrite, RwLockWriteGuard}; +use async_fd_lock::{LockRead, LockWrite}; use serde::{Serialize, de::DeserializeOwned}; use tokio::io::{AsyncReadExt, AsyncSeekExt, AsyncWriteExt}; @@ -33,28 +29,98 @@ pub trait MetadataCache: Clone + Sized { /// Returns the name of the cache file (e.g., "metadata.json") fn cache_file_name(&self) -> &'static str; - /// Returns the cache entry for the given key. + /// Reads the cached metadata for the given key without holding the lock. + /// Returns the metadata and its version number if it exists. /// - /// Returns the cached metadata if it exists and is still valid and a - /// [`CacheEntry`] that can be used to update the cache. As long as the - /// [`CacheEntry`] is held, another process cannot update the cache. - async fn entry( + /// The lock is released immediately after reading, so the metadata may + /// become stale. Use `try_write` with version checking to detect if the + /// cache was updated by another process. + async fn read(&self, input: &Self::Key) -> Result, Self::Error> + where + Self::Metadata: VersionedMetadata, + { + let cache_dir = self.root().join(input.hash_key()); + let cache_file_path = cache_dir.join(self.cache_file_name()); + + // Try to open the cache file (may not exist yet) + let cache_file = match tokio::fs::File::open(&cache_file_path).await { + Ok(file) => file, + Err(e) if e.kind() == std::io::ErrorKind::NotFound => { + // Cache doesn't exist yet + return Ok(None); + } + Err(e) => { + return Err(Self::Error::from_io_error( + "opening cache file".to_string(), + cache_file_path, + e, + )); + } + }; + + let mut locked_cache_file = cache_file.lock_read().await.map_err(|e| { + Self::Error::from_io_error( + "locking cache file".to_string(), + cache_file_path.clone(), + e.error, + ) + })?; + + // Read contents while holding lock + let mut cache_file_contents = String::new(); + locked_cache_file + .read_to_string(&mut cache_file_contents) + .await + .map_err(|e| { + Self::Error::from_io_error( + "reading cache file".to_string(), + cache_file_path.clone(), + e, + ) + })?; + + // Release lock immediately + drop(locked_cache_file); + + // Parse after lock is released + let metadata: Self::Metadata = match serde_json::from_str(&cache_file_contents) { + Ok(m) => m, + Err(_) => return Ok(None), // Invalid cache + }; + + let version = metadata.cache_version(); + Ok(Some((metadata, version))) + } + + /// Tries to write metadata to the cache with optimistic locking. + /// + /// This method checks if the cache version matches the expected version + /// before writing. If another process has updated the cache since it was + /// read, this method returns `WriteResult::Conflict` with the newer metadata. + /// + /// The lock is held only during the version check and write operation. + async fn try_write( &self, input: &Self::Key, - ) -> Result<(Option, CacheEntry), Self::Error> { - // Locate the cache file and lock it. + metadata: Self::Metadata, + expected_version: u64, + ) -> Result, Self::Error> + where + Self::Metadata: VersionedMetadata, + { let cache_dir = self.root().join(input.hash_key()); tokio::fs::create_dir_all(&cache_dir).await.map_err(|e| { Self::Error::from_io_error("creating cache directory".to_string(), cache_dir.clone(), e) })?; - // Try to acquire a lock on the cache file. let cache_file_path = cache_dir.join(self.cache_file_name()); + + // Open or create the cache file let cache_file = tokio::fs::OpenOptions::new() - .write(true) .read(true) - .truncate(false) + .write(true) .create(true) + .truncate(false) .open(&cache_file_path) .await .map_err(|e| { @@ -65,6 +131,7 @@ pub trait MetadataCache: Clone + Sized { ) })?; + // Acquire lock let mut locked_cache_file = cache_file.lock_write().await.map_err(|e| { Self::Error::from_io_error( "locking cache file".to_string(), @@ -73,10 +140,10 @@ pub trait MetadataCache: Clone + Sized { ) })?; - // Try to parse the contents of the file - let mut cache_file_contents = String::new(); + // Check if cache was updated by another process + let mut current_contents = String::new(); locked_cache_file - .read_to_string(&mut cache_file_contents) + .read_to_string(&mut current_contents) .await .map_err(|e| { Self::Error::from_io_error( @@ -86,79 +153,99 @@ pub trait MetadataCache: Clone + Sized { ) })?; - let metadata = serde_json::from_str(&cache_file_contents).ok(); - Ok(( - metadata, - CacheEntry { - file: locked_cache_file, - path: cache_file_path, - _phantom: PhantomData, - }, - )) - } -} - -/// Trait for cache keys that can compute a unique hash -pub trait CacheKey { - /// Computes a unique semi-human-readable hash for this key. - fn hash_key(&self) -> String; -} - -/// Trait for cached metadata types. -/// -/// Implementors must be serializable and deserializable. -pub trait CachedMetadata: Serialize + DeserializeOwned {} - -/// Error trait to ensure consistent error handling across cache implementations. -pub trait CacheError: std::error::Error + Sized { - /// Creates an error from an I/O error with context about the operation - fn from_io_error(operation: String, path: PathBuf, error: std::io::Error) -> Self; -} - -/// A cache entry returned by [`MetadataCache::entry`] which enables -/// updating the cache. -/// -/// As long as this entry is held, no other process can access this cache entry. -#[derive(Debug)] -pub struct CacheEntry { - file: RwLockWriteGuard, - path: PathBuf, - _phantom: PhantomData, -} - -impl CacheEntry { - /// Writes the given metadata to the cache. - pub async fn write(&mut self, metadata: C::Metadata) -> Result<(), C::Error> { - self.file.seek(SeekFrom::Start(0)).await.map_err(|e| { - C::Error::from_io_error( + // If cache exists and has different version, return conflict + if !current_contents.is_empty() { + if let Ok(current_metadata) = serde_json::from_str::(¤t_contents) + { + if current_metadata.cache_version() != expected_version { + // Cache was updated by another process + drop(locked_cache_file); + return Ok(WriteResult::Conflict(current_metadata)); + } + } + } + + // Version matches (or cache is empty), write new data + let mut new_metadata = metadata; + new_metadata.set_cache_version(expected_version + 1); + + let bytes = + serde_json::to_vec(&new_metadata).expect("serialization to JSON should not fail"); + + // Write to file + locked_cache_file.rewind().await.map_err(|e| { + Self::Error::from_io_error( "seeking to start of cache file".to_string(), - self.path.clone(), + cache_file_path.clone(), e, ) })?; - let bytes = serde_json::to_vec(&metadata).expect("serialization to JSON should not fail"); - - self.file.write_all(&bytes).await.map_err(|e| { - C::Error::from_io_error( + locked_cache_file.write_all(&bytes).await.map_err(|e| { + Self::Error::from_io_error( "writing metadata to cache file".to_string(), - self.path.clone(), + cache_file_path.clone(), e, ) })?; - self.file + // Truncate file to new size + locked_cache_file .inner_mut() .set_len(bytes.len() as u64) .await .map_err(|e| { - C::Error::from_io_error( + Self::Error::from_io_error( "setting length of cache file".to_string(), - self.path.clone(), + cache_file_path.clone(), e, ) })?; - Ok(()) + // Flush to ensure data is written + locked_cache_file.flush().await.map_err(|e| { + Self::Error::from_io_error("flushing cache file".to_string(), cache_file_path, e) + })?; + + // Release lock + drop(locked_cache_file); + + Ok(WriteResult::Written) } } + +/// Trait for cache keys that can compute a unique hash +pub trait CacheKey { + /// Computes a unique semi-human-readable hash for this key. + fn hash_key(&self) -> String; +} + +/// Trait for cached metadata types. +/// +/// Implementors must be serializable and deserializable. +pub trait CachedMetadata: Serialize + DeserializeOwned {} + +/// Trait for cached metadata that supports versioning for optimistic locking. +pub trait VersionedMetadata: CachedMetadata { + /// Gets the current cache version + fn cache_version(&self) -> u64; + + /// Sets the cache version + fn set_cache_version(&mut self, version: u64); +} + +/// Result of attempting to write to the cache with version checking. +#[derive(Debug)] +pub enum WriteResult { + /// The cache was successfully written. + Written, + /// The cache was updated by another process during computation. + /// Contains the metadata that was written by the other process. + Conflict(M), +} + +/// Error trait to ensure consistent error handling across cache implementations. +pub trait CacheError: std::error::Error + Sized { + /// Creates an error from an I/O error with context about the operation + fn from_io_error(operation: String, path: PathBuf, error: std::io::Error) -> Self; +} diff --git a/crates/pixi_command_dispatcher/src/cache/source_metadata.rs b/crates/pixi_command_dispatcher/src/cache/source_metadata.rs index 4fc764eb2d..a7aac3de64 100644 --- a/crates/pixi_command_dispatcher/src/cache/source_metadata.rs +++ b/crates/pixi_command_dispatcher/src/cache/source_metadata.rs @@ -1,22 +1,22 @@ -use std::{ - collections::BTreeMap, - hash::{DefaultHasher, Hash, Hasher}, - path::{Path, PathBuf}, +use super::common::{ + CacheError, CacheKey, CachedMetadata, MetadataCache, WriteResult as CommonWriteResult, }; - +use crate::cache::build_backend_metadata::CachedCondaMetadataId; +use crate::{BuildEnvironment, build::source_checkout_cache_key, cache::common::VersionedMetadata}; use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD}; use pixi_build_discovery::EnabledProtocols; -use pixi_record::{InputHash, PinnedSourceSpec, SourceRecord, VariantValue}; +use pixi_path::AbsPathBuf; +use pixi_record::{PinnedSourceSpec, SourceRecord}; use rattler_conda_types::{ChannelUrl, PackageName}; use serde::{Deserialize, Serialize}; +use std::{ + hash::{DefaultHasher, Hash, Hasher}, + path::{Path, PathBuf}, +}; use thiserror::Error; -use crate::{BuildEnvironment, build::source_checkout_cache_key}; - -use super::common::{CacheError, CacheKey, CachedMetadata, MetadataCache}; - -// Re-export CacheEntry with the correct generic type for this cache -pub type CacheEntry = super::common::CacheEntry; +// Re-export WriteResult with the correct type +pub type WriteResult = CommonWriteResult; /// A cache for caching the metadata of a source checkout. /// @@ -28,7 +28,7 @@ pub type CacheEntry = super::common::CacheEntry; /// some additional properties to determine if the cache is still valid. #[derive(Clone, Debug)] pub struct SourceMetadataCache { - root: PathBuf, + root: AbsPathBuf, } #[derive(Debug, Error)] @@ -41,7 +41,7 @@ pub enum SourceMetadataCacheError { /// Defines additional input besides the source files that are used to compute /// the metadata of a source checkout. This is used to bucket the metadata. #[derive(Debug, Clone, Hash, PartialEq, Eq)] -pub struct SourceMetadataKey { +pub struct SourceMetadataCacheShard { /// The name of the package to retrieve metadata from. pub package: PackageName, @@ -63,18 +63,18 @@ impl SourceMetadataCache { pub const CACHE_SUFFIX: &'static str = "v0"; /// Constructs a new instance. - pub fn new(root: PathBuf) -> Self { + pub fn new(root: AbsPathBuf) -> Self { Self { root } } } impl MetadataCache for SourceMetadataCache { - type Key = SourceMetadataKey; + type Key = SourceMetadataCacheShard; type Metadata = CachedSourceMetadata; type Error = SourceMetadataCacheError; fn root(&self) -> &Path { - &self.root + self.root.as_std_path() } fn cache_file_name(&self) -> &'static str { @@ -84,18 +84,21 @@ impl MetadataCache for SourceMetadataCache { const CACHE_SUFFIX: &'static str = "v0"; } -impl CacheKey for SourceMetadataKey { +impl CacheKey for SourceMetadataCacheShard { /// Computes a unique semi-human-readable hash for this key. fn hash_key(&self) -> String { let mut hasher = DefaultHasher::new(); self.channel_urls.hash(&mut hasher); self.build_environment.build_platform.hash(&mut hasher); - self.build_environment - .build_virtual_packages - .hash(&mut hasher); - self.build_environment - .host_virtual_packages - .hash(&mut hasher); + + let mut build_virtual_packages = self.build_environment.build_virtual_packages.clone(); + build_virtual_packages.sort_by(|a, b| a.name.cmp(&b.name)); + build_virtual_packages.hash(&mut hasher); + + let mut host_virtual_packages = self.build_environment.host_virtual_packages.clone(); + host_virtual_packages.sort_by(|a, b| a.name.cmp(&b.name)); + host_virtual_packages.hash(&mut hasher); + self.enabled_protocols.hash(&mut hasher); let source_dir = source_checkout_cache_key(&self.pinned_source); format!( @@ -114,33 +117,43 @@ impl CacheError for SourceMetadataCacheError { } /// Cached result of calling `conda/getMetadata` on a build backend. This is -/// returned by [`SourceMetadataCache::entry`]. +/// returned by [`MetadataCache::read`]. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct CachedSourceMetadata { /// A randomly generated identifier that is generated for each metadata /// file. - /// - /// Cache information for each output is stored in a separate file, this ID - /// is present in each file. This is to ensure that the cache can be - /// invalidated if the metadata changes. - pub id: u64, + pub id: CachedSourceMetadataId, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub input_hash: Option, + /// Version number for optimistic locking. Incremented with each cache update. + /// Used to detect when another process has updated the cache during computation. + #[serde(default)] + pub cache_version: u64, - /// The build variants that were used to generate this metadata. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub build_variants: Option>>, + /// The id of the backend metadata that was used to compute this metadata. + pub cached_conda_metadata_id: CachedCondaMetadataId, - #[serde(flatten)] - pub metadata: Metadata, + /// The source records + pub records: Vec, } impl CachedMetadata for CachedSourceMetadata {} -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(tag = "type", rename_all = "snake_case")] -pub struct Metadata { - /// All the source records for this particular package. - pub records: Vec, +impl VersionedMetadata for CachedSourceMetadata { + fn cache_version(&self) -> u64 { + self.cache_version + } + + fn set_cache_version(&mut self, version: u64) { + self.cache_version = version; + } +} + +#[derive(Debug, Clone, Serialize, Deserialize, Copy, PartialEq, Eq)] +#[serde(transparent)] +pub struct CachedSourceMetadataId(u64); + +impl CachedSourceMetadataId { + pub fn random() -> Self { + Self(rand::random()) + } } diff --git a/crates/pixi_command_dispatcher/src/cache_dirs.rs b/crates/pixi_command_dispatcher/src/cache_dirs.rs index 964e9e2af0..7f130f90a7 100644 --- a/crates/pixi_command_dispatcher/src/cache_dirs.rs +++ b/crates/pixi_command_dispatcher/src/cache_dirs.rs @@ -1,49 +1,47 @@ -use std::path::PathBuf; - -use pixi_consts::consts; - use crate::build::BuildCache; use crate::cache::build_backend_metadata::BuildBackendMetadataCache; use crate::cache::source_metadata::SourceMetadataCache; +use pixi_consts::consts; +use pixi_path::{AbsPresumedDirPath, AbsPresumedDirPathBuf}; pub struct CacheDirs { /// The root cache directory, all other cache directories are derived from /// this. - root: PathBuf, + root: AbsPresumedDirPathBuf, /// Specifies the cache directory for workspace specific directories. If /// this is not specified the directories are stored in the global /// cache. - workspace: Option, + workspace: Option, /// Directory where environments for build backends are cached. - build_backends: Option, + build_backends: Option, /// The directory where working directory for builds are cached. - work_dirs: Option, + work_dirs: Option, /// The directory where binary packages are cached. - packages: Option, + packages: Option, /// The directory where git repositories are cached. - git: Option, + git: Option, /// The location where to store build backend metadata information. - build_backend_metadata: Option, + build_backend_metadata: Option, /// The directory where url archives are cached. - url: Option, + url: Option, /// The location where to store source metadata information. - source_metadata: Option, + source_metadata: Option, /// The location where to store source builds. - source_builds: Option, + source_builds: Option, } impl CacheDirs { /// Instantiate a new `CacheDirs` instance with the given root directory. - pub fn new(root: PathBuf) -> Self { + pub fn new(root: AbsPresumedDirPathBuf) -> Self { Self { root, workspace: None, @@ -58,7 +56,7 @@ impl CacheDirs { } } - pub fn with_workspace(self, workspace: PathBuf) -> Self { + pub fn with_workspace(self, workspace: AbsPresumedDirPathBuf) -> Self { Self { workspace: Some(workspace), ..self @@ -66,7 +64,7 @@ impl CacheDirs { } /// Sets the directory where source builds - pub fn with_working_dirs(self, working_dirs: PathBuf) -> Self { + pub fn with_working_dirs(self, working_dirs: AbsPresumedDirPathBuf) -> Self { Self { work_dirs: Some(working_dirs), ..self @@ -74,94 +72,108 @@ impl CacheDirs { } /// Sets the working directories for builds. - pub fn set_working_dirs(&mut self, working_dirs: PathBuf) { + pub fn set_working_dirs(&mut self, working_dirs: AbsPresumedDirPathBuf) { self.work_dirs = Some(working_dirs); } /// Returns the root directory for the cache. - pub fn root(&self) -> &PathBuf { + pub fn root(&self) -> &AbsPresumedDirPath { &self.root } /// Returns the workspace directory if it is set, otherwise returns `None`. /// For pixi this would refer to the `.pixi` directory in the workspace. - pub fn workspace(&self) -> Option<&PathBuf> { - self.workspace.as_ref() + pub fn workspace(&self) -> Option<&AbsPresumedDirPath> { + self.workspace.as_deref() } /// Returns the directory that is the root directory to store workspace /// build related caches. - pub fn build(&self) -> PathBuf { + pub fn build(&self) -> AbsPresumedDirPathBuf { self.workspace() - .map(|workspace| workspace.join(consts::WORKSPACE_CACHE_DIR)) + .map(|workspace| { + workspace + .join(consts::WORKSPACE_CACHE_DIR) + .into_assume_dir() + }) .unwrap_or_else(|| self.root.clone()) } /// Returns the directory where build backend environments are cached. - pub fn build_backends(&self) -> PathBuf { - self.build_backends - .clone() - .unwrap_or_else(|| self.root.join(consts::CACHED_BUILD_BACKENDS)) + pub fn build_backends(&self) -> AbsPresumedDirPathBuf { + self.build_backends.clone().unwrap_or_else(|| { + self.root + .join(consts::CACHED_BUILD_BACKENDS) + .into_assume_dir() + }) } /// Returns the directory where working directories are cached. - pub fn working_dirs(&self) -> PathBuf { - self.work_dirs - .clone() - .unwrap_or_else(|| self.build().join(consts::CACHED_BUILD_WORK_DIR)) + pub fn working_dirs(&self) -> AbsPresumedDirPathBuf { + self.work_dirs.clone().unwrap_or_else(|| { + self.build() + .join(consts::CACHED_BUILD_WORK_DIR) + .into_assume_dir() + }) } /// Returns the location to store packages - pub fn packages(&self) -> PathBuf { + pub fn packages(&self) -> AbsPresumedDirPathBuf { self.packages .clone() - .unwrap_or_else(|| self.root.join(consts::CACHED_PACKAGES)) + .unwrap_or_else(|| self.root.join(consts::CACHED_PACKAGES).into_assume_dir()) } /// Returns the directory where git repositories are cached. - pub fn git(&self) -> PathBuf { + pub fn git(&self) -> AbsPresumedDirPathBuf { self.git .clone() - .unwrap_or_else(|| self.root.join(consts::CACHED_GIT_DIR)) + .unwrap_or_else(|| self.root.join(consts::CACHED_GIT_DIR).into_assume_dir()) } /// Returns the directory where git repositories are cached. - pub fn url(&self) -> PathBuf { + pub fn url(&self) -> AbsPresumedDirPathBuf { self.url .clone() - .unwrap_or_else(|| self.root.join(consts::CACHED_URL_DIR)) + .unwrap_or_else(|| self.root.join(consts::CACHED_URL_DIR).into_assume_dir()) } /// Returns the directory where source metadata is cached. - pub fn build_backend_metadata(&self) -> PathBuf { + pub fn build_backend_metadata(&self) -> AbsPresumedDirPathBuf { self.build_backend_metadata.clone().unwrap_or_else(|| { - self.build().join(format!( - "{}-{}", - consts::CACHED_BUILD_BACKEND_METADATA, - BuildBackendMetadataCache::CACHE_SUFFIX - )) + self.build() + .join(format!( + "{}-{}", + consts::CACHED_BUILD_BACKEND_METADATA, + BuildBackendMetadataCache::CACHE_SUFFIX + )) + .into_assume_dir() }) } /// Returns the directory where source metadata is cached. - pub fn source_metadata(&self) -> PathBuf { + pub fn source_metadata(&self) -> AbsPresumedDirPathBuf { self.source_metadata.clone().unwrap_or_else(|| { - self.build().join(format!( - "{}-{}", - consts::CACHED_SOURCE_METADATA, - SourceMetadataCache::CACHE_SUFFIX - )) + self.build() + .join(format!( + "{}-{}", + consts::CACHED_SOURCE_METADATA, + SourceMetadataCache::CACHE_SUFFIX + )) + .into_assume_dir() }) } /// Returns the directory where source builds are cached. - pub fn source_builds(&self) -> PathBuf { + pub fn source_builds(&self) -> AbsPresumedDirPathBuf { self.source_builds.clone().unwrap_or_else(|| { - self.build().join(format!( - "{}-{}", - consts::CACHED_SOURCE_BUILDS, - BuildCache::CACHE_SUFFIX - )) + self.build() + .join(format!( + "{}-{}", + consts::CACHED_SOURCE_BUILDS, + BuildCache::CACHE_SUFFIX + )) + .into_assume_dir() }) } } diff --git a/crates/pixi_command_dispatcher/src/command_dispatcher/builder.rs b/crates/pixi_command_dispatcher/src/command_dispatcher/builder.rs index 634f38d375..65104318ab 100644 --- a/crates/pixi_command_dispatcher/src/command_dispatcher/builder.rs +++ b/crates/pixi_command_dispatcher/src/command_dispatcher/builder.rs @@ -1,14 +1,4 @@ -use std::{path::PathBuf, sync::Arc}; - -use pixi_build_frontend::BackendOverride; -use pixi_git::resolver::GitResolver; -use pixi_glob::GlobHashCache; -use pixi_url::resolver::UrlResolver; -use rattler::package_cache::PackageCache; -use rattler_conda_types::{GenericVirtualPackage, Platform}; -use rattler_networking::LazyClient; -use rattler_repodata_gateway::{Gateway, MaxConcurrency}; -use rattler_virtual_packages::{VirtualPackageOverrides, VirtualPackages}; +use std::sync::Arc; use crate::cache::build_backend_metadata::BuildBackendMetadataCache; use crate::cache::source_metadata::SourceMetadataCache; @@ -20,11 +10,21 @@ use crate::{ command_dispatcher_processor::CommandDispatcherProcessor, limits::ResolvedLimits, }; +use pixi_build_frontend::BackendOverride; +use pixi_git::resolver::GitResolver; +use pixi_glob::GlobHashCache; +use pixi_path::{AbsPathBuf, AbsPresumedDirPathBuf}; +use pixi_url::resolver::UrlResolver; +use rattler::package_cache::PackageCache; +use rattler_conda_types::{GenericVirtualPackage, Platform}; +use rattler_networking::LazyClient; +use rattler_repodata_gateway::{Gateway, MaxConcurrency}; +use rattler_virtual_packages::{VirtualPackageOverrides, VirtualPackages}; #[derive(Default)] pub struct CommandDispatcherBuilder { gateway: Option, - root_dir: Option, + root_dir: Option, reporter: Option>, git_resolver: Option, url_resolver: Option, @@ -88,7 +88,7 @@ impl CommandDispatcherBuilder { } /// Sets the root directory for resolving relative paths. - pub fn with_root_dir(self, root_dir: PathBuf) -> Self { + pub fn with_root_dir(self, root_dir: AbsPresumedDirPathBuf) -> Self { Self { root_dir: Some(root_dir), ..self @@ -145,19 +145,23 @@ impl CommandDispatcherBuilder { /// Completes the builder and returns a new [`CommandDispatcher`]. pub fn finish(self) -> CommandDispatcher { - let root_dir = self - .root_dir - .or(std::env::current_dir().ok()) - .unwrap_or_default(); + let root_dir = self.root_dir.unwrap_or_else(|| { + let current_dir = + std::env::current_dir().expect("failed to determine current directory"); + AbsPathBuf::new(current_dir) + .expect("current directory is not an absolute path") + .into_assume_dir() + }); + let cache_dirs = self .cache_dirs - .unwrap_or_else(|| CacheDirs::new(root_dir.join(".cache"))); + .unwrap_or_else(|| CacheDirs::new(root_dir.join(".cache").into_assume_dir())); let download_client = self.download_client.unwrap_or_default(); let package_cache = PackageCache::new(cache_dirs.packages()); let gateway = self.gateway.unwrap_or_else(|| { Gateway::builder() .with_client(download_client.clone()) - .with_cache_dir(cache_dirs.root().clone()) + .with_cache_dir(cache_dirs.root().to_owned().into_std_path_buf()) .with_package_cache(package_cache.clone()) .with_max_concurrent_requests(self.max_download_concurrency) .finish() @@ -165,10 +169,10 @@ impl CommandDispatcherBuilder { let git_resolver = self.git_resolver.unwrap_or_default(); let build_backend_metadata_cache = - BuildBackendMetadataCache::new(cache_dirs.build_backend_metadata()); + BuildBackendMetadataCache::new(cache_dirs.build_backend_metadata().into()); let url_resolver = self.url_resolver.unwrap_or_default(); - let source_metadata_cache = SourceMetadataCache::new(cache_dirs.source_metadata()); + let source_metadata_cache = SourceMetadataCache::new(cache_dirs.source_metadata().into()); let build_cache = BuildCache::new(cache_dirs.source_builds()); let tool_platform = self.tool_platform.unwrap_or_else(|| { diff --git a/crates/pixi_command_dispatcher/src/command_dispatcher/git.rs b/crates/pixi_command_dispatcher/src/command_dispatcher/git.rs index b6d596ffc6..30ad8a2c31 100644 --- a/crates/pixi_command_dispatcher/src/command_dispatcher/git.rs +++ b/crates/pixi_command_dispatcher/src/command_dispatcher/git.rs @@ -1,4 +1,5 @@ use pixi_git::{GitError, GitUrl, git::GitReference, source::Fetch}; +use pixi_path::AbsPathBuf; use pixi_record::{PinnedGitCheckout, PinnedGitSpec, PinnedSourceSpec}; use pixi_spec::GitSpec; @@ -46,17 +47,7 @@ impl CommandDispatcher { }, }; - // Include any subdirectory - let path = if let Some(subdir) = git_spec.subdirectory { - fetch.path().join(subdir) - } else { - fetch.into_path() - }; - - Ok(SourceCheckout { - path, - pinned: PinnedSourceSpec::Git(pinned), - }) + Self::fetch_to_checkout(fetch, pinned) } /// Check out a particular git repository. @@ -85,16 +76,27 @@ impl CommandDispatcher { .await .map_err(|err| err.map(SourceCheckoutError::from))?; - // Include any subdirectory - let path = if let Some(subdir) = git_spec.source.subdirectory.as_ref() { - fetch.path().join(subdir) + Self::fetch_to_checkout(fetch, git_spec) + } + + #[allow(clippy::result_large_err)] + fn fetch_to_checkout( + fetch: Fetch, + pinned: PinnedGitSpec, + ) -> Result> { + let root_dir = AbsPathBuf::new(fetch.into_path()) + .expect("git checkout returned a relative path") + .into_assume_dir(); + + let path = if let Some(subdir) = &pinned.source.subdirectory { + root_dir.join(subdir).into_assume_dir() } else { - fetch.into_path() + root_dir }; Ok(SourceCheckout { - path, - pinned: PinnedSourceSpec::Git(git_spec), + path: path.into(), + pinned: PinnedSourceSpec::Git(pinned), }) } } diff --git a/crates/pixi_command_dispatcher/src/command_dispatcher/instantiate_backend.rs b/crates/pixi_command_dispatcher/src/command_dispatcher/instantiate_backend.rs index c879ff8209..9d822df9aa 100644 --- a/crates/pixi_command_dispatcher/src/command_dispatcher/instantiate_backend.rs +++ b/crates/pixi_command_dispatcher/src/command_dispatcher/instantiate_backend.rs @@ -1,5 +1,11 @@ -use std::path::PathBuf; - +use crate::{ + BuildEnvironment, CommandDispatcher, CommandDispatcherErrorResultExt, SourceCheckoutError, + command_dispatcher::error::CommandDispatcherError, + instantiate_tool_env::{ + InstantiateToolEnvironmentError, InstantiateToolEnvironmentResult, + InstantiateToolEnvironmentSpec, + }, +}; use miette::Diagnostic; use ordermap::OrderMap; use pixi_build_discovery::{BackendSpec, CommandSpec, EnabledProtocols}; @@ -11,6 +17,7 @@ use pixi_build_frontend::{ use pixi_build_types::{ PixiBuildApiVersion, ProjectModelV1, TargetSelectorV1, procedures::initialize::InitializeParams, }; +use pixi_path::{AbsPresumedDirPathBuf, AbsPresumedFilePathBuf}; use pixi_spec::SpecConversionError; use rattler_conda_types::ChannelConfig; use rattler_shell::{ @@ -20,25 +27,16 @@ use rattler_shell::{ use rattler_virtual_packages::DetectVirtualPackageError; use thiserror::Error; -use crate::{ - BuildEnvironment, CommandDispatcher, CommandDispatcherErrorResultExt, SourceCheckoutError, - command_dispatcher::error::CommandDispatcherError, - instantiate_tool_env::{ - InstantiateToolEnvironmentError, InstantiateToolEnvironmentResult, - InstantiateToolEnvironmentSpec, - }, -}; - #[derive(Debug)] pub struct InstantiateBackendSpec { /// The backend specification pub backend_spec: BackendSpec, /// The root directory of the workspace. - pub workspace_root: PathBuf, + pub workspace_root: AbsPresumedDirPathBuf, /// The absolute path of the discovered manifest - pub manifest_path: PathBuf, + pub manifest_path: AbsPresumedFilePathBuf, /// Optionally, the manifest of the discovered package. pub project_model: Option, @@ -50,7 +48,7 @@ pub struct InstantiateBackendSpec { pub target_configuration: Option>, /// The source directory to use for the backend - pub build_source_dir: PathBuf, + pub build_source_dir: AbsPresumedDirPathBuf, /// The channel configuration to use for any source packages required by the /// backend. @@ -90,10 +88,10 @@ impl CommandDispatcher { if let Some(in_mem) = backend { let memory = in_mem .initialize(InitializeParams { - manifest_path: spec.manifest_path, + manifest_path: spec.manifest_path.to_std_path_buf(), source_dir: Some(source_dir), - workspace_root: Some(spec.workspace_root), - cache_directory: Some(self.cache_dirs().root().clone()), + workspace_root: Some(spec.workspace_root.to_std_path_buf()), + cache_directory: Some(self.cache_dirs().root().to_owned().into()), project_model: spec.project_model.map(Into::into), configuration: spec.configuration, target_configuration: spec.target_configuration, @@ -187,12 +185,12 @@ impl CommandDispatcher { JsonRpcBackend::setup( source_dir, - spec.manifest_path, - spec.workspace_root, + spec.manifest_path.to_std_path_buf(), + spec.workspace_root.to_std_path_buf(), spec.project_model, spec.configuration, spec.target_configuration, - Some(self.cache_dirs().root().clone()), + Some(self.cache_dirs().root().to_owned().into()), tool, ) .await diff --git a/crates/pixi_command_dispatcher/src/command_dispatcher/mod.rs b/crates/pixi_command_dispatcher/src/command_dispatcher/mod.rs index 8389266414..e17fbec9d0 100644 --- a/crates/pixi_command_dispatcher/src/command_dispatcher/mod.rs +++ b/crates/pixi_command_dispatcher/src/command_dispatcher/mod.rs @@ -7,7 +7,7 @@ //! and supporting concurrent operations. use std::{ - path::{Component, Path, PathBuf}, + path::{Path, PathBuf}, sync::Arc, }; @@ -19,6 +19,7 @@ use pixi_build_discovery::{DiscoveredBackend, EnabledProtocols}; use pixi_build_frontend::BackendOverride; use pixi_git::resolver::GitResolver; use pixi_glob::GlobHashCache; +use pixi_path::{AbsPathBuf, AbsPresumedDirPathBuf}; use pixi_record::{PinnedPathSpec, PinnedSourceSpec, PixiRecord}; use pixi_spec::{SourceLocationSpec, UrlSpec}; use pixi_url::UrlResolver; @@ -125,7 +126,7 @@ pub(crate) struct CommandDispatcherData { pub url_resolver: UrlResolver, /// The base directory to use if relative paths are discovered. - pub root_dir: PathBuf, + pub root_dir: AbsPresumedDirPathBuf, /// The location to store caches. pub cache_dirs: CacheDirs, @@ -719,58 +720,31 @@ impl CommandDispatcherData { /// /// This function does not check if the path exists and also does not follow /// symlinks. - fn resolve_typed_path(&self, path_spec: Utf8TypedPath) -> Result { + fn resolve_typed_path(&self, path_spec: Utf8TypedPath) -> Result { if path_spec.is_absolute() { - Ok(Path::new(path_spec.as_str()).to_path_buf()) + // SAFETY: we checked that the path is absolute + Ok(unsafe { AbsPathBuf::new_unchecked(PathBuf::from(path_spec.as_str())) }) } else if let Ok(user_path) = path_spec.strip_prefix("~/") { let home_dir = dirs::home_dir().ok_or_else(|| { InvalidPathError::CouldNotDetermineHomeDirectory(PathBuf::from(path_spec.as_str())) })?; - debug_assert!(home_dir.is_absolute()); - normalize_absolute_path(&home_dir.join(Path::new(user_path.as_str()))) + let home_dir = AbsPathBuf::new(home_dir) + .expect("the home directory is absolute") + .into_assume_dir(); + home_dir + .join(Path::new(user_path.as_str())) + .normalized() + .map_err(Into::into) } else { - let root_dir = self.root_dir.as_path(); let native_path = Path::new(path_spec.as_str()); - debug_assert!(root_dir.is_absolute()); - normalize_absolute_path(&root_dir.join(native_path)) + self.root_dir + .join(native_path) + .normalized() + .map_err(Into::into) } } } -/// Normalize a path, removing things like `.` and `..`. -/// -/// Source: -fn normalize_absolute_path(path: &Path) -> Result { - let mut components = path.components().peekable(); - let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().copied() { - components.next(); - PathBuf::from(c.as_os_str()) - } else { - PathBuf::new() - }; - - for component in components { - match component { - Component::Prefix(..) => unreachable!(), - Component::RootDir => { - ret.push(component.as_os_str()); - } - Component::CurDir => {} - Component::ParentDir => { - if !ret.pop() { - return Err(InvalidPathError::RelativePathEscapesRoot( - path.to_path_buf(), - )); - } - } - Component::Normal(c) => { - ret.push(c); - } - } - } - Ok(ret) -} - /// Defines the inputs and outputs of a certain foreground task specification. pub(crate) trait TaskSpec { type Output; diff --git a/crates/pixi_command_dispatcher/src/command_dispatcher/url.rs b/crates/pixi_command_dispatcher/src/command_dispatcher/url.rs index bd10aaf1fb..30d8f3735d 100644 --- a/crates/pixi_command_dispatcher/src/command_dispatcher/url.rs +++ b/crates/pixi_command_dispatcher/src/command_dispatcher/url.rs @@ -1,5 +1,4 @@ -use std::path::PathBuf; - +use pixi_path::AbsPresumedDirPathBuf; use pixi_record::{PinnedSourceSpec, PinnedUrlSpec}; use pixi_spec::UrlSpec; pub use pixi_url::UrlError; @@ -10,12 +9,13 @@ use crate::{CommandDispatcher, CommandDispatcherError, SourceCheckout, SourceChe #[derive(Debug, Clone, PartialEq, Eq)] pub struct UrlCheckout { pub pinned_url: PinnedUrlSpec, + /// Directory which contains checkout. - pub dir: PathBuf, + pub dir: AbsPresumedDirPathBuf, } impl UrlCheckout { - pub fn into_path(self) -> PathBuf { + pub fn into_path(self) -> AbsPresumedDirPathBuf { self.dir } } @@ -40,7 +40,7 @@ impl CommandDispatcher { .map_err(|err| err.map(SourceCheckoutError::from))?; Ok(SourceCheckout { - path: dir, + path: dir.into(), pinned: PinnedSourceSpec::Url(pinned_url), }) } @@ -80,7 +80,7 @@ impl CommandDispatcher { let path = fetch.into_path(); Ok(SourceCheckout { - path, + path: path.into(), pinned: PinnedSourceSpec::Url(pinned_url_spec), }) } diff --git a/crates/pixi_command_dispatcher/src/command_dispatcher_processor/git.rs b/crates/pixi_command_dispatcher/src/command_dispatcher_processor/git.rs index 6911bd1da5..c93610af5b 100644 --- a/crates/pixi_command_dispatcher/src/command_dispatcher_processor/git.rs +++ b/crates/pixi_command_dispatcher/src/command_dispatcher_processor/git.rs @@ -51,7 +51,7 @@ impl CommandDispatcherProcessor { task.cancellation_token .run_until_cancelled_owned(async move { resolver - .fetch(task.spec.clone(), client, cache_dir, None) + .fetch(task.spec.clone(), client, cache_dir.into(), None) .await .map_err(CommandDispatcherError::Failed) }) diff --git a/crates/pixi_command_dispatcher/src/command_dispatcher_processor/url.rs b/crates/pixi_command_dispatcher/src/command_dispatcher_processor/url.rs index 003946fc91..f6ce5df4b6 100644 --- a/crates/pixi_command_dispatcher/src/command_dispatcher_processor/url.rs +++ b/crates/pixi_command_dispatcher/src/command_dispatcher_processor/url.rs @@ -1,6 +1,7 @@ use std::collections::hash_map::Entry; use futures::FutureExt; +use pixi_path::AbsPathBuf; use super::{CommandDispatcherProcessor, PendingUrlCheckout, PendingUrlWaiter, TaskResult}; use crate::{ @@ -81,11 +82,13 @@ impl CommandDispatcherProcessor { cancellation_token .run_until_cancelled_owned(async move { resolver - .fetch(spec, client, cache_dir, None) + .fetch(spec, client, cache_dir.into_std_path_buf(), None) .await .map(|fetch| UrlCheckout { pinned_url: fetch.pinned().clone(), - dir: fetch.path().to_path_buf(), + dir: AbsPathBuf::new(fetch.path()) + .expect("url fetch does not return absolute path") + .into_assume_dir(), }) .map_err(CommandDispatcherError::Failed) }) diff --git a/crates/pixi_command_dispatcher/src/dev_source_metadata/mod.rs b/crates/pixi_command_dispatcher/src/dev_source_metadata/mod.rs index f4549c7d7c..619ce44afa 100644 --- a/crates/pixi_command_dispatcher/src/dev_source_metadata/mod.rs +++ b/crates/pixi_command_dispatcher/src/dev_source_metadata/mod.rs @@ -11,8 +11,6 @@ use crate::{ CommandDispatcherErrorResultExt, }; -use crate::cache::build_backend_metadata::MetadataKind; - /// A specification for retrieving dev source metadata. /// /// This queries the build backend for all outputs from a source and creates @@ -78,16 +76,6 @@ impl DevSourceMetadataSpec { .map_err_with(Box::new) .map_err_with(DevSourceMetadataError::BuildBackendMetadata)?; - // We only support the Outputs protocol for dev sources - let outputs = match &build_backend_metadata.metadata.metadata { - MetadataKind::Outputs { outputs } => outputs, - MetadataKind::GetMetadata { .. } => { - return Err(CommandDispatcherError::Failed( - DevSourceMetadataError::UnsupportedProtocol, - )); - } - }; - // Create a SourceAnchor for resolving relative paths in dependencies let source_anchor = SourceAnchor::from(pixi_spec::SourceSpec::from( build_backend_metadata.source.manifest_source().clone(), @@ -95,14 +83,13 @@ impl DevSourceMetadataSpec { // Create a DevSourceRecord for each output let mut records = Vec::new(); - for output in outputs { + for output in &build_backend_metadata.metadata.outputs { if output.metadata.name != self.package_name { continue; } let record = Self::create_dev_source_record( output, build_backend_metadata.source.manifest_source(), - &build_backend_metadata.metadata.input_hash, &source_anchor, )?; records.push(record); @@ -121,7 +108,6 @@ impl DevSourceMetadataSpec { fn create_dev_source_record( output: &pixi_build_types::procedures::conda_outputs::CondaOutput, source: &PinnedSourceSpec, - input_hash: &Option, source_anchor: &SourceAnchor, ) -> Result> { // Combine all dependencies into a single map @@ -186,7 +172,6 @@ impl DevSourceMetadataSpec { Ok(DevSourceRecord { name: output.metadata.name.clone(), source: source.clone(), - input_hash: input_hash.clone(), variants: variant_values .clone() .into_iter() diff --git a/crates/pixi_command_dispatcher/src/input_hash.rs b/crates/pixi_command_dispatcher/src/input_hash.rs new file mode 100644 index 0000000000..ca2d884829 --- /dev/null +++ b/crates/pixi_command_dispatcher/src/input_hash.rs @@ -0,0 +1,25 @@ +use pixi_build_types::ProjectModelV1; +use rattler_digest::Sha256Hash; +use serde::{Deserialize, Serialize}; +use std::collections::BTreeSet; +use std::hash::{Hash, Hasher}; +use xxhash_rust::xxh3::Xxh3; + +#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[serde(transparent)] +pub struct ProjectModelHash(u64); + +impl From<&'_ ProjectModelV1> for ProjectModelHash { + fn from(value: &'_ ProjectModelV1) -> Self { + let mut hasher = Xxh3::new(); + value.hash(&mut hasher); + Self(hasher.finish()) + } +} + +/// Describes the combined hashes of a set of files +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +pub struct GlobHash { + pub globs: BTreeSet, + pub hash: Sha256Hash, +} diff --git a/crates/pixi_command_dispatcher/src/lib.rs b/crates/pixi_command_dispatcher/src/lib.rs index 98dfb9fe87..250e677df7 100644 --- a/crates/pixi_command_dispatcher/src/lib.rs +++ b/crates/pixi_command_dispatcher/src/lib.rs @@ -42,6 +42,7 @@ mod command_dispatcher_processor; mod dev_source_metadata; mod discover_backend_cache; mod executor; +mod input_hash; mod install_pixi; mod instantiate_tool_env; mod limits; @@ -59,10 +60,12 @@ pub use backend_source_build::{ BackendSourceBuildPrefix, BackendSourceBuildSpec, BackendSourceBuildV1Method, }; pub use build::BuildEnvironment; -pub use build_backend_metadata::calculate_additional_glob_hash; pub use build_backend_metadata::{ BuildBackendMetadata, BuildBackendMetadataError, BuildBackendMetadataSpec, }; +pub use cache::build_backend_metadata::{BuildBackendMetadataCache, CachedCondaMetadata}; +pub use cache::common::MetadataCache; +pub use cache::source_metadata::{CachedSourceMetadata, SourceMetadataCache}; pub use cache_dirs::CacheDirs; pub use command_dispatcher::{ CommandDispatcher, CommandDispatcherBuilder, CommandDispatcherError, diff --git a/crates/pixi_command_dispatcher/src/solve_conda/mod.rs b/crates/pixi_command_dispatcher/src/solve_conda/mod.rs index 6c53268959..4899a1b7fe 100644 --- a/crates/pixi_command_dispatcher/src/solve_conda/mod.rs +++ b/crates/pixi_command_dispatcher/src/solve_conda/mod.rs @@ -123,7 +123,7 @@ impl SolveCondaEnvironmentSpec { let package_names_from_source = self .source_repodata .iter() - .flat_map(|metadata| &metadata.cached_metadata.metadata.records) + .flat_map(|metadata| &metadata.cached_metadata.records) .map(|metadata| &metadata.package_record.name) .dedup() .collect::>(); @@ -188,7 +188,7 @@ impl SolveCondaEnvironmentSpec { // Add source records for source_metadata in &self.source_repodata { - for record in &source_metadata.cached_metadata.metadata.records { + for record in &source_metadata.cached_metadata.records { let url = unique_url(record); let repodata_record = RepoDataRecord { package_record: record.package_record.clone(), diff --git a/crates/pixi_command_dispatcher/src/solve_pixi/source_metadata_collector.rs b/crates/pixi_command_dispatcher/src/solve_pixi/source_metadata_collector.rs index ddefcaff9c..550e0b24dc 100644 --- a/crates/pixi_command_dispatcher/src/solve_pixi/source_metadata_collector.rs +++ b/crates/pixi_command_dispatcher/src/solve_pixi/source_metadata_collector.rs @@ -123,7 +123,7 @@ impl SourceMetadataCollector { let (source_metadata, mut chain) = source_metadata?; // Process transitive dependencies - for record in &source_metadata.cached_metadata.metadata.records { + for record in &source_metadata.cached_metadata.records { chain.push(record.package_record.name.clone()); let anchor = SourceAnchor::from(SourceSpec::from(record.manifest_source.clone())); for depend in &record.package_record.depends { @@ -232,7 +232,7 @@ impl SourceMetadataCollector { // Make sure that a package with the name defined in spec is available from the // backend. - if source_metadata.cached_metadata.metadata.records.is_empty() { + if source_metadata.cached_metadata.records.is_empty() { return Err(CommandDispatcherError::Failed( CollectSourceMetadataError::PackageMetadataNotFound { name, diff --git a/crates/pixi_command_dispatcher/src/source_build/mod.rs b/crates/pixi_command_dispatcher/src/source_build/mod.rs index 9537fc86b9..f9914bab1c 100644 --- a/crates/pixi_command_dispatcher/src/source_build/mod.rs +++ b/crates/pixi_command_dispatcher/src/source_build/mod.rs @@ -9,6 +9,7 @@ use miette::Diagnostic; use pixi_build_discovery::EnabledProtocols; use pixi_build_frontend::Backend; use pixi_build_types::procedures::conda_outputs::CondaOutputsParams; +use pixi_path::AbsPath; use pixi_record::{PinnedSourceSpec, PixiRecord, VariantValue}; use pixi_spec::{SourceAnchor, SourceLocationSpec, SourceSpec}; use rattler_conda_types::{ @@ -236,7 +237,7 @@ impl SourceBuildSpec { // path). let discovered_backend = command_dispatcher .discover_backend( - &manifest_source_checkout.path, + manifest_source_checkout.path.as_std_path(), self.channel_config.clone(), self.enabled_protocols.clone(), ) @@ -292,11 +293,20 @@ impl SourceBuildSpec { .resolve(SourceAnchor::from(SourceSpec::from( manifest_source.clone(), ))), - build_source_dir: build_source_checkout.path.clone(), + build_source_dir: build_source_checkout + .path + .as_dir_or_file_parent() + .to_path_buf(), channel_config: self.channel_config.clone(), enabled_protocols: self.enabled_protocols.clone(), - workspace_root: discovered_backend.init_params.workspace_root.clone(), - manifest_path: discovered_backend.init_params.manifest_path.clone(), + workspace_root: AbsPath::new(&discovered_backend.init_params.workspace_root) + .expect("workspace root is not absolute") + .assume_dir() + .to_path_buf(), + manifest_path: AbsPath::new(&discovered_backend.init_params.manifest_path) + .expect("manifest path is not absolute") + .assume_file() + .to_path_buf(), project_model: discovered_backend.init_params.project_model.clone(), configuration: discovered_backend.init_params.configuration.clone(), target_configuration: discovered_backend.init_params.target_configuration.clone(), @@ -307,17 +317,21 @@ impl SourceBuildSpec { // Determine the working directory for the build. let work_directory = match std::mem::take(&mut self.work_directory) { Some(work_directory) => work_directory, - None => command_dispatcher.cache_dirs().working_dirs().join( - WorkDirKey { - source: SourceRecordOrCheckout::Record { - pinned: manifest_source.clone(), - package_name: self.package.name.clone(), - }, - host_platform: self.build_environment.host_platform, - build_backend: backend.identifier().to_string(), - } - .key(), - ), + None => command_dispatcher + .cache_dirs() + .working_dirs() + .join( + WorkDirKey { + source: SourceRecordOrCheckout::Record { + pinned: manifest_source.clone(), + package_name: self.package.name.clone(), + }, + host_platform: self.build_environment.host_platform, + build_backend: backend.identifier().to_string(), + } + .key(), + ) + .into_std_path_buf(), }; tracing::debug!( source = %manifest_source, @@ -337,11 +351,17 @@ impl SourceBuildSpec { // Build the package using the v1 build method. let source_for_logging = manifest_source.clone(); + let source_dir = build_source_checkout + .path + .as_dir_or_file_parent() + .as_std_path() + .to_path_buf(); let mut built_source = self .build_v1( command_dispatcher, backend, work_directory, + source_dir, package_build_input_hash, reporter, log_sink, @@ -499,11 +519,13 @@ impl SourceBuildSpec { self.build_profile == BuildProfile::Development && self.source.source_code().is_mutable() } + #[allow(clippy::too_many_arguments)] async fn build_v1( self, command_dispatcher: CommandDispatcher, backend: Backend, work_directory: PathBuf, + source_dir: PathBuf, package_build_input_hash: PackageBuildInputHash, reporter: Option>, mut log_sink: UnboundedSender, @@ -614,7 +636,7 @@ impl SourceBuildSpec { reporter.clone(), ) .await - .map_err(SourceBuildError::from) + .map_err(|err| SourceBuildError::RunExportsExtraction(String::from("build"), err)) .map_err(CommandDispatcherError::Failed)?; // Solve the host environment for the output. @@ -646,7 +668,7 @@ impl SourceBuildSpec { reporter, ) .await - .map_err(SourceBuildError::from) + .map_err(|err| SourceBuildError::RunExportsExtraction(String::from("host"), err)) .map_err(CommandDispatcherError::Failed)?; // Install the build environment @@ -761,7 +783,7 @@ impl SourceBuildSpec { }), backend, package: self.package, - source: manifest_source, + source_dir, work_directory, channels: self.channels, channel_config: self.channel_config, @@ -772,7 +794,8 @@ impl SourceBuildSpec { Ok(BuiltPackage { output_file: built_source.output_file, metadata: CachedBuildSourceInfo { - globs: built_source.input_globs, + input_globs: built_source.input_globs, + input_files: built_source.input_files, build: BuildHostEnvironment { packages: build_records, }, @@ -886,8 +909,8 @@ pub enum SourceBuildError { #[error(transparent)] BuildCache(#[from] BuildCacheError), - #[error("failed to amend run exports: {0}")] - RunExportsExtraction(#[from] RunExportExtractorError), + #[error("failed to amend run exports for {0} environment")] + RunExportsExtraction(String, #[source] RunExportExtractorError), #[error(transparent)] CreateWorkDirectory(std::io::Error), @@ -965,6 +988,9 @@ pub enum SourceBuildError { #[error("the package does not contain a valid subdir")] ConvertSubdir(#[source] ConvertSubdirError), + + #[error(transparent)] + GlobSet(#[from] pixi_glob::GlobSetError), } impl From for SourceBuildError { @@ -985,6 +1011,7 @@ impl From for SourceBuildError { SourceBuildCacheStatusError::SourceCheckout(err) => { SourceBuildError::SourceCheckout(err) } + SourceBuildCacheStatusError::GlobSet(err) => SourceBuildError::GlobSet(err), SourceBuildCacheStatusError::Cycle => { unreachable!("a build time cycle should never happen") } diff --git a/crates/pixi_command_dispatcher/src/source_build_cache_status/mod.rs b/crates/pixi_command_dispatcher/src/source_build_cache_status/mod.rs index c9bdaa6767..a6b4fa0a43 100644 --- a/crates/pixi_command_dispatcher/src/source_build_cache_status/mod.rs +++ b/crates/pixi_command_dispatcher/src/source_build_cache_status/mod.rs @@ -1,10 +1,9 @@ use std::{fmt, path::PathBuf}; -use chrono::Utc; use itertools::chain; use miette::Diagnostic; use pixi_build_discovery::EnabledProtocols; -use pixi_glob::GlobModificationTime; +use pixi_glob::GlobSet; use pixi_record::PinnedSourceSpec; use rattler_conda_types::{ChannelConfig, ChannelUrl}; use tokio::sync::Mutex; @@ -162,7 +161,10 @@ impl SourceBuildCacheStatusSpec { Ok(SourceBuildCacheEntry { cached_build: Mutex::new(cached_build), - cache_dir: build_cache_entry.cache_dir().to_path_buf(), + cache_dir: build_cache_entry + .cache_dir() + .to_path_buf() + .into_std_path_buf(), entry: Mutex::new(build_cache_entry), }) } @@ -330,7 +332,7 @@ impl SourceBuildCacheStatusSpec { // Determine the backend parameters for the package. let backend = command_dispatcher .discover_backend( - &source_checkout.path, + source_checkout.path.as_std_path(), self.channel_config.clone(), self.enabled_protocols.clone(), ) @@ -364,7 +366,11 @@ impl SourceBuildCacheStatusSpec { ) -> Result> { // If there are no source globs, we always consider the cached package // up-to-date. - let Some(source_info) = cached_build.source.as_ref().filter(|p| !p.globs.is_empty()) else { + let Some(source_info) = cached_build + .source + .as_ref() + .filter(|p| !p.input_globs.is_empty()) + else { return Ok(CachedBuildStatus::UpToDate(cached_build)); }; @@ -374,46 +380,66 @@ impl SourceBuildCacheStatusSpec { .await .map_err_with(SourceBuildCacheStatusError::SourceCheckout)?; - // Compute the modification time of the files that match the source input globs. - let glob_time = match GlobModificationTime::from_patterns( - &source_build_checkout.path, - source_info.globs.iter().map(String::as_str), - ) { - Ok(glob_time) => glob_time, - Err(e) => { - tracing::warn!( - "failed to determine modification time of input files: {}. Assuming the package is out-of-date.", - e - ); - return Ok(CachedBuildStatus::Stale(cached_build)); - } - }; + let source_dir = source_build_checkout.path.as_std_path(); + let timestamp = cached_build.record.package_record.timestamp; - // Determine the staleness of the package based on the timestamps of the last - // updated file and the package itself. - match glob_time { - GlobModificationTime::MatchesFound { - modified_at, - designated_file, - } => { - if cached_build - .record - .package_record - .timestamp - .map(|t| t < chrono::DateTime::::from(modified_at)) - .unwrap_or(true) - { + // Check the files that were explicitly recorded at cache time. + // This detects file modifications and deletions. + for source_file_path in source_info + .input_files + .iter() + .map(|path| source_dir.join(path)) + { + match source_file_path.metadata().and_then(|m| m.modified()) { + Ok(modified_date) => { + // Check if the file was modified after the package was built. + let modified_date = chrono::DateTime::::from(modified_date); + let is_stale = timestamp.map(|t| t < modified_date).unwrap_or(true); + if is_stale { + tracing::debug!( + "package is stale, the file '{}' has been modified", + source_file_path.display() + ); + return Ok(CachedBuildStatus::Stale(cached_build)); + } + } + Err(err) => { + // File was deleted or is no longer accessible. tracing::debug!( - "package is stale, the file {} is newer than the package in cache", - designated_file.display() + "package is stale, requested metadata for '{}' failed with: {}", + source_file_path.display(), + err ); return Ok(CachedBuildStatus::Stale(cached_build)); } - } - GlobModificationTime::NoMatches => { + }; + } + + // Check if any new files match the globs that weren't recorded at cache time. + // This detects file additions. + let glob_set = GlobSet::create(source_info.input_globs.iter().map(String::as_str)); + let matching_files = glob_set + .collect_matching(source_dir) + .map_err(SourceBuildCacheStatusError::GlobSet) + .map_err(CommandDispatcherError::Failed)?; + + for matching_file in matching_files { + let path = matching_file.into_path(); + let relative_path = path + .strip_prefix(source_dir) + .ok() + .map(|p| p.to_path_buf()) + .unwrap_or_else(|| path.clone()); + + if !source_info.input_files.contains(&relative_path) { + tracing::debug!( + "package is stale, a new matching file at '{}' has been detected", + path.display() + ); return Ok(CachedBuildStatus::Stale(cached_build)); } } + Ok(CachedBuildStatus::UpToDate(cached_build)) } } @@ -431,6 +457,9 @@ pub enum SourceBuildCacheStatusError { #[diagnostic(transparent)] Discovery(pixi_build_discovery::DiscoveryError), + #[error(transparent)] + GlobSet(#[from] pixi_glob::GlobSetError), + #[error("a cycle was detected in the build/host dependencies of the package")] Cycle, } diff --git a/crates/pixi_command_dispatcher/src/source_checkout/mod.rs b/crates/pixi_command_dispatcher/src/source_checkout/mod.rs index eb1b566188..8c144d28c4 100644 --- a/crates/pixi_command_dispatcher/src/source_checkout/mod.rs +++ b/crates/pixi_command_dispatcher/src/source_checkout/mod.rs @@ -1,29 +1,27 @@ +use crate::command_dispatcher::url::UrlError; use miette::Diagnostic; use pixi_git::GitError; +use pixi_path::{AbsPathBuf, NormalizeError}; use pixi_record::PinnedSourceSpec; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use thiserror::Error; -use crate::command_dispatcher::url::UrlError; - /// Location of the source code for a package. This will be used as the input /// for the build process. Archives are unpacked, git clones are checked out, /// etc. #[derive(Debug, Clone, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)] pub struct SourceCheckout { /// The path to where the source is located locally on disk. - pub path: PathBuf, + pub path: AbsPathBuf, /// The exact source specification pub pinned: PinnedSourceSpec, } impl SourceCheckout { - pub fn new(path: impl AsRef, pinned: PinnedSourceSpec) -> Self { - Self { - path: path.as_ref().to_owned(), - pinned, - } + /// Returns true if the contents of the source checkout are immutable. + pub fn is_immutable(&self) -> bool { + self.pinned.is_immutable() } } @@ -40,6 +38,12 @@ pub enum SourceCheckoutError { #[error("the manifest path {0} should have a parent directory")] ParentDir(PathBuf), + + #[error("the subdirectory {0} does not exist in the source checkout")] + SubdirDoesNotExist(PathBuf), + + #[error("the subdirectory {0} refers to a file in the source checkout")] + SubdirIsAFile(PathBuf), } #[derive(Debug, Error)] @@ -50,3 +54,11 @@ pub enum InvalidPathError { #[error("could not determine the current home directory while resolving: {0}")] CouldNotDetermineHomeDirectory(PathBuf), } + +impl From for InvalidPathError { + fn from(value: NormalizeError) -> Self { + match value { + NormalizeError::EscapesRoot(path) => InvalidPathError::RelativePathEscapesRoot(path), + } + } +} diff --git a/crates/pixi_command_dispatcher/src/source_metadata/mod.rs b/crates/pixi_command_dispatcher/src/source_metadata/mod.rs index 797f66f61a..1cb3924587 100644 --- a/crates/pixi_command_dispatcher/src/source_metadata/mod.rs +++ b/crates/pixi_command_dispatcher/src/source_metadata/mod.rs @@ -10,11 +10,9 @@ use futures::TryStreamExt; use itertools::{Either, Itertools}; use miette::Diagnostic; use pixi_build_types::procedures::conda_outputs::CondaOutput; -use pixi_record::VariantValue; -use pixi_record::{InputHash, PixiRecord, SourceRecord}; +use pixi_record::{PixiRecord, SourceRecord}; use pixi_spec::{BinarySpec, PixiSpec, SourceAnchor, SourceSpec, SpecConversionError}; use pixi_spec_containers::DependencyMap; -use rand::random; use rattler_conda_types::{ ChannelConfig, InvalidPackageNameError, MatchSpec, PackageName, PackageRecord, package::RunExportsJson, @@ -23,15 +21,16 @@ use rattler_repodata_gateway::{RunExportExtractorError, RunExportsReporter}; use thiserror::Error; use tracing::instrument; +use crate::cache::build_backend_metadata::CachedCondaMetadataId; +use crate::cache::source_metadata::CachedSourceMetadataId; use crate::{ BuildBackendMetadataError, BuildBackendMetadataSpec, BuildEnvironment, CommandDispatcher, CommandDispatcherError, CommandDispatcherErrorResultExt, PixiEnvironmentSpec, SolvePixiEnvironmentError, - build::{Dependencies, DependenciesError, PixiRunExports, SourceCodeLocation, conversion}, + build::{Dependencies, DependenciesError, PixiRunExports, SourceCodeLocation}, cache::{ - build_backend_metadata::MetadataKind, common::MetadataCache, - source_metadata::{self, CachedSourceMetadata, Metadata, SourceMetadataKey}, + source_metadata::{self, CachedSourceMetadata, SourceMetadataCacheShard}, }, executor::ExecutorFutures, }; @@ -51,13 +50,6 @@ pub struct SourceMetadata { /// Manifest and optional build source location for this metadata. pub source: SourceCodeLocation, - /// The cache entry that contains the metadata acquired from the build - /// backend. - /// - /// As long as the cache entry is not dropped, the metadata cannot be - /// accessed by another process. - pub cache_entry: source_metadata::CacheEntry, - /// The metadata that was acquired from the build backend. pub cached_metadata: CachedSourceMetadata, } @@ -86,7 +78,7 @@ impl SourceMetadataSpec { let build_backend_metadata = build_backend_metadata?; - tracing::info!( + tracing::trace!( "Retrieving source metadata for package {}", self.package.as_source() ); @@ -96,111 +88,80 @@ impl SourceMetadataSpec { // Get the skip_cache flag from the build backend metadata let skip_cache = build_backend_metadata.skip_cache; - let (metadata, mut cache_entry) = command_dispatcher + let cache_read_result = command_dispatcher .source_metadata_cache() - .entry(&cache_key) + .read(&cache_key) .await .map_err(SourceMetadataError::Cache) .map_err(CommandDispatcherError::Failed)?; + let (cached_metadata, cache_version) = match cache_read_result { + Some((metadata, version)) => (Some(metadata), version), + // Start at cache version 0 if no cache exists + None => (None, 0), + }; + if !skip_cache { - if let Some(cached_metadata) = Self::verify_cache_freshness( - &build_backend_metadata.metadata.input_hash, - metadata, - &self.backend_metadata.variant_configuration, - ) - .await? + if let Some(cached_metadata) = + Self::verify_cache_freshness(cached_metadata, build_backend_metadata.metadata.id) + .await? { - tracing::debug!( - "Using cached source metadata for package {}", - self.package.as_source() - ); + tracing::debug!("Using cached source metadata for package",); return Ok(SourceMetadata { source: build_backend_metadata.source.clone(), cached_metadata, - cache_entry, }); } } - match &build_backend_metadata.metadata.metadata { - MetadataKind::GetMetadata { packages } => { - let source_location = build_backend_metadata.source.clone(); - // Convert the metadata to source records. - let records = conversion::package_metadata_to_source_records( - source_location.manifest_source(), - source_location.build_source(), - packages, - &self.package, - &build_backend_metadata.metadata.input_hash, - ); - - let cached_source_metadata = CachedSourceMetadata { - id: random(), - input_hash: build_backend_metadata.metadata.input_hash.clone(), - build_variants: self.backend_metadata.variant_configuration.clone(), - metadata: Metadata { - records: records.clone(), - }, - }; - - // Store the metadata in the cache for later retrieval - cache_entry - .write(cached_source_metadata.clone()) - .await - .map_err(SourceMetadataError::Cache) - .map_err(CommandDispatcherError::Failed)?; - - Ok(SourceMetadata { - cache_entry, - cached_metadata: cached_source_metadata, - source: source_location, - }) + let mut futures = ExecutorFutures::new(command_dispatcher.executor()); + let source_location = build_backend_metadata.source.clone(); + for output in &build_backend_metadata.metadata.outputs { + if output.metadata.name != self.package { + continue; } - MetadataKind::Outputs { outputs } => { - let mut futures = ExecutorFutures::new(command_dispatcher.executor()); - let source_location = build_backend_metadata.source.clone(); - for output in outputs { - if output.metadata.name != self.package { - continue; - } - futures.push(self.resolve_output( - &command_dispatcher, - output, - build_backend_metadata.metadata.input_hash.clone(), - source_location.clone(), - reporter.clone(), - )); - } + futures.push(self.resolve_output( + &command_dispatcher, + output, + source_location.clone(), + reporter.clone(), + )); + } - let cached_source_metadata = CachedSourceMetadata { - id: random(), - input_hash: build_backend_metadata.metadata.input_hash.clone(), - build_variants: self.backend_metadata.variant_configuration.clone(), - metadata: Metadata { - records: futures.try_collect().await?, - }, - }; - - // Store the metadata in the cache for later retrieval - cache_entry - .write(cached_source_metadata.clone()) - .await - .map_err(SourceMetadataError::Cache) - .map_err(CommandDispatcherError::Failed)?; - - Ok(SourceMetadata { - cache_entry, - cached_metadata: cached_source_metadata, - source: source_location, - }) + let cached_source_metadata = CachedSourceMetadata { + id: CachedSourceMetadataId::random(), + cache_version, + records: futures.try_collect().await?, + cached_conda_metadata_id: build_backend_metadata.metadata.id, + }; + + // Try to store the metadata in the cache with version checking + match command_dispatcher + .source_metadata_cache() + .try_write(&cache_key, cached_source_metadata.clone(), cache_version) + .await + .map_err(SourceMetadataError::Cache) + .map_err(CommandDispatcherError::Failed)? + { + source_metadata::WriteResult::Written => { + tracing::trace!("Cache updated successfully"); + } + source_metadata::WriteResult::Conflict(_) => { + tracing::warn!( + "Cache was updated by another process during computation (version conflict), using our computed result" + ); } } + + Ok(SourceMetadata { + cached_metadata: cached_source_metadata, + source: source_location, + }) } /// Computes the cache key for this instance - pub(crate) fn cache_key(&self) -> SourceMetadataKey { - SourceMetadataKey { + pub(crate) fn cache_key(&self) -> SourceMetadataCacheShard { + SourceMetadataCacheShard { package: self.package.clone(), channel_urls: self.backend_metadata.channels.clone(), build_environment: self.backend_metadata.build_environment.clone(), @@ -210,44 +171,27 @@ impl SourceMetadataSpec { } async fn verify_cache_freshness( - current_input_hash: &Option, cached_metadata: Option, - requested_variants: &Option>>, + current_conda_metadata_id: CachedCondaMetadataId, ) -> Result, CommandDispatcherError> { let Some(cached_metadata) = cached_metadata else { tracing::debug!("no cached metadata passed."); return Ok(None); }; - // Check if the build variants match - if cached_metadata.build_variants != *requested_variants { - tracing::trace!("found cached response with different variants, invalidating cache."); + if cached_metadata.cached_conda_metadata_id != current_conda_metadata_id { + // Not adding tracing here because the backend metadata would already have done that. + tracing::info!("Cached metadata is stale, skipping cache"); return Ok(None); } - // If neither has an input hash, consider it fresh - let (Some(current_hash), Some(cached_hash)) = - (current_input_hash, &cached_metadata.input_hash) - else { - tracing::trace!("no input hash to compare, assuming cache is fresh"); - return Ok(Some(cached_metadata)); - }; - - // Compare the hashes directly - if current_hash.hash == cached_hash.hash { - tracing::trace!("found up-to-date cached response"); - Ok(Some(cached_metadata)) - } else { - tracing::trace!("found stale cached response"); - Ok(None) - } + Ok(Some(cached_metadata)) } async fn resolve_output( &self, command_dispatcher: &CommandDispatcher, output: &CondaOutput, - input_hash: Option, source: SourceCodeLocation, reporter: Option>, ) -> Result> { @@ -286,7 +230,7 @@ impl SourceMetadataSpec { reporter.clone(), ) .await - .map_err(SourceMetadataError::from) + .map_err(|err| SourceMetadataError::RunExportsExtraction(String::from("build"), err)) .map_err(CommandDispatcherError::Failed)?; // Solve the host environment for the output. @@ -317,7 +261,7 @@ impl SourceMetadataSpec { reporter, ) .await - .map_err(SourceMetadataError::from) + .map_err(|err| SourceMetadataError::RunExportsExtraction(String::from("host"), err)) .map_err(CommandDispatcherError::Failed)?; // Gather the dependencies for the output. @@ -469,7 +413,6 @@ impl SourceMetadataSpec { experimental_extra_depends: Default::default(), }, manifest_source, - input_hash, build_source, sources: sources .into_iter() @@ -613,8 +556,8 @@ pub enum SourceMetadataError { #[diagnostic(transparent)] BuildBackendMetadata(#[from] BuildBackendMetadataError), - #[error("failed to amend run exports: {0}")] - RunExportsExtraction(#[from] RunExportExtractorError), + #[error("failed to amend run exports for {0} environment")] + RunExportsExtraction(String, #[source] RunExportExtractorError), #[error("while trying to solve the build environment for the package")] SolveBuildEnvironment( diff --git a/crates/pixi_command_dispatcher/tests/integration/main.rs b/crates/pixi_command_dispatcher/tests/integration/main.rs index d69c34a2d9..e85fee7d75 100644 --- a/crates/pixi_command_dispatcher/tests/integration/main.rs +++ b/crates/pixi_command_dispatcher/tests/integration/main.rs @@ -8,6 +8,8 @@ use std::{ str::FromStr, }; +use pixi_path::AbsPathBuf; + use event_reporter::EventReporter; use fs_err as fs; use itertools::Itertools; @@ -35,9 +37,17 @@ use url::Url; use crate::{event_reporter::Event, event_tree::EventTree}; +/// Converts a PathBuf to AbsPresumedDirPathBuf for tests. +fn to_abs_dir(path: impl Into) -> pixi_path::AbsPresumedDirPathBuf { + AbsPathBuf::new(path) + .expect("path is not absolute") + .into_assume_dir() +} + /// Returns a default set of cache directories for the test. fn default_cache_dirs() -> CacheDirs { - CacheDirs::new(pixi_config::get_cache_dir().unwrap()) + let cache_dir = pixi_config::get_cache_dir().unwrap(); + CacheDirs::new(to_abs_dir(cache_dir)) } /// Returns the tool platform that is appropriate for the current platform. @@ -112,7 +122,7 @@ pub async fn simple_test() { let tempdir = tempfile::tempdir().unwrap(); let prefix_dir = tempdir.path().join("prefix"); let dispatcher = CommandDispatcher::builder() - .with_cache_dirs(default_cache_dirs().with_workspace(tempdir.path().to_path_buf())) + .with_cache_dirs(default_cache_dirs().with_workspace(to_abs_dir(tempdir.path()))) .with_reporter(reporter) .with_executor(Executor::Serial) .with_tool_platform(tool_platform, tool_virtual_packages.clone()) @@ -310,7 +320,7 @@ pub async fn dropping_future_cancels_background_task() { .cache_dirs() .build_backends() .join(spec.cache_key()); - let mut write_guard = pixi_utils::AsyncPrefixGuard::new(&prefix_dir) + let mut write_guard = pixi_utils::AsyncPrefixGuard::new(prefix_dir.as_std_path()) .await .unwrap() .write() @@ -379,8 +389,8 @@ pub async fn test_cycle() { let root_dir = workspaces_dir().join("cycle"); let tempdir = tempfile::tempdir().unwrap(); let dispatcher = CommandDispatcher::builder() - .with_root_dir(root_dir.clone()) - .with_cache_dirs(default_cache_dirs().with_workspace(tempdir.path().to_path_buf())) + .with_root_dir(to_abs_dir(root_dir.clone())) + .with_cache_dirs(default_cache_dirs().with_workspace(to_abs_dir(tempdir.path()))) .with_reporter(reporter) .with_executor(Executor::Serial) .with_tool_platform(tool_platform, tool_virtual_packages.clone()) @@ -432,8 +442,8 @@ pub async fn test_stale_host_dependency_triggers_rebuild() { let build_env = BuildEnvironment::simple(tool_platform, tool_virtual_packages.clone()); let build_command_dispatcher = || { CommandDispatcher::builder() - .with_root_dir(root_dir.clone()) - .with_cache_dirs(default_cache_dirs().with_workspace(tempdir.path().to_path_buf())) + .with_root_dir(to_abs_dir(root_dir.clone())) + .with_cache_dirs(default_cache_dirs().with_workspace(to_abs_dir(tempdir.path()))) .with_executor(Executor::Serial) .with_tool_platform(tool_platform, tool_virtual_packages.clone()) .with_backend_overrides(BackendOverride::from_memory( @@ -574,8 +584,8 @@ pub async fn instantiate_backend_with_from_source() { fs_err::write(&workspace_toml, content).unwrap(); let dispatcher = CommandDispatcher::builder() - .with_root_dir(root_dir.clone()) - .with_cache_dirs(CacheDirs::new(root_dir.join(".pixi"))) + .with_root_dir(to_abs_dir(root_dir.clone())) + .with_cache_dirs(CacheDirs::new(to_abs_dir(root_dir.join(".pixi")))) .with_executor(Executor::Serial) .with_backend_overrides(BackendOverride::InMemory( InMemoryOverriddenBackends::Specified(HashMap::from_iter([( @@ -604,7 +614,7 @@ async fn source_build_cache_status_clear_works() { let tmp_dir = tempfile::tempdir().unwrap(); let dispatcher = CommandDispatcher::builder() - .with_cache_dirs(CacheDirs::new(tmp_dir.path().to_path_buf())) + .with_cache_dirs(CacheDirs::new(to_abs_dir(tmp_dir.path()))) .finish(); let host = Platform::current(); @@ -688,8 +698,8 @@ pub async fn test_dev_source_metadata() { let (tool_platform, tool_virtual_packages) = tool_platform(); let dispatcher = CommandDispatcher::builder() - .with_root_dir(root_dir.clone()) - .with_cache_dirs(default_cache_dirs().with_workspace(tempdir.path().to_path_buf())) + .with_root_dir(to_abs_dir(root_dir.clone())) + .with_cache_dirs(default_cache_dirs().with_workspace(to_abs_dir(tempdir.path()))) .with_executor(Executor::Serial) .with_tool_platform(tool_platform, tool_virtual_packages.clone()) .with_backend_overrides(BackendOverride::from_memory( @@ -777,8 +787,8 @@ pub async fn test_dev_source_metadata_with_variants() { let (tool_platform, tool_virtual_packages) = tool_platform(); let dispatcher = CommandDispatcher::builder() - .with_root_dir(root_dir.clone()) - .with_cache_dirs(default_cache_dirs().with_workspace(tempdir.path().to_path_buf())) + .with_root_dir(to_abs_dir(root_dir.clone())) + .with_cache_dirs(default_cache_dirs().with_workspace(to_abs_dir(tempdir.path()))) .with_executor(Executor::Serial) .with_tool_platform(tool_platform, tool_virtual_packages.clone()) .with_backend_overrides(BackendOverride::from_memory( @@ -910,8 +920,8 @@ pub async fn test_force_rebuild() { let build_env = BuildEnvironment::simple(tool_platform, tool_virtual_packages.clone()); let build_command_dispatcher = || { CommandDispatcher::builder() - .with_root_dir(root_dir.clone()) - .with_cache_dirs(default_cache_dirs().with_workspace(tempdir.path().to_path_buf())) + .with_root_dir(to_abs_dir(root_dir.clone())) + .with_cache_dirs(default_cache_dirs().with_workspace(to_abs_dir(tempdir.path()))) .with_executor(Executor::Serial) .with_tool_platform(tool_platform, tool_virtual_packages.clone()) .with_backend_overrides(BackendOverride::from_memory( @@ -1057,11 +1067,11 @@ pub async fn test_force_rebuild() { #[tokio::test] pub async fn pin_and_checkout_url_reuses_cached_checkout() { let tempdir = tempfile::tempdir().unwrap(); - let cache_dirs = CacheDirs::new(tempdir.path().join("pixi-cache")); + let cache_dirs = CacheDirs::new(to_abs_dir(tempdir.path().join("pixi-cache"))); let url_cache_root = cache_dirs.url(); let sha = dummy_sha(); - let checkout_dir = prepare_cached_checkout(&url_cache_root, sha); + let checkout_dir = prepare_cached_checkout(url_cache_root.as_std_path(), sha); let dispatcher = CommandDispatcher::builder() .with_cache_dirs(cache_dirs) @@ -1080,7 +1090,7 @@ pub async fn pin_and_checkout_url_reuses_cached_checkout() { .await .expect("url checkout should succeed"); - assert_eq!(checkout.path, checkout_dir); + assert_eq!(checkout.path.as_std_path(), checkout_dir); match checkout.pinned { PinnedSourceSpec::Url(pinned) => { assert_eq!(pinned.url, spec.url); @@ -1093,7 +1103,7 @@ pub async fn pin_and_checkout_url_reuses_cached_checkout() { #[tokio::test] pub async fn pin_and_checkout_url_reports_sha_mismatch_from_concurrent_request() { let tempdir = tempfile::tempdir().unwrap(); - let cache_dirs = CacheDirs::new(tempdir.path().join("pixi-cache")); + let cache_dirs = CacheDirs::new(to_abs_dir(tempdir.path().join("pixi-cache"))); let archive = tempfile::tempdir().unwrap(); let url = file_url_for_test(&archive, "archive.zip"); @@ -1130,7 +1140,7 @@ pub async fn pin_and_checkout_url_reports_sha_mismatch_from_concurrent_request() #[tokio::test] pub async fn pin_and_checkout_url_validates_cached_results() { let tempdir = tempfile::tempdir().unwrap(); - let cache_dirs = CacheDirs::new(tempdir.path().join("pixi-cache")); + let cache_dirs = CacheDirs::new(to_abs_dir(tempdir.path().join("pixi-cache"))); let archive = tempfile::tempdir().unwrap(); let url = file_url_for_test(&archive, "archive.zip"); @@ -1162,3 +1172,550 @@ pub async fn pin_and_checkout_url_validates_cached_results() { CommandDispatcherError::Failed(UrlError::Sha256Mismatch { .. }) )); } + +/// Tests that a package is NOT rebuilt across sessions when no source files have changed. +/// +/// This test simulates a program restart by dropping and recreating the dispatcher, +/// and verifies that the cache is properly reused (CacheStatus::UpToDate). +#[tokio::test] +pub async fn test_package_not_rebuilt_across_sessions_when_no_files_changed() { + let root_dir = workspaces_dir().join("host-dependency"); + let tempdir = tempfile::tempdir().unwrap(); + let (tool_platform, tool_virtual_packages) = tool_platform(); + let build_env = BuildEnvironment::simple(tool_platform, tool_virtual_packages.clone()); + + let build_command_dispatcher = || { + CommandDispatcher::builder() + .with_root_dir(to_abs_dir(root_dir.clone())) + .with_cache_dirs(default_cache_dirs().with_workspace(to_abs_dir(tempdir.path()))) + .with_executor(Executor::Serial) + .with_tool_platform(tool_platform, tool_virtual_packages.clone()) + .with_backend_overrides(BackendOverride::from_memory( + PassthroughBackend::instantiator(), + )) + }; + + // First session: solve and install + let dispatcher = build_command_dispatcher().finish(); + + let records = dispatcher + .solve_pixi_environment(PixiEnvironmentSpec { + dependencies: DependencyMap::from_iter([ + ( + "package-a".parse().unwrap(), + PathSpec::new("package-a").into(), + ), + ( + "package-c".parse().unwrap(), + PathSpec::new("package-c").into(), + ), + ]), + build_environment: build_env.clone(), + ..PixiEnvironmentSpec::default() + }) + .await + .map_err(|e| format_diagnostic(&e)) + .expect("solve should succeed"); + + let prefix = Prefix::create(tempdir.path().join("prefix")).unwrap(); + dispatcher + .install_pixi_environment(InstallPixiEnvironmentSpec { + build_environment: build_env.clone(), + ..InstallPixiEnvironmentSpec::new(records.clone(), prefix.clone()) + }) + .await + .map_err(|e| format_diagnostic(&e)) + .expect("install should succeed"); + + // Drop dispatcher to simulate program restart + drop(dispatcher); + + // Second session: reinstall WITHOUT modifying any files + let (reporter, events) = EventReporter::new(); + let dispatcher = build_command_dispatcher().with_reporter(reporter).finish(); + + dispatcher + .install_pixi_environment(InstallPixiEnvironmentSpec { + build_environment: build_env.clone(), + ..InstallPixiEnvironmentSpec::new(records, prefix) + }) + .await + .map_err(|e| format_diagnostic(&e)) + .expect("reinstall should succeed"); + + let rebuild_packages: Vec<_> = events + .take() + .iter() + .filter_map(|event| match event { + event_reporter::Event::BackendSourceBuildQueued { package, .. } => { + Some(package.name.as_normalized().to_string()) + } + _ => None, + }) + .collect(); + + assert!( + rebuild_packages.is_empty(), + "No packages should be rebuilt across sessions when no files changed, but got: {rebuild_packages:?}" + ); +} + +/// Tests that a package IS rebuilt across sessions when a source file is modified. +/// +/// This test simulates a program restart by dropping and recreating the dispatcher, +/// and verifies that file changes are detected and trigger a rebuild. +#[tokio::test] +pub async fn test_package_rebuilt_across_sessions_when_source_file_modified() { + let root_dir = workspaces_dir().join("host-dependency"); + let tempdir = tempfile::tempdir().unwrap(); + let (tool_platform, tool_virtual_packages) = tool_platform(); + let build_env = BuildEnvironment::simple(tool_platform, tool_virtual_packages.clone()); + + let build_command_dispatcher = || { + CommandDispatcher::builder() + .with_root_dir(to_abs_dir(root_dir.clone())) + .with_cache_dirs(default_cache_dirs().with_workspace(to_abs_dir(tempdir.path()))) + .with_executor(Executor::Serial) + .with_tool_platform(tool_platform, tool_virtual_packages.clone()) + .with_backend_overrides(BackendOverride::from_memory( + PassthroughBackend::instantiator(), + )) + }; + + // First session: solve and install + let dispatcher = build_command_dispatcher().finish(); + + let records = dispatcher + .solve_pixi_environment(PixiEnvironmentSpec { + dependencies: DependencyMap::from_iter([ + ( + "package-a".parse().unwrap(), + PathSpec::new("package-a").into(), + ), + ( + "package-c".parse().unwrap(), + PathSpec::new("package-c").into(), + ), + ]), + build_environment: build_env.clone(), + ..PixiEnvironmentSpec::default() + }) + .await + .map_err(|e| format_diagnostic(&e)) + .expect("solve should succeed"); + + let prefix = Prefix::create(tempdir.path().join("prefix")).unwrap(); + dispatcher + .install_pixi_environment(InstallPixiEnvironmentSpec { + build_environment: build_env.clone(), + ..InstallPixiEnvironmentSpec::new(records.clone(), prefix.clone()) + }) + .await + .map_err(|e| format_diagnostic(&e)) + .expect("install should succeed"); + + // Drop dispatcher to simulate program restart + drop(dispatcher); + + // Create a file that matches package-b's build glob pattern ("TOUCH*") + let _touch_file = tempfile::Builder::new() + .prefix("TOUCH") + .tempfile_in(root_dir.join("package-b")) + .unwrap(); + + // Second session: reinstall after file modification + let (reporter, events) = EventReporter::new(); + let dispatcher = build_command_dispatcher().with_reporter(reporter).finish(); + + dispatcher + .install_pixi_environment(InstallPixiEnvironmentSpec { + build_environment: build_env.clone(), + ..InstallPixiEnvironmentSpec::new(records, prefix) + }) + .await + .map_err(|e| format_diagnostic(&e)) + .expect("reinstall should succeed"); + + let rebuild_packages: Vec<_> = events + .take() + .iter() + .filter_map(|event| match event { + event_reporter::Event::BackendSourceBuildQueued { package, .. } => { + Some(package.name.as_normalized().to_string()) + } + _ => None, + }) + .collect(); + + assert_eq!( + rebuild_packages, + vec!["package-b"], + "Only package-b should be rebuilt after source file modification" + ); +} + +/// Tests that modifying a source file triggers a rebuild of the package. +/// +/// This is a focused test that verifies only the file-change detection behavior, +/// without testing dependency chains or force rebuild flags. +#[tokio::test] +pub async fn test_package_rebuilt_when_source_file_modified() { + let root_dir = workspaces_dir().join("host-dependency"); + let tempdir = tempfile::tempdir().unwrap(); + let (tool_platform, tool_virtual_packages) = tool_platform(); + let build_env = BuildEnvironment::simple(tool_platform, tool_virtual_packages.clone()); + + let build_command_dispatcher = || { + CommandDispatcher::builder() + .with_root_dir(to_abs_dir(root_dir.clone())) + .with_cache_dirs(default_cache_dirs().with_workspace(to_abs_dir(tempdir.path()))) + .with_executor(Executor::Serial) + .with_tool_platform(tool_platform, tool_virtual_packages.clone()) + .with_backend_overrides(BackendOverride::from_memory( + PassthroughBackend::instantiator(), + )) + }; + + // First pass: build and install package-b + let dispatcher = build_command_dispatcher().finish(); + + let records = dispatcher + .solve_pixi_environment(PixiEnvironmentSpec { + dependencies: DependencyMap::from_iter([( + "package-b".parse().unwrap(), + PathSpec::new("package-b").into(), + )]), + build_environment: build_env.clone(), + ..PixiEnvironmentSpec::default() + }) + .await + .map_err(|e| format_diagnostic(&e)) + .expect("solve should succeed"); + + let prefix = Prefix::create(tempdir.path().join("prefix")).unwrap(); + dispatcher + .install_pixi_environment(InstallPixiEnvironmentSpec { + build_environment: build_env.clone(), + ..InstallPixiEnvironmentSpec::new(records.clone(), prefix.clone()) + }) + .await + .map_err(|e| format_diagnostic(&e)) + .expect("install should succeed"); + + // Drop dispatcher to flush caches (simulating program restart) + drop(dispatcher); + + // Create a file that matches package-b's build glob pattern ("TOUCH*") + let _touch_file = tempfile::Builder::new() + .prefix("TOUCH") + .tempfile_in(root_dir.join("package-b")) + .unwrap(); + + // Second pass: reinstall with new dispatcher, expect rebuild + let (reporter, events) = EventReporter::new(); + let dispatcher = build_command_dispatcher().with_reporter(reporter).finish(); + + dispatcher + .install_pixi_environment(InstallPixiEnvironmentSpec { + build_environment: build_env.clone(), + ..InstallPixiEnvironmentSpec::new(records, prefix) + }) + .await + .map_err(|e| format_diagnostic(&e)) + .expect("reinstall should succeed"); + + let rebuild_packages: Vec<_> = events + .take() + .iter() + .filter_map(|event| match event { + event_reporter::Event::BackendSourceBuildQueued { package, .. } => { + Some(package.name.as_normalized().to_string()) + } + _ => None, + }) + .collect(); + + assert_eq!( + rebuild_packages, + vec!["package-b"], + "Package should be rebuilt when source file is modified" + ); +} + +/// Tests that a package is NOT rebuilt when no source files have changed. +/// +/// This is a focused test that verifies cache reuse behavior when files are unchanged +/// within the same dispatcher session (CacheStatus::New is reused). +#[tokio::test] +pub async fn test_package_not_rebuilt_when_no_files_changed() { + let root_dir = workspaces_dir().join("host-dependency"); + let tempdir = tempfile::tempdir().unwrap(); + let (tool_platform, tool_virtual_packages) = tool_platform(); + let build_env = BuildEnvironment::simple(tool_platform, tool_virtual_packages.clone()); + + let (reporter, events) = EventReporter::new(); + let dispatcher = CommandDispatcher::builder() + .with_root_dir(to_abs_dir(root_dir.clone())) + .with_cache_dirs(default_cache_dirs().with_workspace(to_abs_dir(tempdir.path()))) + .with_executor(Executor::Serial) + .with_tool_platform(tool_platform, tool_virtual_packages.clone()) + .with_backend_overrides(BackendOverride::from_memory( + PassthroughBackend::instantiator(), + )) + .with_reporter(reporter) + .finish(); + + // First pass: build and install package-b + let records = dispatcher + .solve_pixi_environment(PixiEnvironmentSpec { + dependencies: DependencyMap::from_iter([( + "package-b".parse().unwrap(), + PathSpec::new("package-b").into(), + )]), + build_environment: build_env.clone(), + ..PixiEnvironmentSpec::default() + }) + .await + .map_err(|e| format_diagnostic(&e)) + .expect("solve should succeed"); + + let prefix = Prefix::create(tempdir.path().join("prefix")).unwrap(); + dispatcher + .install_pixi_environment(InstallPixiEnvironmentSpec { + build_environment: build_env.clone(), + ..InstallPixiEnvironmentSpec::new(records.clone(), prefix.clone()) + }) + .await + .map_err(|e| format_diagnostic(&e)) + .expect("install should succeed"); + + // Count first build events + let first_build_count: usize = events + .take() + .iter() + .filter(|event| { + matches!( + event, + event_reporter::Event::BackendSourceBuildQueued { .. } + ) + }) + .count(); + + assert_eq!( + first_build_count, 1, + "First install should build package-b once" + ); + + // Second pass: reinstall WITHOUT modifying any files (same dispatcher session) + dispatcher + .install_pixi_environment(InstallPixiEnvironmentSpec { + build_environment: build_env.clone(), + ..InstallPixiEnvironmentSpec::new(records, prefix) + }) + .await + .map_err(|e| format_diagnostic(&e)) + .expect("reinstall should succeed"); + + let rebuild_packages: Vec<_> = events + .take() + .iter() + .filter_map(|event| match event { + event_reporter::Event::BackendSourceBuildQueued { package, .. } => { + Some(package.name.as_normalized().to_string()) + } + _ => None, + }) + .collect(); + + assert!( + rebuild_packages.is_empty(), + "No packages should be rebuilt when no files changed, but got: {rebuild_packages:?}" + ); +} + +/// Tests that metadata is NOT re-fetched when no source files have changed. +/// +/// This is a focused test that verifies metadata cache reuse behavior. +#[tokio::test] +pub async fn test_metadata_not_refetched_when_no_files_changed() { + use pixi_command_dispatcher::{BuildBackendMetadataSpec, DevSourceMetadataSpec}; + use pixi_record::PinnedPathSpec; + + let root_dir = workspaces_dir().join("dev-sources"); + let tempdir = tempfile::tempdir().unwrap(); + let (tool_platform, tool_virtual_packages) = tool_platform(); + + let build_command_dispatcher = || { + CommandDispatcher::builder() + .with_root_dir(to_abs_dir(root_dir.clone())) + .with_cache_dirs(default_cache_dirs().with_workspace(to_abs_dir(tempdir.path()))) + .with_executor(Executor::Serial) + .with_tool_platform(tool_platform, tool_virtual_packages.clone()) + .with_backend_overrides(BackendOverride::from_memory( + PassthroughBackend::instantiator(), + )) + }; + + let pinned_source: PinnedSourceSpec = PinnedPathSpec { + path: "test-package".into(), + } + .into(); + + let spec = DevSourceMetadataSpec { + package_name: PackageName::new_unchecked("test-package"), + backend_metadata: BuildBackendMetadataSpec { + manifest_source: pinned_source, + channel_config: default_channel_config(), + channels: vec![], + build_environment: BuildEnvironment::simple( + tool_platform, + tool_virtual_packages.clone(), + ), + variant_configuration: None, + variant_files: None, + enabled_protocols: Default::default(), + preferred_build_source: None, + }, + }; + + // First metadata request + let (reporter, events) = EventReporter::new(); + let dispatcher = build_command_dispatcher().with_reporter(reporter).finish(); + + dispatcher + .dev_source_metadata(spec.clone()) + .await + .map_err(|e| format_diagnostic(&e)) + .expect("first metadata request should succeed"); + + let first_metadata_requests: usize = events + .take() + .iter() + .filter(|event| { + matches!( + event, + event_reporter::Event::BuildBackendMetadataQueued { .. } + ) + }) + .count(); + + assert_eq!( + first_metadata_requests, 1, + "First request should fetch metadata once" + ); + + // Second metadata request (same dispatcher, no file changes) + dispatcher.clear_reporter().await; + + dispatcher + .dev_source_metadata(spec) + .await + .map_err(|e| format_diagnostic(&e)) + .expect("second metadata request should succeed"); + + let second_metadata_requests: usize = events + .take() + .iter() + .filter(|event| { + matches!( + event, + event_reporter::Event::BuildBackendMetadataQueued { .. } + ) + }) + .count(); + + assert_eq!( + second_metadata_requests, 0, + "Second request should use cached metadata, no backend call expected" + ); +} + +/// Tests that metadata IS re-fetched when a source file is modified. +/// +/// This is a focused test that verifies metadata cache invalidation on file changes. +#[tokio::test] +pub async fn test_metadata_refetched_when_source_file_modified() { + use pixi_command_dispatcher::{BuildBackendMetadataSpec, DevSourceMetadataSpec}; + use pixi_record::PinnedPathSpec; + + let root_dir = workspaces_dir().join("host-dependency"); + let tempdir = tempfile::tempdir().unwrap(); + let (tool_platform, tool_virtual_packages) = tool_platform(); + + let build_command_dispatcher = || { + CommandDispatcher::builder() + .with_root_dir(to_abs_dir(root_dir.clone())) + .with_cache_dirs(default_cache_dirs().with_workspace(to_abs_dir(tempdir.path()))) + .with_executor(Executor::Serial) + .with_tool_platform(tool_platform, tool_virtual_packages.clone()) + .with_backend_overrides(BackendOverride::from_memory( + PassthroughBackend::instantiator(), + )) + }; + + let pinned_source: PinnedSourceSpec = PinnedPathSpec { + path: "package-b".into(), + } + .into(); + + let spec = DevSourceMetadataSpec { + package_name: PackageName::new_unchecked("package-b"), + backend_metadata: BuildBackendMetadataSpec { + manifest_source: pinned_source, + channel_config: default_channel_config(), + channels: vec![], + build_environment: BuildEnvironment::simple( + tool_platform, + tool_virtual_packages.clone(), + ), + variant_configuration: None, + variant_files: None, + enabled_protocols: Default::default(), + preferred_build_source: None, + }, + }; + + // First metadata request + let dispatcher = build_command_dispatcher().finish(); + + dispatcher + .dev_source_metadata(spec.clone()) + .await + .map_err(|e| format_diagnostic(&e)) + .expect("first metadata request should succeed"); + + // Drop dispatcher to flush caches (simulating program restart) + drop(dispatcher); + + // Create a file that matches package-b's build glob pattern ("TOUCH*") + let _touch_file = tempfile::Builder::new() + .prefix("TOUCH") + .tempfile_in(root_dir.join("package-b")) + .unwrap(); + + // Second metadata request after file modification + let (reporter, events) = EventReporter::new(); + let dispatcher = build_command_dispatcher().with_reporter(reporter).finish(); + + dispatcher + .dev_source_metadata(spec) + .await + .map_err(|e| format_diagnostic(&e)) + .expect("second metadata request should succeed"); + + let metadata_requests: usize = events + .take() + .iter() + .filter(|event| { + matches!( + event, + event_reporter::Event::BuildBackendMetadataQueued { .. } + ) + }) + .count(); + + assert_eq!( + metadata_requests, 1, + "Metadata should be re-fetched after source file modification" + ); +} diff --git a/crates/pixi_core/Cargo.toml b/crates/pixi_core/Cargo.toml index f77d6b7c25..924a12346f 100644 --- a/crates/pixi_core/Cargo.toml +++ b/crates/pixi_core/Cargo.toml @@ -45,6 +45,7 @@ pixi_git = { workspace = true } pixi_glob = { workspace = true } pixi_install_pypi = { workspace = true } pixi_manifest = { workspace = true, features = ["rattler_lock"] } +pixi_path = { workspace = true } pixi_progress = { workspace = true } pixi_pypi_spec = { workspace = true } pixi_python_status = { workspace = true } @@ -110,3 +111,4 @@ pixi_test_utils = { workspace = true } rstest = { workspace = true } serde_json = { workspace = true } tokio = { workspace = true, features = ["rt"] } +pixi_build_backend_passthrough = { workspace = true } diff --git a/crates/pixi_core/src/lock_file/outdated.rs b/crates/pixi_core/src/lock_file/outdated.rs index 89b1f64cc3..c119c15177 100644 --- a/crates/pixi_core/src/lock_file/outdated.rs +++ b/crates/pixi_core/src/lock_file/outdated.rs @@ -10,7 +10,6 @@ use fancy_display::FancyDisplay; use itertools::Itertools; use pixi_command_dispatcher::CommandDispatcher; use pixi_consts::consts; -use pixi_glob::GlobHashCache; use pixi_manifest::FeaturesExt; use rattler_conda_types::Platform; use rattler_lock::{LockFile, LockedPackageRef}; @@ -65,15 +64,13 @@ impl<'p> OutdatedEnvironments<'p> { workspace: &'p Workspace, command_dispatcher: CommandDispatcher, lock_file: &LockFile, - glob_hash_cache: GlobHashCache, ) -> Self { // Find all targets that are not satisfied by the lock-file let UnsatisfiableTargets { mut outdated_conda, mut outdated_pypi, disregard_locked_content, - } = find_unsatisfiable_targets(workspace, command_dispatcher, lock_file, glob_hash_cache) - .await; + } = find_unsatisfiable_targets(workspace, command_dispatcher, lock_file).await; // Extend the outdated targets to include the solve groups let (mut conda_solve_groups_out_of_date, mut pypi_solve_groups_out_of_date) = @@ -144,7 +141,6 @@ async fn find_unsatisfiable_targets<'p>( project: &'p Workspace, command_dispatcher: CommandDispatcher, lock_file: &LockFile, - glob_hash_cache: GlobHashCache, ) -> UnsatisfiableTargets<'p> { let mut verified_environments = HashMap::new(); let mut unsatisfiable_targets = UnsatisfiableTargets::default(); @@ -237,7 +233,6 @@ async fn find_unsatisfiable_targets<'p>( locked_environment, platform, project.root(), - glob_hash_cache.clone(), ) .await { diff --git a/crates/pixi_core/src/lock_file/satisfiability/mod.rs b/crates/pixi_core/src/lock_file/satisfiability/mod.rs index fdec3e7afc..0385be40dd 100644 --- a/crates/pixi_core/src/lock_file/satisfiability/mod.rs +++ b/crates/pixi_core/src/lock_file/satisfiability/mod.rs @@ -1,22 +1,21 @@ -use futures::stream::StreamExt; +use futures::stream::{FuturesUnordered, StreamExt}; use itertools::{Either, Itertools}; use miette::Diagnostic; use pep440_rs::VersionSpecifiers; -use pixi_build_discovery::{DiscoveredBackend, EnabledProtocols}; +use pixi_build_discovery::EnabledProtocols; use pixi_command_dispatcher::{ BuildBackendMetadataSpec, BuildEnvironment, CommandDispatcher, CommandDispatcherError, - DevSourceMetadataError, DevSourceMetadataSpec, SourceCheckoutError, - calculate_additional_glob_hash, + DevSourceMetadataError, DevSourceMetadataSpec, SourceCheckoutError, SourceMetadataError, + SourceMetadataSpec, }; use pixi_git::url::RepositoryUrl; -use pixi_glob::{GlobHashCache, GlobHashError, GlobHashKey}; use pixi_manifest::{ FeaturesExt, pypi::pypi_options::{NoBuild, PrereleaseMode}, }; use pixi_record::{ DevSourceRecord, LockedGitUrl, ParseLockFileError, PinnedSourceSpec, PixiRecord, - SourceMismatchError, VariantValue, + SourceMismatchError, SourceRecord, VariantValue, }; use pixi_spec::{PixiSpec, SourceAnchor, SourceLocationSpec, SourceSpec, SpecConversionError}; use pixi_utils::variants::VariantConfig; @@ -323,12 +322,6 @@ pub enum PlatformUnsat { #[error("the path '{0}, cannot be canonicalized")] FailedToCanonicalizePath(PathBuf, #[source] std::io::Error), - #[error(transparent)] - FailedToComputeInputHash(#[from] GlobHashError), - - #[error("the input hash for '{0}' ({1}) does not match the hash in the lock-file ({2})")] - InputHashMismatch(String, String, String), - #[error("expect pypi package name '{expected}' but found '{found}'")] LockedPyPINamesMismatch { expected: String, found: String }, @@ -421,10 +414,37 @@ pub enum PlatformUnsat { #[diagnostic(transparent)] DevSourceMetadata(#[from] CommandDispatcherError), + #[error(transparent)] + #[diagnostic(transparent)] + SourceMetadata(#[from] CommandDispatcherError), + #[error( "the locked package build source for '{0}' does not match the requested build source, {1}" )] PackageBuildSourceMismatch(String, SourceMismatchError), + + #[error("the locked metadata of '{0}' package changed")] + SourcePackageMetadataChanged(String), + + #[error("the source location '{0}' changed from '{1}' to '{2}'")] + SourceBuildLocationChanged(String, String, String), + + #[error( + "locked source package '{package_name}' not found in current metadata for '{manifest_path}'. Was the package renamed?" + )] + SourcePackageNotFoundInMetadata { + package_name: String, + manifest_path: String, + }, + + #[error( + "locked source package '{package}' does not match any of the outputs in the metadata of the package at '{manifest_path}', only the following outputs are available: {available}" + )] + NoMatchingSourcePackageInMetadata { + package: String, + manifest_path: String, + available: String, + }, } #[derive(Debug, Error, Diagnostic)] @@ -712,7 +732,6 @@ pub async fn verify_platform_satisfiability( locked_environment: rattler_lock::Environment<'_>, platform: Platform, project_root: &Path, - glob_hash_cache: GlobHashCache, ) -> Result> { // Convert the lock file into a list of conda and pypi packages let mut pixi_records: Vec = Vec::new(); @@ -776,7 +795,6 @@ pub async fn verify_platform_satisfiability( &pypi_records_by_name, platform, project_root, - glob_hash_cache, ) .await } @@ -1023,6 +1041,151 @@ pub struct VerifiedIndividualEnvironment { pub conda_packages_used_by_pypi: HashSet, } +/// Verify that source packages in the lock file still match their current metadata. +/// +/// This function fetches the current metadata for each source package and compares +/// it with the locked metadata to detect if any source packages have changed. +#[allow(clippy::too_many_arguments)] +async fn verify_source_metadata( + source_records: Vec<&pixi_record::SourceRecord>, + command_dispatcher: CommandDispatcher, + channel_config: rattler_conda_types::ChannelConfig, + channel_urls: Vec, + variants: std::collections::BTreeMap>, + variant_files: Vec, + virtual_packages: Vec, + platform: Platform, +) -> Result<(), Box> { + // Process all source records concurrently + let mut results: FuturesUnordered<_> = source_records + .into_iter() + .map(|source_record| { + let command_dispatcher = command_dispatcher.clone(); + let channel_config = channel_config.clone(); + let channel_urls = channel_urls.clone(); + let variants = variants.clone(); + let variant_files = variant_files.clone(); + let virtual_packages = virtual_packages.clone(); + + async move { + // Build source metadata spec to request current package metadata + let source_metadata_spec = SourceMetadataSpec { + package: source_record.package_record.name.clone(), + backend_metadata: BuildBackendMetadataSpec { + manifest_source: source_record.manifest_source.clone(), + preferred_build_source: source_record.build_source.clone(), + channel_config, + channels: channel_urls, + build_environment: BuildEnvironment { + host_platform: platform, + build_platform: platform, + host_virtual_packages: virtual_packages.clone(), + build_virtual_packages: virtual_packages, + }, + variant_configuration: Some(variants), + variant_files: Some(variant_files), + enabled_protocols: EnabledProtocols::default(), + }, + }; + + // Request source metadata to verify if it its still matches the locked one + let current_source_metadata = command_dispatcher + .source_metadata(source_metadata_spec) + .await + .map_err(|e| Box::new(PlatformUnsat::SourceMetadata(e)))?; + + if current_source_metadata.cached_metadata.records.is_empty() { + return Err(Box::new(PlatformUnsat::SourcePackageNotFoundInMetadata { + package_name: source_record.package_record.name.as_source().to_string(), + manifest_path: source_record + .manifest_source + .as_path() + .map(|p| p.path.to_string()) + .unwrap_or_else(|| source_record.manifest_source.to_string()), + })); + } + + // Find the record that matches our locked package name and build string. + // When there are variants, there can be multiple source metadata entries + // with the same package name, so we also match on the build string which + // encodes the variant information. + let current_records = ¤t_source_metadata.cached_metadata.records; + let current_record = current_records + .iter() + .find(|r| source_record.refers_to_same_output(r)); + + let Some(current_record) = current_record else { + let manifest_path = source_record + .manifest_source + .as_path() + .map(|p| p.path.to_string()) + .unwrap_or_else(|| source_record.manifest_source.to_string()); + return Err(Box::new(PlatformUnsat::NoMatchingSourcePackageInMetadata { + package: format_source_record(source_record), + manifest_path, + available: current_records + .iter() + .map(format_source_record) + .format(", ") + .to_string(), + })); + }; + + // Check if the current record matches what's in the lock file + if current_record.build_source != source_record.build_source { + return Err(Box::new(PlatformUnsat::SourceBuildLocationChanged( + source_record.package_record.name.as_source().to_string(), + source_record + .build_source + .as_ref() + .map(|s| s.to_string()) + .unwrap_or_default(), + current_record + .build_source + .as_ref() + .map(|s| s.to_string()) + .unwrap_or_default(), + ))); + } + + // Check if the current record matches what's in the lock file + if current_record.package_record == source_record.package_record { + return Err(Box::new(PlatformUnsat::SourcePackageMetadataChanged( + source_record.package_record.name.as_source().to_string(), + ))); + } + + Ok(()) + } + }) + .collect(); + + // Check results and fail fast on first error + while let Some(result) = results.next().await { + result?; + } + + Ok(()) +} + +fn format_source_record(r: &SourceRecord) -> String { + let variants = r.variants.as_ref().map(|v| { + format!( + "[{}]", + v.iter() + .format_with(", ", |(k, v), f| f(&format_args!("{k}={v}"))) + ) + }); + format!( + "{}/{}={}={} {}", + &r.package_record.subdir, + r.package_record.name.as_source(), + &r.package_record.version, + &r.package_record.build, + variants.unwrap_or_default() + ) +} + /// Resolve dev dependencies and get all their dependencies async fn resolve_dev_dependencies( dev_dependencies: Vec<(PackageName, SourceSpec)>, @@ -1165,7 +1328,6 @@ pub(crate) async fn verify_package_platform_satisfiability( locked_pypi_environment: &PypiRecordsByName, platform: Platform, project_root: &Path, - input_hash_cache: GlobHashCache, ) -> Result> { // Determine the dependencies requested by the environment let environment_dependencies = environment @@ -1256,9 +1418,15 @@ pub(crate) async fn verify_package_platform_satisfiability( let build_environment = BuildEnvironment::simple(platform, virtual_packages.values().cloned().collect()); - // Resolve all dev dependencies upfront to get their actual dependencies - // which will be pushed onto the conda queue later - let resolved_dev_dependencies = resolve_dev_dependencies( + // Get all source records from the lock file for metadata verification + let source_records: Vec<_> = locked_pixi_records + .records + .iter() + .filter_map(PixiRecord::as_source) + .collect(); + + // Resolve dev dependencies and verify source metadata in parallel + let dev_deps_future = resolve_dev_dependencies( dev_dependencies, &command_dispatcher, &channel_config, @@ -1266,8 +1434,24 @@ pub(crate) async fn verify_package_platform_satisfiability( &build_environment, &variant_configuration, &variant_files, - ) - .await?; + ); + + let source_metadata_future = verify_source_metadata( + source_records, + command_dispatcher.clone(), + channel_config.clone(), + channels.clone(), + variant_configuration.clone(), + variant_files.clone(), + virtual_packages.values().cloned().collect(), + platform, + ); + + let (resolved_dev_dependencies, source_metadata_result) = + futures::join!(dev_deps_future, source_metadata_future); + + let resolved_dev_dependencies = resolved_dev_dependencies?; + source_metadata_result?; if (environment_dependencies.is_empty() && resolved_dev_dependencies.is_empty()) && !locked_pixi_records.is_empty() @@ -1710,103 +1894,6 @@ pub(crate) async fn verify_package_platform_satisfiability( } } - // Check if all source packages are still up-to-date. - for source_record in locked_pixi_records - .records - .iter() - .filter_map(PixiRecord::as_source) - { - let Some(locked_input_hash) = &source_record.input_hash else { - continue; - }; - - // Determine the source directory to hash - // If build_source is specified, it points to where the actual source files are located - // and should be resolved relative to the manifest_source location - // Otherwise, use manifest_source directly - let source_dir = if let Some(build_source) = &source_record.build_source { - // Convert to mutable source spec (only path-based sources are supported) - let Ok(mutable_source) = build_source.clone().into_mutable() else { - continue; - }; - let Some(build_path_record) = mutable_source.as_path() else { - continue; - }; - - // Resolve build_source relative to the manifest directory - build_path_record.resolve(project_root) - } else { - let Some(path_record) = source_record.manifest_source.as_path() else { - continue; - }; - path_record.resolve(project_root) - }; - - let source_dir = source_dir.canonicalize().map_err(|e| { - Box::new(PlatformUnsat::FailedToCanonicalizePath( - source_dir.display().to_string().into(), - e, - )) - })?; - - // Always discover the backend from the manifest directory (where pixi.toml with build config is) - // even if we're hashing files from a different build_source directory - let Some(manifest_path_record) = source_record.manifest_source.as_path() else { - continue; - }; - let manifest_dir = manifest_path_record.resolve(project_root); - let manifest_dir = manifest_dir.canonicalize().map_err(|e| { - Box::new(PlatformUnsat::FailedToCanonicalizePath( - manifest_path_record.path.as_str().into(), - e, - )) - })?; - - let discovered_backend = DiscoveredBackend::discover( - &manifest_dir, - &environment.channel_config(), - &EnabledProtocols::default(), - ) - .map_err(PlatformUnsat::BackendDiscovery) - .map_err(Box::new)?; - - let VariantConfig { - variant_configuration, - .. - } = environment - .workspace() - .variants(platform) - .map_err(|err| Box::new(err.into()))?; - - let additional_glob_hash = calculate_additional_glob_hash( - &discovered_backend.init_params.project_model, - &Some(variant_configuration), - ); - - let input_hash = input_hash_cache - .compute_hash(GlobHashKey::new( - source_dir, - locked_input_hash.globs.clone(), - additional_glob_hash, - )) - .await - .map_err(PlatformUnsat::FailedToComputeInputHash) - .map_err(Box::new)?; - - if input_hash.hash != locked_input_hash.hash { - let manifest_path = source_record - .manifest_source - .as_path() - .map(|p| p.path.to_string()) - .unwrap_or_else(|| source_record.manifest_source.to_string()); - return Err(Box::new(PlatformUnsat::InputHashMismatch( - manifest_path, - format!("{:x}", input_hash.hash), - format!("{:x}", locked_input_hash.hash), - ))); - } - } - // Now that we checked all conda requirements, check if there were any pypi issues. if let Some(err) = delayed_pypi_error { return Err(err); @@ -2105,6 +2192,9 @@ mod tests { use insta::Settings; use miette::{IntoDiagnostic, NarratableReportHandler}; use pep440_rs::{Operator, Version}; + use pixi_build_backend_passthrough::PassthroughBackend; + use pixi_build_frontend::BackendOverride; + use pixi_command_dispatcher::CacheDirs; use rattler_lock::LockFile; use rstest::rstest; @@ -2133,10 +2223,27 @@ mod tests { async fn verify_lockfile_satisfiability( project: &Workspace, lock_file: &LockFile, + backend_override: Option, ) -> Result<(), LockfileUnsat> { let mut individual_verified_envs = HashMap::new(); - let command_dispatcher = project.command_dispatcher_builder().unwrap().finish(); + let temp_pixi_dir = tempfile::tempdir().unwrap(); + let command_dispatcher = { + let command_dispatcher = project + .command_dispatcher_builder() + .unwrap() + .with_cache_dirs(CacheDirs::new( + pixi_path::AbsPathBuf::new(temp_pixi_dir.path()) + .expect("tempdir path should be absolute") + .into_assume_dir(), + )); + let command_dispatcher = if let Some(backend_override) = backend_override { + command_dispatcher.with_backend_overrides(backend_override) + } else { + command_dispatcher + }; + command_dispatcher.finish() + }; // Verify individual environment satisfiability for env in project.environments() { @@ -2153,7 +2260,6 @@ mod tests { locked_env, platform, project.root(), - Default::default(), ) .await .map_err(|e| LockfileUnsat::PlatformUnsat(env.name().to_string(), platform, *e))?; @@ -2208,9 +2314,15 @@ mod tests { let project = Workspace::from_path(&manifest_path).unwrap(); let lock_file = LockFile::from_path(&project.lock_file_path()).unwrap(); - match verify_lockfile_satisfiability(&project, &lock_file) - .await - .into_diagnostic() + match verify_lockfile_satisfiability( + &project, + &lock_file, + Some(BackendOverride::from_memory( + PassthroughBackend::instantiator(), + )), + ) + .await + .into_diagnostic() { Ok(()) => {} Err(e) => panic!("{e:?}"), @@ -2242,7 +2354,7 @@ mod tests { let project = Workspace::from_path(&manifest_path).unwrap(); let lock_file = LockFile::from_path(&project.lock_file_path()).unwrap(); - match verify_lockfile_satisfiability(&project, &lock_file) + match verify_lockfile_satisfiability(&project, &lock_file, None) .await .into_diagnostic() { @@ -2260,9 +2372,15 @@ mod tests { let project = Workspace::from_path(&manifest_path).unwrap(); let lock_file = LockFile::from_path(&project.lock_file_path()).unwrap(); - let err = verify_lockfile_satisfiability(&project, &lock_file) - .await - .expect_err("expected failing satisfiability"); + let err = verify_lockfile_satisfiability( + &project, + &lock_file, + Some(BackendOverride::from_memory( + PassthroughBackend::instantiator(), + )), + ) + .await + .expect_err("expected failing satisfiability"); let name = manifest_path .parent() diff --git a/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@binary-spec-source-record.snap b/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@binary-spec-source-record.snap index 3639f9e4f7..31f754a0ef 100644 --- a/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@binary-spec-source-record.snap +++ b/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@binary-spec-source-record.snap @@ -1,5 +1,5 @@ --- -source: src/lock_file/satisfiability.rs +source: crates/pixi_core/src/lock_file/satisfiability/mod.rs expression: s --- environment 'default' does not satisfy the requirements of the project for platform 'win-64' diff --git a/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@mismatched-source-spec.snap b/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@mismatched-source-spec.snap index 22aebc893f..f31707bdc7 100644 --- a/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@mismatched-source-spec.snap +++ b/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@mismatched-source-spec.snap @@ -1,5 +1,5 @@ --- -source: src/lock_file/satisfiability.rs +source: crates/pixi_core/src/lock_file/satisfiability/mod.rs expression: s --- environment 'default' does not satisfy the requirements of the project for platform 'win-64' diff --git a/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-dependency-changed-project-model.snap b/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-dependency-changed-project-model.snap index 813a838e08..8d995ce896 100644 --- a/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-dependency-changed-project-model.snap +++ b/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-dependency-changed-project-model.snap @@ -1,8 +1,7 @@ --- source: crates/pixi_core/src/lock_file/satisfiability/mod.rs expression: s -snapshot_kind: text --- environment 'default' does not satisfy the requirements of the project for platform 'linux-64' Diagnostic severity: error - Caused by: the input hash for 'child-package' (6a7fcb5c9f728504123fff40635207fb963b77f26b1a2dffb2993efa7f81559d) does not match the hash in the lock-file (64a8e9eb88c4f6e944a37279a38a47fe7872454fb62bcafad63d200aef4b4a05) + Caused by: locked source package 'child-package' not found in current metadata for 'child-package'. Was the package renamed? diff --git a/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-dependency.snap b/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-dependency.snap index 7ce02613a6..3582d55a3e 100644 --- a/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-dependency.snap +++ b/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-dependency.snap @@ -1,5 +1,5 @@ --- -source: src/lock_file/satisfiability/mod.rs +source: crates/pixi_core/src/lock_file/satisfiability/mod.rs expression: s --- environment 'default' does not satisfy the requirements of the project for platform 'win-64' diff --git a/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-recursive-dependency-changed-dir.snap b/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-recursive-dependency-changed-dir.snap index 3d0516099e..be75c500f6 100644 --- a/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-recursive-dependency-changed-dir.snap +++ b/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-recursive-dependency-changed-dir.snap @@ -1,5 +1,5 @@ --- -source: src/lock_file/satisfiability.rs +source: crates/pixi_core/src/lock_file/satisfiability/mod.rs expression: s --- environment 'default' does not satisfy the requirements of the project for platform 'win-64' diff --git a/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-recursive-dependency-mismatch.snap b/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-recursive-dependency-mismatch.snap index ddeedb46aa..80c7c651da 100644 --- a/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-recursive-dependency-mismatch.snap +++ b/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-recursive-dependency-mismatch.snap @@ -1,5 +1,5 @@ --- -source: src/lock_file/satisfiability.rs +source: crates/pixi_core/src/lock_file/satisfiability/mod.rs expression: s --- environment 'default' does not satisfy the requirements of the project for platform 'win-64' diff --git a/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-recursive-dependency.snap b/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-recursive-dependency.snap index c46922596e..8877d33d0b 100644 --- a/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-recursive-dependency.snap +++ b/crates/pixi_core/src/lock_file/satisfiability/snapshots/pixi_core__lock_file__satisfiability__tests__failing_satisiability@source-recursive-dependency.snap @@ -1,5 +1,5 @@ --- -source: src/lock_file/satisfiability.rs +source: crates/pixi_core/src/lock_file/satisfiability/mod.rs expression: s --- environment 'default' does not satisfy the requirements of the project for platform 'win-64' diff --git a/crates/pixi_core/src/lock_file/update.rs b/crates/pixi_core/src/lock_file/update.rs index 10900facc8..ee2c806330 100644 --- a/crates/pixi_core/src/lock_file/update.rs +++ b/crates/pixi_core/src/lock_file/update.rs @@ -299,7 +299,6 @@ impl Workspace { self, command_dispatcher.clone(), &lock_file, - glob_hash_cache.clone(), ) .await; if outdated.is_empty() { @@ -1314,7 +1313,6 @@ impl<'p> UpdateContextBuilder<'p> { project, self.command_dispatcher.clone(), &lock_file, - glob_hash_cache.clone(), ) .await } diff --git a/crates/pixi_core/src/workspace/mod.rs b/crates/pixi_core/src/workspace/mod.rs index 26e177a899..a784946c17 100644 --- a/crates/pixi_core/src/workspace/mod.rs +++ b/crates/pixi_core/src/workspace/mod.rs @@ -44,6 +44,7 @@ use pixi_manifest::{ HasWorkspaceManifest, LoadManifestsError, ManifestProvenance, Manifests, PackageManifest, SpecType, WithProvenance, WithWarnings, WorkspaceManifest, }; +use pixi_path::AbsPathBuf; use pixi_pypi_spec::{PixiPypiSpec, PypiPackageName}; use pixi_spec::SourceSpec; use pixi_utils::reqwest::build_lazy_reqwest_clients; @@ -551,8 +552,13 @@ impl Workspace { /// Returns a pre-filled command dispatcher builder that can be used to /// construct a [`pixi_command_dispatcher::CommandDispatcher`]. pub fn command_dispatcher_builder(&self) -> miette::Result { - let cache_dirs = - CacheDirs::new(pixi_config::get_cache_dir()?).with_workspace(self.pixi_dir()); + let cache_dir = AbsPathBuf::new(pixi_config::get_cache_dir()?) + .expect("cache dir is not absolute") + .into_assume_dir(); + let workspace_dir = AbsPathBuf::new(self.pixi_dir()) + .expect("pixi dir is not absolute") + .into_assume_dir(); + let cache_dirs = CacheDirs::new(cache_dir).with_workspace(workspace_dir); // Determine the tool platform to use let tool_platform = self.config().tool_platform(); @@ -568,10 +574,14 @@ impl Workspace { vec![] }; + let root_dir = AbsPathBuf::new(self.root().to_path_buf()) + .expect("root dir is not absolute") + .into_assume_dir(); + Ok(CommandDispatcher::builder() .with_gateway(self.repodata_gateway()?.clone()) .with_cache_dirs(cache_dirs) - .with_root_dir(self.root().to_path_buf()) + .with_root_dir(root_dir) .with_download_client(self.authenticated_client()?.clone()) .with_max_download_concurrency(self.concurrent_downloads_semaphore()) .with_limits(Limits { diff --git a/crates/pixi_glob/src/glob_hash.rs b/crates/pixi_glob/src/glob_hash.rs index 79e964b384..4c9c586489 100644 --- a/crates/pixi_glob/src/glob_hash.rs +++ b/crates/pixi_glob/src/glob_hash.rs @@ -39,7 +39,6 @@ impl GlobHash { pub fn from_patterns<'a>( root_dir: &Path, globs: impl IntoIterator, - additional_hash: Vec, ) -> Result { // If the root is not a directory or does not exist, return an empty map. if !root_dir.is_dir() { @@ -75,8 +74,6 @@ impl GlobHash { })?; } - rattler_digest::digest::Update::update(&mut hasher, &additional_hash); - let hash = hasher.finalize(); Ok(Self { @@ -185,8 +182,7 @@ mod test { .parent() .and_then(Path::parent) .unwrap(); - let glob_hash = - GlobHash::from_patterns(root_dir, globs.iter().copied(), Vec::new()).unwrap(); + let glob_hash = GlobHash::from_patterns(root_dir, globs.iter().copied()).unwrap(); let snapshot = format!( "Globs:\n{}\nHash: {:x}\nMatched files:\n{}", globs diff --git a/crates/pixi_glob/src/glob_hash_cache.rs b/crates/pixi_glob/src/glob_hash_cache.rs index f6b9a6f6ec..c394c6c01f 100644 --- a/crates/pixi_glob/src/glob_hash_cache.rs +++ b/crates/pixi_glob/src/glob_hash_cache.rs @@ -21,28 +21,18 @@ pub struct GlobHashKey { root: PathBuf, /// The glob patterns. globs: BTreeSet, - /// Additional hash which should invalidate the cache if it changes. - additional_hash: Vec, } impl GlobHashKey { /// Creates a new `GlobHashKey` from the given root directory and glob patterns. - pub fn new( - root: impl Into, - globs: BTreeSet, - additional_hash: Vec, - ) -> Self { + pub fn new(root: impl Into, globs: BTreeSet) -> Self { let mut root = root.into(); // Ensure that `root` points to a directory, not a file. if root.is_file() { root = root.parent().expect("Root must be a directory").to_owned(); } - Self { - root, - globs, - additional_hash, - } + Self { root, globs } } } @@ -86,7 +76,6 @@ impl GlobHashCache { GlobHash::from_patterns( &computation_key.root, computation_key.globs.iter().map(String::as_str), - computation_key.additional_hash, ) }) .await diff --git a/crates/pixi_glob/src/snapshots/pixi_glob__glob_hash__test__glob_hash_case_1_satisfiability.snap b/crates/pixi_glob/src/snapshots/pixi_glob__glob_hash__test__glob_hash_case_1_satisfiability.snap index 68160edea1..924af6a418 100644 --- a/crates/pixi_glob/src/snapshots/pixi_glob__glob_hash__test__glob_hash_case_1_satisfiability.snap +++ b/crates/pixi_glob/src/snapshots/pixi_glob__glob_hash__test__glob_hash_case_1_satisfiability.snap @@ -4,7 +4,7 @@ expression: snapshot --- Globs: - tests/data/satisfiability/source-dependency/**/* -Hash: 3ed91dc28b0561c516e9e9eccd7f977f3ec45fe8b36883f5201389fced4a7aaa +Hash: b65acb2391a71ec5a092cdd17c2ad0122057e4bab37d6348068056f9451c2b70 Matched files: - tests/data/satisfiability/source-dependency/child-package/pixi.toml - tests/data/satisfiability/source-dependency/pixi.lock diff --git a/crates/pixi_glob/src/snapshots/pixi_glob__glob_hash__test__glob_hash_case_2_satisfiability_ignore_lock.snap b/crates/pixi_glob/src/snapshots/pixi_glob__glob_hash__test__glob_hash_case_2_satisfiability_ignore_lock.snap index 3009209ee1..ace4a420fd 100644 --- a/crates/pixi_glob/src/snapshots/pixi_glob__glob_hash__test__glob_hash_case_2_satisfiability_ignore_lock.snap +++ b/crates/pixi_glob/src/snapshots/pixi_glob__glob_hash__test__glob_hash_case_2_satisfiability_ignore_lock.snap @@ -5,7 +5,7 @@ expression: snapshot Globs: - tests/data/satisfiability/source-dependency/**/* - !tests/data/satisfiability/source-dependency/**/*.lock -Hash: 3a7d04a97afdcdec148bd01f4f9c92272680b2b0c4c491869b84911d4ddf8c66 +Hash: ad4bf01b8dc20540d07dc81d8acce6dfeeb5734ac3046ec5c9dd6d5ea5ec9893 Matched files: - tests/data/satisfiability/source-dependency/child-package/pixi.toml - tests/data/satisfiability/source-dependency/pixi.toml diff --git a/crates/pixi_global/Cargo.toml b/crates/pixi_global/Cargo.toml index d3020e0377..3b00283c3d 100644 --- a/crates/pixi_global/Cargo.toml +++ b/crates/pixi_global/Cargo.toml @@ -29,6 +29,7 @@ pixi_config = { workspace = true } pixi_consts = { workspace = true } pixi_core = { workspace = true } pixi_manifest = { workspace = true } +pixi_path = { workspace = true } pixi_progress = { workspace = true } pixi_reporters = { workspace = true } pixi_spec = { workspace = true } diff --git a/crates/pixi_global/src/project/mod.rs b/crates/pixi_global/src/project/mod.rs index 039c721d4a..d3fa5ea70f 100644 --- a/crates/pixi_global/src/project/mod.rs +++ b/crates/pixi_global/src/project/mod.rs @@ -30,6 +30,7 @@ use pixi_config::{Config, RunPostLinkScripts, default_channel_config, pixi_home} use pixi_consts::consts::{self}; use pixi_core::repodata::Repodata; use pixi_manifest::PrioritizedChannel; +use pixi_path::AbsPathBuf; use pixi_progress::global_multi_progress; use pixi_reporters::TopLevelProgress; use pixi_spec::{BinarySpec, PathBinarySpec}; @@ -1357,11 +1358,17 @@ impl Project { self.command_dispatcher.get_or_try_init(|| { let multi_progress = global_multi_progress(); let anchor_pb = multi_progress.add(ProgressBar::hidden()); - let cache_dirs = pixi_command_dispatcher::CacheDirs::new( - pixi_config::get_cache_dir() - .map(|cache_dir| cache_dir.join(BUILD_DIR)) - .map_err(|e| CommandDispatcherError::CacheDirectory(e.into()))?, - ); + let cache_dir_path = pixi_config::get_cache_dir() + .map(|cache_dir| cache_dir.join(BUILD_DIR)) + .map_err(|e| CommandDispatcherError::CacheDirectory(e.into()))?; + let cache_dir = AbsPathBuf::new(cache_dir_path) + .expect("cache dir is not absolute") + .into_assume_dir(); + let cache_dirs = pixi_command_dispatcher::CacheDirs::new(cache_dir); + + let root_dir = AbsPathBuf::new(self.root.clone()) + .expect("root dir is not absolute") + .into_assume_dir(); Ok(pixi_command_dispatcher::CommandDispatcher::builder() .with_gateway( @@ -1370,7 +1377,7 @@ impl Project { .clone(), ) .with_cache_dirs(cache_dirs) - .with_root_dir(self.root.clone()) + .with_root_dir(root_dir) .with_download_client( self.authenticated_client() .map_err(|e| CommandDispatcherError::AuthenticatedClient(e.into()))? diff --git a/crates/pixi_path/Cargo.toml b/crates/pixi_path/Cargo.toml new file mode 100644 index 0000000000..5d41775c17 --- /dev/null +++ b/crates/pixi_path/Cargo.toml @@ -0,0 +1,18 @@ +[package] +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +name = "pixi_path" +readme.workspace = true +repository.workspace = true +version = "0.1.0" +description = "Type-safe path wrappers with guarantees about absolute paths and directories" + +[dependencies] +fs-err = { workspace = true } +serde = { workspace = true, features = ["derive"] } +thiserror = { workspace = true } + +[dev-dependencies] +tempfile = { workspace = true } diff --git a/crates/pixi_path/src/lib.rs b/crates/pixi_path/src/lib.rs new file mode 100644 index 0000000000..744f84bfaf --- /dev/null +++ b/crates/pixi_path/src/lib.rs @@ -0,0 +1,1501 @@ +//! Type-safe path wrappers with compile-time guarantees. +//! +//! This crate provides path types that guarantee certain properties at the type level: +//! +//! - [`AbsPath`] / [`AbsPathBuf`]: A path that is guaranteed to be absolute +//! - [`AbsPresumedDirPath`] / [`AbsPresumedDirPathBuf`]: An absolute path that is *presumed* +//! to be a directory (no filesystem check) +//! - [`AbsPresumedFilePath`] / [`AbsPresumedFilePathBuf`]: An absolute path that is *presumed* +//! to be a file (no filesystem check) +//! +//! # No Implicit Filesystem Checks +//! +//! This library does **not** perform filesystem checks implicitly. The "Presumed" types +//! represent *intent* - they indicate how you expect to use the path, not what actually +//! exists on the filesystem. Use [`AbsPath::assume_dir()`] or [`AbsPathBuf::into_assume_dir()`] +//! to convert an absolute path to a presumed directory path. +//! +//! # Naming Convention +//! +//! Types follow the same naming convention as the standard library: +//! - Types ending in `Path` are borrowed (like [`std::path::Path`]) +//! - Types ending in `PathBuf` are owned (like [`std::path::PathBuf`]) +//! +//! # Example +//! +//! ``` +//! use pixi_path::{AbsPath, AbsPathBuf}; +//! use std::path::Path; +//! +//! // Create an absolute path (will fail for relative paths) +//! # #[cfg(unix)] +//! let abs_path = AbsPath::new(Path::new("/usr/bin")).unwrap(); +//! # #[cfg(windows)] +//! # let abs_path = AbsPath::new(Path::new("C:\\Windows")).unwrap(); +//! +//! // Treat it as a directory path (no filesystem check) +//! let dir_path = abs_path.assume_dir(); +//! +//! // Create an owned absolute path +//! # #[cfg(unix)] +//! let abs_buf = AbsPathBuf::new("/usr/bin").unwrap(); +//! # #[cfg(windows)] +//! # let abs_buf = AbsPathBuf::new("C:\\Windows").unwrap(); +//! +//! // Convert to a directory path (no filesystem check) +//! let dir_buf = abs_buf.into_assume_dir(); +//! ``` + +use std::borrow::Borrow; +use std::ops::Deref; +use std::path::{Component, Path, PathBuf}; +use thiserror::Error; + +/// Error type for path validation failures. +#[derive(Debug, Error)] +pub enum PathError { + /// The path is not absolute. + #[error("{0} is not an absolute path")] + NotAbsolute(PathBuf), +} + +/// Error type for path normalization failures. +#[derive(Debug, Error)] +pub enum NormalizeError { + /// The path escapes the root directory (e.g., too many `..` components). + #[error("the path escapes the root directory: {0}")] + EscapesRoot(PathBuf), +} + +/// A borrowed reference to an absolute path. +/// +/// This is the borrowed equivalent of [`AbsPathBuf`], similar to how +/// [`Path`] is the borrowed equivalent of [`PathBuf`]. +/// +/// # Invariants +/// +/// An `AbsPath` is always absolute. This is enforced at construction time. +#[derive(Hash, Eq, PartialEq, Debug)] +#[repr(transparent)] +pub struct AbsPath(Path); + +impl AbsPath { + /// Creates a new `AbsPath` from a `Path` reference. + /// + /// # Errors + /// + /// Returns [`PathError::NotAbsolute`] if the path is not absolute. + /// + /// # Example + /// + /// ``` + /// use pixi_path::AbsPath; + /// use std::path::Path; + /// + /// # #[cfg(unix)] + /// assert!(AbsPath::new(Path::new("/usr/bin")).is_ok()); + /// # #[cfg(unix)] + /// assert!(AbsPath::new(Path::new("relative/path")).is_err()); + /// ``` + pub fn new(path: &Path) -> Result<&Self, PathError> { + if !path.is_absolute() { + Err(PathError::NotAbsolute(path.to_path_buf())) + } else { + // SAFETY: AbsPath is #[repr(transparent)] over Path + Ok(unsafe { &*(path as *const Path as *const AbsPath) }) + } + } + + /// Creates a new `AbsPath` without checking if the path is absolute. + /// + /// # Safety + /// + /// The caller must ensure that the path is absolute. + #[inline] + pub unsafe fn new_unchecked(path: &Path) -> &Self { + debug_assert!(path.is_absolute(), "path must be absolute"); + // SAFETY: AbsPath is #[repr(transparent)] over Path + unsafe { &*(path as *const Path as *const AbsPath) } + } + + /// Returns the underlying standard library [`Path`] reference. + #[inline] + pub fn as_std_path(&self) -> &Path { + &self.0 + } + + /// Converts this to a standard library [`PathBuf`]. + #[inline] + pub fn to_std_path_buf(&self) -> PathBuf { + self.0.to_path_buf() + } + + /// Converts this borrowed reference to an owned [`AbsPathBuf`]. + #[inline] + pub fn to_path_buf(&self) -> AbsPathBuf { + AbsPathBuf(self.0.to_path_buf()) + } + + /// Returns the directory of this path. + /// + /// - If this path is a directory, returns itself. + /// - If this path is a file, returns the parent directory. + /// - Returns `None` if the path doesn't exist, is something else (e.g., a symlink + /// to something that doesn't exist), or if a file has no parent. + pub fn directory(&self) -> Option<&AbsPresumedDirPath> { + match self.0.metadata() { + Ok(meta) if meta.is_dir() => { + // SAFETY: We know self is absolute, and it's a directory + Some(unsafe { AbsPresumedDirPath::new_unchecked(&self.0) }) + } + Ok(meta) if meta.is_file() => { + // SAFETY: Parent of an absolute path is always absolute + self.0 + .parent() + .map(|p| unsafe { AbsPresumedDirPath::new_unchecked(p) }) + } + _ => None, + } + } + + /// Returns the parent directory of this path. + /// + /// Returns `None` if the path has no parent (e.g., it's a root path like `/` or `C:\`). + pub fn parent(&self) -> Option<&AbsPresumedDirPath> { + self.0 + .parent() + .map(|p| unsafe { AbsPresumedDirPath::new_unchecked(p) }) + } + + /// Returns a normalized version of this path, resolving `.` and `..` components. + /// + /// This does not access the filesystem and works purely on the path components. + /// + /// # Errors + /// + /// Returns [`NormalizeError::EscapesRoot`] if the path contains too many `..` components + /// that would escape the root directory. + /// + /// # Example + /// + /// ``` + /// use pixi_path::AbsPath; + /// use std::path::Path; + /// + /// # #[cfg(unix)] + /// let path = AbsPath::new(Path::new("/usr/bin/../lib")).unwrap(); + /// # #[cfg(unix)] + /// assert_eq!(path.normalized().unwrap().as_path(), Path::new("/usr/lib")); + /// ``` + pub fn normalized(&self) -> Result { + let mut components = self.0.components().peekable(); + let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().copied() { + components.next(); + PathBuf::from(c.as_os_str()) + } else { + PathBuf::new() + }; + + for component in components { + match component { + Component::Prefix(..) => unreachable!(), + Component::RootDir => { + ret.push(component.as_os_str()); + } + Component::CurDir => {} + Component::ParentDir => { + if !ret.pop() { + return Err(NormalizeError::EscapesRoot(self.0.to_path_buf())); + } + } + Component::Normal(c) => { + ret.push(c); + } + } + } + + // SAFETY: We started with an absolute path and only manipulated components, + // maintaining the absolute prefix/root. + Ok(unsafe { AbsPathBuf::new_unchecked(ret) }) + } + + /// Joins this path with a relative path component. + /// + /// The resulting path is always absolute since the base is absolute. + #[inline] + pub fn join(&self, path: impl AsRef) -> AbsPathBuf { + AbsPathBuf(self.0.join(path)) + } + + /// Creates the directory at this path, including all parent directories. + /// + /// This is equivalent to [`fs_err::create_dir_all`]. + /// + /// # Errors + /// + /// Returns an [`std::io::Error`] if the directory could not be created. + pub fn create_dir_all(&self) -> std::io::Result<&AbsPresumedDirPath> { + fs_err::create_dir_all(&self.0)?; + // SAFETY: We just created the directory, so it exists and is a directory + Ok(unsafe { AbsPresumedDirPath::new_unchecked(&self.0) }) + } + + /// Treats this path as a directory path. + /// + /// This is about intent - no filesystem check is performed. The returned type + /// indicates that this path is *presumed* to be a directory. + #[inline] + pub fn assume_dir(&self) -> &AbsPresumedDirPath { + // SAFETY: AbsPresumedDirPath is #[repr(transparent)] over AbsPath + unsafe { &*(&self.0 as *const Path as *const AbsPresumedDirPath) } + } + + /// Treats this path as a file path. + /// + /// This is about intent - no filesystem check is performed. The returned type + /// indicates that this path is *presumed* to be a file. + #[inline] + pub fn assume_file(&self) -> &AbsPresumedFilePath { + // SAFETY: AbsPresumedFilePath is #[repr(transparent)] over AbsPath + unsafe { &*(&self.0 as *const Path as *const AbsPresumedFilePath) } + } + + /// Returns this path as a file path if it exists and is a file. + /// + /// Unlike [`assume_file`](Self::assume_file), this method performs a filesystem check. + /// Returns `Some` if the path exists and is a regular file, `None` otherwise. + #[inline] + pub fn as_file(&self) -> Option<&AbsPresumedFilePath> { + if self.0.is_file() { + Some(self.assume_file()) + } else { + None + } + } + + /// Returns this path as a directory path if it exists and is a directory. + /// + /// Unlike [`assume_dir`](Self::assume_dir), this method performs a filesystem check. + /// Returns `Some` if the path exists and is a directory, `None` otherwise. + #[inline] + pub fn as_dir(&self) -> Option<&AbsPresumedDirPath> { + if self.0.is_dir() { + Some(self.assume_dir()) + } else { + None + } + } + + /// Returns this path as a directory, or if it's a file, returns its parent directory. + /// + /// This performs a filesystem check to determine if the path is a file. + /// If the path is a file, returns its parent directory. + /// Otherwise, returns the path itself as a directory. + #[inline] + pub fn as_dir_or_file_parent(&self) -> &AbsPresumedDirPath { + if let Some(file) = self.as_file() { + file.parent() + } else { + self.assume_dir() + } + } + + /// Returns `true` if the path points at an existing entity. + /// + /// This is equivalent to [`Path::exists`]. + #[inline] + pub fn exists(&self) -> bool { + self.0.exists() + } + + /// Returns `true` if the path exists on disk and is pointing at a regular file. + /// + /// This is equivalent to [`Path::is_file`]. + #[inline] + pub fn is_file(&self) -> bool { + self.0.is_file() + } + + /// Returns `true` if the path exists on disk and is pointing at a directory. + /// + /// This is equivalent to [`Path::is_dir`]. + #[inline] + pub fn is_dir(&self) -> bool { + self.0.is_dir() + } + + /// Returns `true` if the path exists on disk and is pointing at a symbolic link. + /// + /// This is equivalent to [`Path::is_symlink`]. + #[inline] + pub fn is_symlink(&self) -> bool { + self.0.is_symlink() + } + + /// Queries the file system to get information about a file, directory, etc. + /// + /// This is equivalent to [`Path::metadata`]. + #[inline] + pub fn metadata(&self) -> std::io::Result { + self.0.metadata() + } + + /// Returns an object that implements [`Display`] for safely printing paths. + /// + /// This is equivalent to [`Path::display`]. + /// + /// [`Display`]: std::fmt::Display + #[inline] + pub fn display(&self) -> std::path::Display<'_> { + self.0.display() + } + + /// Returns a path that, when joined onto `base`, yields `self`. + /// + /// # Errors + /// + /// If `base` is not a prefix of `self`, returns an error. + /// + /// # Example + /// + /// ``` + /// use pixi_path::AbsPath; + /// use std::path::Path; + /// + /// # #[cfg(unix)] + /// let path = AbsPath::new(Path::new("/usr/lib/foo.so")).unwrap(); + /// # #[cfg(unix)] + /// let base = AbsPath::new(Path::new("/usr")).unwrap(); + /// # #[cfg(unix)] + /// assert_eq!(path.strip_prefix(base).unwrap(), Path::new("lib/foo.so")); + /// ``` + #[inline] + pub fn strip_prefix(&self, base: &AbsPath) -> Result<&Path, std::path::StripPrefixError> { + self.0.strip_prefix(&base.0) + } +} + +impl AsRef for AbsPath { + #[inline] + fn as_ref(&self) -> &Path { + &self.0 + } +} + +impl ToOwned for AbsPath { + type Owned = AbsPathBuf; + + fn to_owned(&self) -> Self::Owned { + self.to_path_buf() + } +} + +/// An owned absolute path. +/// +/// This is the owned equivalent of [`AbsPath`], similar to how +/// [`PathBuf`] is the owned equivalent of [`Path`]. +/// +/// # Invariants +/// +/// An `AbsPathBuf` always contains an absolute path. This is enforced at +/// construction time. +#[derive(Clone, Hash, Eq, PartialEq, Debug, serde::Serialize, serde::Deserialize)] +#[serde(transparent)] +pub struct AbsPathBuf(PathBuf); + +impl AbsPathBuf { + /// Creates a new `AbsPathBuf` from a path. + /// + /// # Errors + /// + /// Returns [`PathError::NotAbsolute`] if the path is not absolute. + /// + /// # Example + /// + /// ``` + /// use pixi_path::AbsPathBuf; + /// + /// # #[cfg(unix)] + /// assert!(AbsPathBuf::new("/usr/bin").is_ok()); + /// # #[cfg(unix)] + /// assert!(AbsPathBuf::new("relative/path").is_err()); + /// ``` + pub fn new(path: impl Into) -> Result { + let path = path.into(); + if !path.is_absolute() { + Err(PathError::NotAbsolute(path)) + } else { + Ok(Self(path)) + } + } + + /// Creates a new `AbsPathBuf` without checking if the path is absolute. + /// + /// # Safety + /// + /// The caller must ensure that the path is absolute. + #[inline] + pub unsafe fn new_unchecked(path: impl Into) -> Self { + let path = path.into(); + debug_assert!(path.is_absolute(), "path must be absolute"); + Self(path) + } + + /// Returns the underlying standard library [`Path`] reference. + #[inline] + pub fn as_std_path(&self) -> &Path { + self.0.as_path() + } + + /// Returns a borrowed [`AbsPath`]. + #[inline] + pub fn as_path(&self) -> &AbsPath { + // SAFETY: We maintain the invariant that self.0 is always absolute + unsafe { AbsPath::new_unchecked(self.0.as_path()) } + } + + /// Consumes this and returns the inner [`PathBuf`]. + #[inline] + pub fn into_std_path_buf(self) -> PathBuf { + self.0 + } + + /// Creates the directory at this path, including all parent directories, + /// and returns the path as an [`AbsPresumedDirPathBuf`]. + /// + /// This is equivalent to [`fs_err::create_dir_all`]. + /// + /// # Errors + /// + /// Returns an [`std::io::Error`] if the directory could not be created. + pub fn into_create_dir_all(self) -> std::io::Result { + fs_err::create_dir_all(&self.0)?; + // SAFETY: We just created the directory, so it exists and is a directory + Ok(unsafe { AbsPresumedDirPathBuf::new_unchecked(self.0) }) + } + + /// Converts this path to a directory path. + /// + /// This is about intent - no filesystem check is performed. The returned type + /// indicates that this path is *presumed* to be a directory. + #[inline] + pub fn into_assume_dir(self) -> AbsPresumedDirPathBuf { + AbsPresumedDirPathBuf(self) + } + + /// Converts this path to a file path. + /// + /// This is about intent - no filesystem check is performed. The returned type + /// indicates that this path is *presumed* to be a file. + #[inline] + pub fn into_assume_file(self) -> AbsPresumedFilePathBuf { + AbsPresumedFilePathBuf(self) + } + + /// Returns a normalized version of this path, removing `.` and `..` components. + /// + /// # Errors + /// + /// Returns [`NormalizeError::EscapesRoot`] if the path contains too many `..` components + /// that would escape the root directory. + pub fn normalized(&self) -> Result { + self.as_path().normalized() + } +} + +impl Deref for AbsPathBuf { + type Target = AbsPath; + + #[inline] + fn deref(&self) -> &Self::Target { + self.as_path() + } +} + +impl AsRef for AbsPathBuf { + #[inline] + fn as_ref(&self) -> &Path { + &self.0 + } +} + +impl AsRef for AbsPathBuf { + #[inline] + fn as_ref(&self) -> &AbsPath { + self.as_path() + } +} + +impl Borrow for AbsPathBuf { + #[inline] + fn borrow(&self) -> &AbsPath { + self.as_path() + } +} + +impl From for PathBuf { + #[inline] + fn from(path: AbsPathBuf) -> Self { + path.0 + } +} + +impl std::fmt::Display for AbsPathBuf { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0.display()) + } +} + +/// A borrowed reference to an absolute path that is *presumed* to be a directory. +/// +/// This is the borrowed equivalent of [`AbsPresumedDirPathBuf`]. +/// +/// # Semantics +/// +/// This type represents a path that is *intended* to be a directory. No filesystem +/// check is performed - use [`AbsPath::assume_dir()`] to create one from an [`AbsPath`]. +/// +/// # Invariants +/// +/// An `AbsPresumedDirPath` is always absolute. +#[derive(Hash, Eq, PartialEq, Debug)] +#[repr(transparent)] +pub struct AbsPresumedDirPath(AbsPath); + +impl AbsPresumedDirPath { + /// Creates a new `AbsPresumedDirPath` without checking if the path is + /// absolute or a directory. + /// + /// # Safety + /// + /// The caller must ensure that the path is absolute. + #[inline] + pub unsafe fn new_unchecked(path: &Path) -> &Self { + debug_assert!(path.is_absolute(), "path must be absolute"); + // SAFETY: AbsPresumedDirPath has the same layout as Path through + // AbsPath which is #[repr(transparent)] + unsafe { &*(path as *const Path as *const AbsPresumedDirPath) } + } + + /// Returns the underlying standard library [`Path`] reference. + #[inline] + pub fn as_std_path(&self) -> &Path { + self.0.as_std_path() + } + + /// Returns a borrowed [`AbsPath`]. + #[inline] + pub fn as_absolute_path(&self) -> &AbsPath { + &self.0 + } + + /// Converts this to a standard library [`PathBuf`]. + #[inline] + pub fn to_std_path_buf(&self) -> PathBuf { + self.0.to_std_path_buf() + } + + /// Converts this borrowed reference to an owned [`AbsPresumedDirPathBuf`]. + #[inline] + pub fn to_path_buf(&self) -> AbsPresumedDirPathBuf { + AbsPresumedDirPathBuf(self.0.to_path_buf()) + } + + /// Returns a normalized version of this directory path, resolving `.` and `..` components. + /// + /// This does not access the filesystem and works purely on the path components. + /// + /// # Errors + /// + /// Returns [`NormalizeError::EscapesRoot`] if the path contains too many `..` components + /// that would escape the root directory. + pub fn normalized(&self) -> Result { + let normalized = self.0.normalized()?; + Ok(AbsPresumedDirPathBuf(normalized)) + } +} + +impl Deref for AbsPresumedDirPath { + type Target = AbsPath; + + #[inline] + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl AsRef for AbsPresumedDirPath { + #[inline] + fn as_ref(&self) -> &Path { + self.0.as_std_path() + } +} + +impl AsRef for AbsPresumedDirPath { + #[inline] + fn as_ref(&self) -> &AbsPath { + &self.0 + } +} + +impl ToOwned for AbsPresumedDirPath { + type Owned = AbsPresumedDirPathBuf; + + fn to_owned(&self) -> Self::Owned { + self.to_path_buf() + } +} + +/// An owned absolute path that is *presumed* to be a directory. +/// +/// This is the owned equivalent of [`AbsPresumedDirPath`]. +/// +/// # Semantics +/// +/// This type represents a path that is *intended* to be a directory. No filesystem +/// check is performed - use [`AbsPathBuf::into_assume_dir()`] to create one from an [`AbsPathBuf`]. +/// +/// # Invariants +/// +/// An `AbsPresumedDirPathBuf` always contains an absolute path. +#[derive(Clone, Hash, Eq, PartialEq, Debug, serde::Serialize, serde::Deserialize)] +#[serde(transparent)] +pub struct AbsPresumedDirPathBuf(AbsPathBuf); + +impl AbsPresumedDirPathBuf { + /// Creates a new `AbsPresumedDirPathBuf` without checking if the path is + /// absolute or a directory. + /// + /// # Safety + /// + /// The caller must ensure that the path is absolute. + #[inline] + pub unsafe fn new_unchecked(path: impl Into) -> Self { + let path = path.into(); + debug_assert!(path.is_absolute(), "path must be absolute"); + // SAFETY: The caller guarantees the path is absolute + Self(unsafe { AbsPathBuf::new_unchecked(path) }) + } + + /// Returns the underlying standard library [`Path`] reference. + #[inline] + pub fn as_std_path(&self) -> &Path { + self.0.as_std_path() + } + + /// Returns a borrowed [`AbsPresumedDirPath`]. + #[inline] + pub fn as_path(&self) -> &AbsPresumedDirPath { + // SAFETY: We maintain the invariant that self.0 is always an absolute directory + unsafe { AbsPresumedDirPath::new_unchecked(self.0.as_std_path()) } + } + + /// Returns a reference to the inner [`AbsPathBuf`]. + #[inline] + pub fn as_absolute_path_buf(&self) -> &AbsPathBuf { + &self.0 + } + + /// Consumes this and returns the inner [`AbsPathBuf`]. + #[inline] + pub fn into_absolute_path_buf(self) -> AbsPathBuf { + self.0 + } + + /// Consumes this and returns the inner [`PathBuf`]. + #[inline] + pub fn into_std_path_buf(self) -> PathBuf { + self.0.into_std_path_buf() + } + + /// Returns a normalized version of this path, removing `.` and `..` components, + /// while retaining the presumption that this is a directory path. + /// + /// # Errors + /// + /// Returns [`NormalizeError::EscapesRoot`] if the path contains too many `..` components + /// that would escape the root directory. + pub fn normalized(&self) -> Result { + self.as_path().normalized() + } +} + +impl Deref for AbsPresumedDirPathBuf { + type Target = AbsPresumedDirPath; + + #[inline] + fn deref(&self) -> &Self::Target { + self.as_path() + } +} + +impl AsRef for AbsPresumedDirPathBuf { + #[inline] + fn as_ref(&self) -> &Path { + self.0.as_std_path() + } +} + +impl AsRef for AbsPresumedDirPathBuf { + #[inline] + fn as_ref(&self) -> &AbsPath { + self.0.as_path() + } +} + +impl AsRef for AbsPresumedDirPathBuf { + #[inline] + fn as_ref(&self) -> &AbsPresumedDirPath { + self.as_path() + } +} + +impl Borrow for AbsPresumedDirPathBuf { + #[inline] + fn borrow(&self) -> &AbsPresumedDirPath { + self.as_path() + } +} + +impl From for PathBuf { + #[inline] + fn from(path: AbsPresumedDirPathBuf) -> Self { + path.0.into() + } +} + +impl From for AbsPathBuf { + #[inline] + fn from(path: AbsPresumedDirPathBuf) -> Self { + path.0 + } +} + +/// A borrowed reference to an absolute path that is *presumed* to be a file. +/// +/// This is the borrowed equivalent of [`AbsPresumedFilePathBuf`]. +/// +/// # Semantics +/// +/// This type represents a path that is *intended* to be a file. No filesystem +/// check is performed - use [`AbsPath::assume_file()`] to create one from an [`AbsPath`]. +/// +/// # Invariants +/// +/// An `AbsPresumedFilePath` is always absolute. +#[derive(Hash, Eq, PartialEq, Debug)] +#[repr(transparent)] +pub struct AbsPresumedFilePath(AbsPath); + +impl AbsPresumedFilePath { + /// Creates a new `AbsPresumedFilePath` without checking if the path is + /// absolute or a file. + /// + /// # Safety + /// + /// The caller must ensure that the path is absolute. + #[inline] + pub unsafe fn new_unchecked(path: &Path) -> &Self { + debug_assert!(path.is_absolute(), "path must be absolute"); + // SAFETY: AbsPresumedFilePath has the same layout as Path through + // AbsPath which is #[repr(transparent)] + unsafe { &*(path as *const Path as *const AbsPresumedFilePath) } + } + + /// Returns the underlying standard library [`Path`] reference. + #[inline] + pub fn as_std_path(&self) -> &Path { + self.0.as_std_path() + } + + /// Returns a borrowed [`AbsPath`]. + #[inline] + pub fn as_absolute_path(&self) -> &AbsPath { + &self.0 + } + + /// Returns the parent directory of this file path. + /// + /// Since this is a file path, it always has a parent directory. + #[inline] + pub fn parent(&self) -> &AbsPresumedDirPath { + // SAFETY: A file path always has a parent directory. + // AbsPresumedDirPath is #[repr(transparent)] over AbsPath. + let parent = self + .0 + .as_std_path() + .parent() + .expect("file path must have a parent"); + unsafe { AbsPresumedDirPath::new_unchecked(parent) } + } + + /// Converts this to a standard library [`PathBuf`]. + #[inline] + pub fn to_std_path_buf(&self) -> PathBuf { + self.0.to_std_path_buf() + } + + /// Converts this borrowed reference to an owned [`AbsPresumedFilePathBuf`]. + #[inline] + pub fn to_path_buf(&self) -> AbsPresumedFilePathBuf { + AbsPresumedFilePathBuf(self.0.to_path_buf()) + } + + /// Returns a normalized version of this path, removing `.` and `..` components, + /// while retaining the presumption that this is a file path. + /// + /// # Errors + /// + /// Returns [`NormalizeError::EscapesRoot`] if the path contains too many `..` components + /// that would escape the root directory. + pub fn normalized(&self) -> Result { + let normalized = self.0.normalized()?; + Ok(AbsPresumedFilePathBuf(normalized)) + } +} + +impl Deref for AbsPresumedFilePath { + type Target = AbsPath; + + #[inline] + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl AsRef for AbsPresumedFilePath { + #[inline] + fn as_ref(&self) -> &Path { + self.0.as_std_path() + } +} + +impl AsRef for AbsPresumedFilePath { + #[inline] + fn as_ref(&self) -> &AbsPath { + &self.0 + } +} + +impl ToOwned for AbsPresumedFilePath { + type Owned = AbsPresumedFilePathBuf; + + fn to_owned(&self) -> Self::Owned { + self.to_path_buf() + } +} + +/// An owned absolute path that is presumed to be a file. +/// +/// This is the owned equivalent of [`AbsPresumedFilePath`]. +/// +/// This type represents a path where the caller has indicated that the path +/// should be treated as a file. No filesystem check is performed - the path +/// may or may not exist, and if it exists, may or may not be an actual file. +/// Use [`AbsPathBuf::into_assume_file`] to create instances of this type. +/// +/// # Invariants +/// +/// An `AbsPresumedFilePathBuf` always contains an absolute path. +#[derive(Clone, Hash, Eq, PartialEq, Debug, serde::Serialize, serde::Deserialize)] +#[serde(transparent)] +pub struct AbsPresumedFilePathBuf(AbsPathBuf); + +impl AbsPresumedFilePathBuf { + /// Creates a new `AbsPresumedFilePathBuf` without checking if the path is + /// absolute or a file. + /// + /// # Safety + /// + /// The caller must ensure that the path is absolute. + #[inline] + pub unsafe fn new_unchecked(path: impl Into) -> Self { + let path = path.into(); + debug_assert!(path.is_absolute(), "path must be absolute"); + // SAFETY: The caller guarantees the path is absolute + Self(unsafe { AbsPathBuf::new_unchecked(path) }) + } + + /// Returns the underlying standard library [`Path`] reference. + #[inline] + pub fn as_std_path(&self) -> &Path { + self.0.as_std_path() + } + + /// Returns a borrowed [`AbsPresumedFilePath`]. + #[inline] + pub fn as_path(&self) -> &AbsPresumedFilePath { + // SAFETY: We maintain the invariant that self.0 is always an absolute file + unsafe { AbsPresumedFilePath::new_unchecked(self.0.as_std_path()) } + } + + /// Returns a reference to the inner [`AbsPathBuf`]. + #[inline] + pub fn as_absolute_path_buf(&self) -> &AbsPathBuf { + &self.0 + } + + /// Consumes this and returns the inner [`AbsPathBuf`]. + #[inline] + pub fn into_absolute_path_buf(self) -> AbsPathBuf { + self.0 + } + + /// Consumes this and returns the inner [`PathBuf`]. + #[inline] + pub fn into_std_path_buf(self) -> PathBuf { + self.0.into_std_path_buf() + } + + /// Returns a normalized version of this path, removing `.` and `..` components, + /// while retaining the presumption that this is a file path. + /// + /// # Errors + /// + /// Returns [`NormalizeError::EscapesRoot`] if the path contains too many `..` components + /// that would escape the root directory. + pub fn normalized(&self) -> Result { + self.as_path().normalized() + } +} + +impl Deref for AbsPresumedFilePathBuf { + type Target = AbsPresumedFilePath; + + #[inline] + fn deref(&self) -> &Self::Target { + self.as_path() + } +} + +impl AsRef for AbsPresumedFilePathBuf { + #[inline] + fn as_ref(&self) -> &Path { + self.0.as_std_path() + } +} + +impl AsRef for AbsPresumedFilePathBuf { + #[inline] + fn as_ref(&self) -> &AbsPath { + self.0.as_path() + } +} + +impl AsRef for AbsPresumedFilePathBuf { + #[inline] + fn as_ref(&self) -> &AbsPresumedFilePath { + self.as_path() + } +} + +impl Borrow for AbsPresumedFilePathBuf { + #[inline] + fn borrow(&self) -> &AbsPresumedFilePath { + self.as_path() + } +} + +impl From for PathBuf { + #[inline] + fn from(path: AbsPresumedFilePathBuf) -> Self { + path.0.into() + } +} + +impl From for AbsPathBuf { + #[inline] + fn from(path: AbsPresumedFilePathBuf) -> Self { + path.0 + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::collections::HashSet; + use tempfile::TempDir; + + fn get_test_dir() -> TempDir { + tempfile::tempdir().unwrap() + } + + #[cfg(unix)] + fn get_nonexistent_absolute_path() -> PathBuf { + PathBuf::from("/nonexistent_path_12345") + } + + #[cfg(windows)] + fn get_nonexistent_absolute_path() -> PathBuf { + PathBuf::from("C:\\nonexistent_path_12345") + } + + #[cfg(unix)] + fn get_absolute_path() -> PathBuf { + PathBuf::from("/usr") + } + + #[cfg(windows)] + fn get_absolute_path() -> PathBuf { + PathBuf::from("C:\\Windows") + } + + fn get_relative_path() -> PathBuf { + PathBuf::from("relative/path") + } + + // ==================== AbsPath Tests ==================== + + #[test] + fn test_abs_path_new_with_absolute() { + let path = get_absolute_path(); + let result = AbsPath::new(&path); + assert!(result.is_ok()); + } + + #[test] + fn test_abs_path_new_with_relative() { + let path = get_relative_path(); + let result = AbsPath::new(&path); + assert!(matches!(result, Err(PathError::NotAbsolute(_)))); + } + + #[test] + fn test_abs_path_as_std_path() { + let path = get_absolute_path(); + let abs = AbsPath::new(&path).unwrap(); + assert_eq!(abs.as_std_path(), &path); + assert!(abs.as_std_path().is_absolute()); + } + + #[test] + fn test_abs_path_to_path_buf() { + let path = get_absolute_path(); + let abs = AbsPath::new(&path).unwrap(); + let owned = abs.to_path_buf(); + assert_eq!(owned.as_std_path(), &path); + } + + #[test] + fn test_abs_path_directory_on_directory() { + let temp = get_test_dir(); + let abs = AbsPath::new(temp.path()).unwrap(); + let dir = abs.directory().unwrap(); + assert_eq!(dir.as_std_path(), temp.path()); + } + + #[test] + fn test_abs_path_directory_on_file() { + let temp = get_test_dir(); + let file_path = temp.path().join("test_file.txt"); + fs_err::write(&file_path, "test").unwrap(); + + let abs = AbsPath::new(&file_path).unwrap(); + let dir = abs.directory().unwrap(); + assert_eq!(dir.as_std_path(), temp.path()); + } + + #[test] + fn test_abs_path_directory_on_nonexistent() { + let path = get_nonexistent_absolute_path(); + let abs = AbsPath::new(&path).unwrap(); + assert!(abs.directory().is_none()); + } + + #[test] + fn test_abs_path_parent() { + let temp = get_test_dir(); + let child_path = temp.path().join("child"); + fs_err::create_dir(&child_path).unwrap(); + + let abs = AbsPath::new(&child_path).unwrap(); + let parent = abs.parent().unwrap(); + assert_eq!(parent.as_std_path(), temp.path()); + } + + #[test] + fn test_abs_path_parent_on_root() { + #[cfg(unix)] + let root = PathBuf::from("/"); + #[cfg(windows)] + let root = PathBuf::from("C:\\"); + + let abs = AbsPath::new(&root).unwrap(); + assert!(abs.parent().is_none()); + } + + #[test] + fn test_abs_path_assume_dir() { + let path = get_absolute_path(); + let abs = AbsPath::new(&path).unwrap(); + let dir = abs.assume_dir(); + assert_eq!(dir.as_std_path(), &path); + } + + #[test] + fn test_abs_path_assume_file() { + let path = get_absolute_path(); + let abs = AbsPath::new(&path).unwrap(); + let file = abs.assume_file(); + assert_eq!(file.as_std_path(), &path); + } + + #[test] + fn test_abs_path_to_owned() { + let path = get_absolute_path(); + let abs = AbsPath::new(&path).unwrap(); + let owned: AbsPathBuf = abs.to_owned(); + assert_eq!(owned.as_std_path(), abs.as_std_path()); + } + + // ==================== AbsPathBuf Tests ==================== + + #[test] + fn test_abs_path_buf_new_with_absolute() { + let path = get_absolute_path(); + let result = AbsPathBuf::new(&path); + assert!(result.is_ok()); + } + + #[test] + fn test_abs_path_buf_new_with_relative() { + let result = AbsPathBuf::new("relative/path"); + assert!(matches!(result, Err(PathError::NotAbsolute(_)))); + } + + #[test] + fn test_abs_path_buf_deref() { + let path = get_absolute_path(); + let abs_buf = AbsPathBuf::new(&path).unwrap(); + let abs_ref: &AbsPath = &abs_buf; + assert_eq!(abs_ref.as_std_path(), &path); + } + + #[test] + fn test_abs_path_buf_clone() { + let path = get_absolute_path(); + let abs_buf = AbsPathBuf::new(&path).unwrap(); + let cloned = abs_buf.clone(); + assert_eq!(abs_buf, cloned); + } + + #[test] + fn test_abs_path_buf_hash() { + let path = get_absolute_path(); + let abs_buf = AbsPathBuf::new(&path).unwrap(); + + let mut set = HashSet::new(); + set.insert(abs_buf.clone()); + assert!(set.contains(&abs_buf)); + } + + #[test] + fn test_abs_path_buf_borrow() { + let path = get_absolute_path(); + let abs_buf = AbsPathBuf::new(&path).unwrap(); + let borrowed: &AbsPath = abs_buf.borrow(); + assert_eq!(borrowed.as_std_path(), abs_buf.as_std_path()); + } + + #[test] + fn test_abs_path_buf_into_assume_dir() { + let path = get_absolute_path(); + let abs_buf = AbsPathBuf::new(&path).unwrap(); + let dir_buf = abs_buf.into_assume_dir(); + assert_eq!(dir_buf.as_std_path(), &path); + } + + #[test] + fn test_abs_path_buf_into_assume_file() { + let path = get_absolute_path(); + let abs_buf = AbsPathBuf::new(&path).unwrap(); + let file_buf = abs_buf.into_assume_file(); + assert_eq!(file_buf.as_std_path(), &path); + } + + #[test] + fn test_abs_path_buf_as_ref_implementations() { + let temp = get_test_dir(); + + let abs_buf = AbsPathBuf::new(temp.path()).unwrap(); + let _: &Path = abs_buf.as_ref(); + let _: &AbsPath = abs_buf.as_ref(); + } + + // ==================== AbsPresumedDirPath Tests ==================== + + #[test] + fn test_presumed_dir_path_from_assume() { + let temp = get_test_dir(); + let abs = AbsPath::new(temp.path()).unwrap(); + let dir = abs.assume_dir(); + assert_eq!(dir.as_std_path(), temp.path()); + } + + #[test] + fn test_presumed_dir_path_as_absolute_path() { + let temp = get_test_dir(); + let abs = AbsPath::new(temp.path()).unwrap(); + let dir = abs.assume_dir(); + let abs_back: &AbsPath = dir.as_absolute_path(); + assert_eq!(abs_back.as_std_path(), temp.path()); + } + + #[test] + fn test_presumed_dir_path_to_path_buf() { + let temp = get_test_dir(); + let abs = AbsPath::new(temp.path()).unwrap(); + let dir = abs.assume_dir(); + let owned = dir.to_path_buf(); + assert_eq!(owned.as_std_path(), temp.path()); + } + + #[test] + fn test_presumed_dir_path_join() { + let temp = get_test_dir(); + let abs = AbsPath::new(temp.path()).unwrap(); + let dir = abs.assume_dir(); + + let joined = dir.join("subdir/file.txt"); + assert_eq!(joined.as_std_path(), temp.path().join("subdir/file.txt")); + assert!(joined.as_std_path().is_absolute()); + } + + #[test] + fn test_presumed_dir_path_to_owned() { + let temp = get_test_dir(); + let abs = AbsPath::new(temp.path()).unwrap(); + let dir = abs.assume_dir(); + let owned: AbsPresumedDirPathBuf = dir.to_owned(); + assert_eq!(owned.as_std_path(), dir.as_std_path()); + } + + // ==================== AbsPresumedDirPathBuf Tests ==================== + + #[test] + fn test_presumed_dir_path_buf_from_into_assume() { + let temp = get_test_dir(); + let abs_buf = AbsPathBuf::new(temp.path()).unwrap(); + let dir_buf = abs_buf.into_assume_dir(); + assert_eq!(dir_buf.as_std_path(), temp.path()); + } + + #[test] + fn test_presumed_dir_path_buf_deref() { + let temp = get_test_dir(); + let abs_buf = AbsPathBuf::new(temp.path()).unwrap(); + let dir_buf = abs_buf.into_assume_dir(); + let dir_ref: &AbsPresumedDirPath = &dir_buf; + assert_eq!(dir_ref.as_std_path(), temp.path()); + } + + #[test] + fn test_presumed_dir_path_buf_clone() { + let temp = get_test_dir(); + let abs_buf = AbsPathBuf::new(temp.path()).unwrap(); + let dir_buf = abs_buf.into_assume_dir(); + let cloned = dir_buf.clone(); + assert_eq!(dir_buf, cloned); + } + + #[test] + fn test_presumed_dir_path_buf_into_absolute_path_buf() { + let temp = get_test_dir(); + let abs_buf = AbsPathBuf::new(temp.path()).unwrap(); + let dir_buf = abs_buf.into_assume_dir(); + let abs_buf_back = dir_buf.into_absolute_path_buf(); + assert_eq!(abs_buf_back.as_std_path(), temp.path()); + } + + #[test] + fn test_presumed_dir_path_buf_borrow() { + let temp = get_test_dir(); + let abs_buf = AbsPathBuf::new(temp.path()).unwrap(); + let dir_buf = abs_buf.into_assume_dir(); + let borrowed: &AbsPresumedDirPath = dir_buf.borrow(); + assert_eq!(borrowed.as_std_path(), dir_buf.as_std_path()); + } + + #[test] + fn test_presumed_dir_path_buf_as_absolute_path_buf() { + let temp = get_test_dir(); + let abs_buf = AbsPathBuf::new(temp.path()).unwrap(); + let dir_buf = abs_buf.into_assume_dir(); + let abs_buf_ref: &AbsPathBuf = dir_buf.as_absolute_path_buf(); + assert_eq!(abs_buf_ref.as_std_path(), temp.path()); + } + + #[test] + fn test_presumed_dir_path_buf_join() { + let temp = get_test_dir(); + let abs_buf = AbsPathBuf::new(temp.path()).unwrap(); + let dir_buf = abs_buf.into_assume_dir(); + + // join is available via Deref to AbsPresumedDirPath + let joined = dir_buf.join("subdir/file.txt"); + assert_eq!(joined.as_std_path(), temp.path().join("subdir/file.txt")); + } + + #[test] + fn test_presumed_dir_path_buf_as_ref_implementations() { + let temp = get_test_dir(); + let abs_buf = AbsPathBuf::new(temp.path()).unwrap(); + let dir_buf = abs_buf.into_assume_dir(); + + let _: &Path = dir_buf.as_ref(); + let _: &AbsPath = dir_buf.as_ref(); + let _: &AbsPresumedDirPath = dir_buf.as_ref(); + } + + // ==================== AbsPresumedFilePath Tests ==================== + + #[test] + fn test_presumed_file_path_from_assume() { + let temp = get_test_dir(); + let file_path = temp.path().join("test_file.txt"); + + let abs = AbsPath::new(&file_path).unwrap(); + let file = abs.assume_file(); + assert_eq!(file.as_std_path(), &file_path); + } + + #[test] + fn test_presumed_file_path_as_absolute_path() { + let temp = get_test_dir(); + let file_path = temp.path().join("test_file.txt"); + + let abs = AbsPath::new(&file_path).unwrap(); + let file = abs.assume_file(); + let abs_back: &AbsPath = file.as_absolute_path(); + assert_eq!(abs_back.as_std_path(), &file_path); + } + + #[test] + fn test_presumed_file_path_to_path_buf() { + let temp = get_test_dir(); + let file_path = temp.path().join("test_file.txt"); + + let abs = AbsPath::new(&file_path).unwrap(); + let file = abs.assume_file(); + let owned = file.to_path_buf(); + assert_eq!(owned.as_std_path(), &file_path); + } + + #[test] + fn test_presumed_file_path_to_owned() { + let temp = get_test_dir(); + let file_path = temp.path().join("test_file.txt"); + + let abs = AbsPath::new(&file_path).unwrap(); + let file = abs.assume_file(); + let owned: AbsPresumedFilePathBuf = file.to_owned(); + assert_eq!(owned.as_std_path(), file.as_std_path()); + } + + // ==================== AbsPresumedFilePathBuf Tests ==================== + + #[test] + fn test_presumed_file_path_buf_from_into_assume() { + let temp = get_test_dir(); + let file_path = temp.path().join("test_file.txt"); + + let abs_buf = AbsPathBuf::new(&file_path).unwrap(); + let file_buf = abs_buf.into_assume_file(); + assert_eq!(file_buf.as_std_path(), &file_path); + } + + #[test] + fn test_presumed_file_path_buf_deref() { + let temp = get_test_dir(); + let file_path = temp.path().join("test_file.txt"); + + let abs_buf = AbsPathBuf::new(&file_path).unwrap(); + let file_buf = abs_buf.into_assume_file(); + let file_ref: &AbsPresumedFilePath = &file_buf; + assert_eq!(file_ref.as_std_path(), &file_path); + } + + #[test] + fn test_presumed_file_path_buf_clone() { + let temp = get_test_dir(); + let file_path = temp.path().join("test_file.txt"); + + let abs_buf = AbsPathBuf::new(&file_path).unwrap(); + let file_buf = abs_buf.into_assume_file(); + let cloned = file_buf.clone(); + assert_eq!(file_buf, cloned); + } + + #[test] + fn test_presumed_file_path_buf_into_absolute_path_buf() { + let temp = get_test_dir(); + let file_path = temp.path().join("test_file.txt"); + + let abs_buf = AbsPathBuf::new(&file_path).unwrap(); + let file_buf = abs_buf.into_assume_file(); + let abs_buf_back = file_buf.into_absolute_path_buf(); + assert_eq!(abs_buf_back.as_std_path(), &file_path); + } + + #[test] + fn test_presumed_file_path_buf_borrow() { + let temp = get_test_dir(); + let file_path = temp.path().join("test_file.txt"); + + let abs_buf = AbsPathBuf::new(&file_path).unwrap(); + let file_buf = abs_buf.into_assume_file(); + let borrowed: &AbsPresumedFilePath = file_buf.borrow(); + assert_eq!(borrowed.as_std_path(), file_buf.as_std_path()); + } + + #[test] + fn test_presumed_file_path_buf_as_absolute_path_buf() { + let temp = get_test_dir(); + let file_path = temp.path().join("test_file.txt"); + + let abs_buf = AbsPathBuf::new(&file_path).unwrap(); + let file_buf = abs_buf.into_assume_file(); + let abs_buf_ref: &AbsPathBuf = file_buf.as_absolute_path_buf(); + assert_eq!(abs_buf_ref.as_std_path(), &file_path); + } + + #[test] + fn test_presumed_file_path_buf_as_ref_implementations() { + let temp = get_test_dir(); + let file_path = temp.path().join("test_file.txt"); + + let abs_buf = AbsPathBuf::new(&file_path).unwrap(); + let file_buf = abs_buf.into_assume_file(); + + let _: &Path = file_buf.as_ref(); + let _: &AbsPath = file_buf.as_ref(); + let _: &AbsPresumedFilePath = file_buf.as_ref(); + } + + // ==================== Edge Cases ==================== + + #[test] + fn test_assume_works_on_nonexistent_paths() { + // The assume_* methods should work on non-existent paths + // because they represent intent, not filesystem state + let path = get_nonexistent_absolute_path(); + let abs = AbsPath::new(&path).unwrap(); + + // Both assume_dir and assume_file should work + let _dir = abs.assume_dir(); + let _file = abs.assume_file(); + } + + #[test] + fn test_into_assume_works_on_nonexistent_paths() { + let path = get_nonexistent_absolute_path(); + + // into_assume_dir + let abs_buf = AbsPathBuf::new(&path).unwrap(); + let _dir_buf = abs_buf.into_assume_dir(); + + // into_assume_file + let abs_buf = AbsPathBuf::new(&path).unwrap(); + let _file_buf = abs_buf.into_assume_file(); + } +} diff --git a/crates/pixi_record/src/dev_source_record.rs b/crates/pixi_record/src/dev_source_record.rs index 5f8fc4ebbe..61a63cedf3 100644 --- a/crates/pixi_record/src/dev_source_record.rs +++ b/crates/pixi_record/src/dev_source_record.rs @@ -12,7 +12,7 @@ use rattler_conda_types::PackageName; use itertools::{Either, Itertools}; -use crate::{InputHash, PinnedSourceSpec}; +use crate::PinnedSourceSpec; /// A resolved development source record representing a specific output from a source package. /// @@ -27,9 +27,6 @@ pub struct DevSourceRecord { /// The pinned source this record came from pub source: PinnedSourceSpec, - /// Hash of input files used to generate this metadata - pub input_hash: Option, - /// Variants used when computing dependencies. This is used to uniquely identify this record. pub variants: BTreeMap, diff --git a/crates/pixi_record/src/lib.rs b/crates/pixi_record/src/lib.rs index 00c7b2ff9a..21dfb43aa0 100644 --- a/crates/pixi_record/src/lib.rs +++ b/crates/pixi_record/src/lib.rs @@ -17,7 +17,7 @@ use rattler_conda_types::{ }; use rattler_lock::{CondaPackageData, ConversionError, UrlOrPath}; use serde::Serialize; -pub use source_record::{InputHash, SourceRecord}; +pub use source_record::SourceRecord; use thiserror::Error; /// A record of a conda package that is either something installable from a diff --git a/crates/pixi_record/src/snapshots/pixi_record__source_record__tests__roundtrip_conda_source_data.snap b/crates/pixi_record/src/snapshots/pixi_record__source_record__tests__roundtrip_conda_source_data.snap index b79dba6615..7114a995b8 100644 --- a/crates/pixi_record/src/snapshots/pixi_record__source_record__tests__roundtrip_conda_source_data.snap +++ b/crates/pixi_record/src/snapshots/pixi_record__source_record__tests__roundtrip_conda_source_data.snap @@ -30,10 +30,6 @@ packages: sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 md5: d41d8cd98f00b204e9800998ecf8427e channel: null - input: - hash: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - globs: - - '**/*.c' package_build_source: path: ../src - conda: git+https://github.com/example/repo.git?tag=v1.0.0#abc123def456abc123def456abc123def456abc1 @@ -45,10 +41,6 @@ packages: sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 md5: d41d8cd98f00b204e9800998ecf8427e channel: null - input: - hash: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - globs: - - src/**/*.rs package_build_source: path: build/subdir - conda: git+https://github.com/example/mono-repo.git?subdirectory=recipes&branch=main#abc123def456abc123def456abc123def456abc1 @@ -60,11 +52,6 @@ packages: sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 md5: d41d8cd98f00b204e9800998ecf8427e channel: null - input: - hash: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - globs: - - '**/*.py' - - '**/*.txt' package_build_source: path: ../non-nested - conda: /workspace/absolute-recipe @@ -75,10 +62,6 @@ packages: noarch: false sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 md5: d41d8cd98f00b204e9800998ecf8427e - input: - hash: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - globs: - - '**/*.sh' package_build_source: path: ../src - conda: recipes/my-package @@ -89,10 +72,6 @@ packages: noarch: false sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 md5: d41d8cd98f00b204e9800998ecf8427e - input: - hash: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - globs: - - '**/*.cpp' package_build_source: path: ../../src/lib - conda: recipes/no-build @@ -103,10 +82,6 @@ packages: noarch: false sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 md5: d41d8cd98f00b204e9800998ecf8427e - input: - hash: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - globs: - - '**/*.md' - conda: recipes/my-package name: path-sibling-test version: 2.0.0 @@ -115,9 +90,5 @@ packages: noarch: false sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 md5: d41d8cd98f00b204e9800998ecf8427e - input: - hash: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - globs: - - '**/*.rs' package_build_source: path: ../../other-package/src diff --git a/crates/pixi_record/src/source_record.rs b/crates/pixi_record/src/source_record.rs index 3c630a59ed..44399c2a75 100644 --- a/crates/pixi_record/src/source_record.rs +++ b/crates/pixi_record/src/source_record.rs @@ -1,5 +1,5 @@ use std::{ - collections::{BTreeMap, BTreeSet, HashMap}, + collections::{BTreeMap, HashMap}, path::Path, str::FromStr, }; @@ -7,9 +7,7 @@ use std::{ use pixi_git::{sha::GitSha, url::RepositoryUrl}; use pixi_spec::{GitReference, SourceSpec}; use rattler_conda_types::{MatchSpec, Matches, NamelessMatchSpec, PackageRecord}; -use rattler_digest::{Sha256, Sha256Hash}; use rattler_lock::{CondaSourceData, GitShallowSpec, PackageBuildSource}; -use serde::{Deserialize, Serialize}; use typed_path::{Utf8TypedPathBuf, Utf8UnixPathBuf}; use url::Url; @@ -33,34 +31,11 @@ pub struct SourceRecord { /// The variants that uniquely identify the way this package was built. pub variants: Option>, - /// The hash of the input that was used to build the metadata of the - /// package. This can be used to verify that the metadata is still valid. - /// - /// If this is `None`, the input hash was not computed or is not relevant - /// for this record. The record can always be considered up to date. - pub input_hash: Option, - /// Specifies which packages are expected to be installed as source packages /// and from which location. pub sources: HashMap, } -/// Defines the hash of the input files that were used to build the metadata of -/// the record. If reevaluating and hashing the globs results in a different -/// hash, the metadata is considered invalid. -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct InputHash { - /// The hash of the input files that matched the globs. - #[serde( - serialize_with = "rattler_digest::serde::serialize::<_, Sha256>", - deserialize_with = "rattler_digest::serde::deserialize::<_, Sha256>" - )] - pub hash: Sha256Hash, - - /// The globs that were used to compute the hash. - pub globs: BTreeSet, -} - impl SourceRecord { /// Convert [`SourceRecord`] into lock-file compatible `CondaSourceData` /// The `build_source` in the SourceRecord is always relative to the workspace. @@ -107,10 +82,8 @@ impl SourceRecord { package_record: self.package_record, location: self.manifest_source.clone().into(), package_build_source, - input: self.input_hash.map(|i| rattler_lock::InputHash { - hash: i.hash, - globs: Vec::from_iter(i.globs), - }), + // Don't write input_hash to lock file + input: None, sources: self .sources .into_iter() @@ -200,10 +173,6 @@ impl SourceRecord { Ok(Self { package_record: data.package_record, manifest_source, - input_hash: data.input.map(|hash| InputHash { - hash: hash.hash, - globs: BTreeSet::from_iter(hash.globs), - }), build_source, sources: data .sources @@ -218,6 +187,27 @@ impl SourceRecord { }), }) } + + /// Returns true if this source record refers to the same output as the other source record. + /// This is determined by comparing the package name, and either the variants (if both records have them) + /// or the build, version and subdir (if variants are not present). + pub fn refers_to_same_output(&self, other: &SourceRecord) -> bool { + if self.package_record.name != other.package_record.name { + return false; + } + + match (&self.variants, &other.variants) { + (Some(variants), Some(other_variants)) => { + // If both records have variants, we use that to identify them. + variants == other_variants + } + _ => { + self.package_record.build == other.package_record.build + && self.package_record.version == other.package_record.version + && self.package_record.subdir == other.package_record.subdir + } + } + } } impl Matches for NamelessMatchSpec { @@ -323,7 +313,6 @@ mod tests { package_record, manifest_source: manifest_source.clone(), build_source: Some(build_source), - input_hash: None, sources: Default::default(), variants: None, }; @@ -403,7 +392,6 @@ mod tests { package_record, manifest_source: manifest_source.clone(), build_source: Some(build_source), - input_hash: None, sources: Default::default(), variants: None, }; @@ -489,7 +477,6 @@ mod tests { package_record, manifest_source: manifest_source.clone(), build_source: Some(build_source), - input_hash: None, sources: Default::default(), variants: None, }; diff --git a/examples/pixi-build/array-api-extra/pixi.lock b/examples/pixi-build/array-api-extra/pixi.lock index 88c97d8d85..6c0ab3b9a0 100644 --- a/examples/pixi-build/array-api-extra/pixi.lock +++ b/examples/pixi-build/array-api-extra/pixi.lock @@ -3,93 +3,98 @@ environments: default: channels: - url: https://prefix.dev/conda-forge/ + options: + pypi-prerelease-mode: if-necessary-or-explicit packages: linux-64: - conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 - conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 - conda: https://prefix.dev/conda-forge/noarch/array-api-compat-1.12.0-pyhe01879c_0.conda + - conda: https://prefix.dev/conda-forge/noarch/boltons-25.0.0-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/linux-64/bzip2-1.0.8-hda65f42_8.conda - - conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2025.10.5-hbd8a1cb_0.conda - - conda: https://prefix.dev/conda-forge/linux-64/ld_impl_linux-64-2.44-ha97dd6f_2.conda - - conda: https://prefix.dev/conda-forge/linux-64/libexpat-2.7.1-hecca717_0.conda - - conda: https://prefix.dev/conda-forge/linux-64/libffi-3.4.6-h2dba641_1.conda - - conda: https://prefix.dev/conda-forge/linux-64/libgcc-15.2.0-h767d61c_7.conda - - conda: https://prefix.dev/conda-forge/linux-64/libgomp-15.2.0-h767d61c_7.conda + - conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2025.11.12-hbd8a1cb_0.conda + - conda: https://prefix.dev/conda-forge/linux-64/ld_impl_linux-64-2.45-default_hbd61a6d_104.conda + - conda: https://prefix.dev/conda-forge/linux-64/libexpat-2.7.3-hecca717_0.conda + - conda: https://prefix.dev/conda-forge/linux-64/libffi-3.5.2-h9ec8514_0.conda + - conda: https://prefix.dev/conda-forge/linux-64/libgcc-15.2.0-he0feb66_16.conda + - conda: https://prefix.dev/conda-forge/linux-64/libgomp-15.2.0-he0feb66_16.conda - conda: https://prefix.dev/conda-forge/linux-64/liblzma-5.8.1-hb9d3cd8_2.conda - conda: https://prefix.dev/conda-forge/linux-64/libmpdec-4.0.0-hb9d3cd8_0.conda - - conda: https://prefix.dev/conda-forge/linux-64/libsqlite-3.50.4-h0c1763c_0.conda - - conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-15.2.0-h8f9b012_7.conda - - conda: https://prefix.dev/conda-forge/linux-64/libuuid-2.41.2-he9a06e4_0.conda + - conda: https://prefix.dev/conda-forge/linux-64/libsqlite-3.51.1-h0c1763c_0.conda + - conda: https://prefix.dev/conda-forge/linux-64/libuuid-2.41.2-h5347b49_1.conda - conda: https://prefix.dev/conda-forge/linux-64/libzlib-1.3.1-hb9d3cd8_2.conda - conda: https://prefix.dev/conda-forge/linux-64/ncurses-6.5-h2d0b736_3.conda - - conda: https://prefix.dev/conda-forge/linux-64/openssl-3.5.4-h26f9b46_0.conda - - conda: https://prefix.dev/conda-forge/linux-64/python-3.14.0-h5989046_101_cp314.conda + - conda: https://prefix.dev/conda-forge/linux-64/openssl-3.6.0-h26f9b46_0.conda + - conda: https://prefix.dev/conda-forge/linux-64/python-3.14.2-h32b2ec7_100_cp314.conda - conda: https://prefix.dev/conda-forge/noarch/python_abi-3.14-8_cp314.conda - conda: https://prefix.dev/conda-forge/linux-64/readline-8.2-h8c095d6_2.conda - - conda: https://prefix.dev/conda-forge/linux-64/tk-8.6.13-noxft_hd72426e_102.conda + - conda: https://prefix.dev/conda-forge/linux-64/tk-8.6.13-noxft_ha0e22de_103.conda - conda: https://prefix.dev/conda-forge/noarch/tzdata-2025b-h78e105d_0.conda - - conda: https://prefix.dev/conda-forge/linux-64/zstd-1.5.7-hb8e6e7a_2.conda - - conda: . + - conda: https://prefix.dev/conda-forge/linux-64/zstd-1.5.7-hb78ec9c_6.conda + - conda: recipe.yaml osx-64: - conda: https://prefix.dev/conda-forge/noarch/array-api-compat-1.12.0-pyhe01879c_0.conda + - conda: https://prefix.dev/conda-forge/noarch/boltons-25.0.0-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/osx-64/bzip2-1.0.8-h500dc9f_8.conda - - conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2025.10.5-hbd8a1cb_0.conda - - conda: https://prefix.dev/conda-forge/osx-64/libexpat-2.7.1-h21dd04a_0.conda - - conda: https://prefix.dev/conda-forge/osx-64/libffi-3.4.6-h281671d_1.conda + - conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2025.11.12-hbd8a1cb_0.conda + - conda: https://prefix.dev/conda-forge/osx-64/icu-75.1-h120a0e1_0.conda + - conda: https://prefix.dev/conda-forge/osx-64/libexpat-2.7.3-heffb93a_0.conda + - conda: https://prefix.dev/conda-forge/osx-64/libffi-3.5.2-h750e83c_0.conda - conda: https://prefix.dev/conda-forge/osx-64/liblzma-5.8.1-hd471939_2.conda - conda: https://prefix.dev/conda-forge/osx-64/libmpdec-4.0.0-h6e16a3a_0.conda - - conda: https://prefix.dev/conda-forge/osx-64/libsqlite-3.50.4-h39a8b3b_0.conda + - conda: https://prefix.dev/conda-forge/osx-64/libsqlite-3.51.1-h6cc646a_0.conda - conda: https://prefix.dev/conda-forge/osx-64/libzlib-1.3.1-hd23fc13_2.conda - conda: https://prefix.dev/conda-forge/osx-64/ncurses-6.5-h0622a9a_3.conda - - conda: https://prefix.dev/conda-forge/osx-64/openssl-3.5.4-h230baf5_0.conda - - conda: https://prefix.dev/conda-forge/osx-64/python-3.14.0-h759804c_101_cp314.conda + - conda: https://prefix.dev/conda-forge/osx-64/openssl-3.6.0-h230baf5_0.conda + - conda: https://prefix.dev/conda-forge/osx-64/python-3.14.2-hf88997e_100_cp314.conda - conda: https://prefix.dev/conda-forge/noarch/python_abi-3.14-8_cp314.conda - conda: https://prefix.dev/conda-forge/osx-64/readline-8.2-h7cca4af_2.conda - - conda: https://prefix.dev/conda-forge/osx-64/tk-8.6.13-hf689a15_2.conda + - conda: https://prefix.dev/conda-forge/osx-64/tk-8.6.13-hf689a15_3.conda - conda: https://prefix.dev/conda-forge/noarch/tzdata-2025b-h78e105d_0.conda - - conda: https://prefix.dev/conda-forge/osx-64/zstd-1.5.7-h8210216_2.conda - - conda: . + - conda: https://prefix.dev/conda-forge/osx-64/zstd-1.5.7-h3eecb57_6.conda + - conda: recipe.yaml osx-arm64: - conda: https://prefix.dev/conda-forge/noarch/array-api-compat-1.12.0-pyhe01879c_0.conda + - conda: https://prefix.dev/conda-forge/noarch/boltons-25.0.0-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/bzip2-1.0.8-hd037594_8.conda - - conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2025.10.5-hbd8a1cb_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/icu-75.1-hfee45f7_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/libexpat-2.7.1-hec049ff_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/libffi-3.4.6-h1da3d7d_1.conda + - conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2025.11.12-hbd8a1cb_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/libexpat-2.7.3-haf25636_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/libffi-3.5.2-he5f378a_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/liblzma-5.8.1-h39f12f2_2.conda - conda: https://prefix.dev/conda-forge/osx-arm64/libmpdec-4.0.0-h5505292_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/libsqlite-3.50.4-h4237e3c_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/libsqlite-3.51.1-h9a5124b_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/libzlib-1.3.1-h8359307_2.conda - conda: https://prefix.dev/conda-forge/osx-arm64/ncurses-6.5-h5e97a16_3.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/openssl-3.5.4-h5503f6c_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/python-3.14.0-h8929636_101_cp314.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/openssl-3.6.0-h5503f6c_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/python-3.14.2-h40d2674_100_cp314.conda - conda: https://prefix.dev/conda-forge/noarch/python_abi-3.14-8_cp314.conda - conda: https://prefix.dev/conda-forge/osx-arm64/readline-8.2-h1d1bf99_2.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/tk-8.6.13-h892fb3f_2.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/tk-8.6.13-h892fb3f_3.conda - conda: https://prefix.dev/conda-forge/noarch/tzdata-2025b-h78e105d_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/zstd-1.5.7-h6491c7d_2.conda - - conda: . + - conda: https://prefix.dev/conda-forge/osx-arm64/zstd-1.5.7-hbf9d68e_6.conda + - conda: recipe.yaml win-64: - conda: https://prefix.dev/conda-forge/noarch/array-api-compat-1.12.0-pyhe01879c_0.conda + - conda: https://prefix.dev/conda-forge/noarch/boltons-25.0.0-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/win-64/bzip2-1.0.8-h0ad9c76_8.conda - - conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2025.10.5-h4c7d964_0.conda - - conda: https://prefix.dev/conda-forge/win-64/libexpat-2.7.1-hac47afa_0.conda - - conda: https://prefix.dev/conda-forge/win-64/libffi-3.4.6-h537db12_1.conda + - conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2025.11.12-h4c7d964_0.conda + - conda: https://prefix.dev/conda-forge/win-64/libexpat-2.7.3-hac47afa_0.conda + - conda: https://prefix.dev/conda-forge/win-64/libffi-3.5.2-h52bdfb6_0.conda - conda: https://prefix.dev/conda-forge/win-64/liblzma-5.8.1-h2466b09_2.conda - conda: https://prefix.dev/conda-forge/win-64/libmpdec-4.0.0-h2466b09_0.conda - - conda: https://prefix.dev/conda-forge/win-64/libsqlite-3.50.4-hf5d6505_0.conda + - conda: https://prefix.dev/conda-forge/win-64/libsqlite-3.51.1-hf5d6505_0.conda - conda: https://prefix.dev/conda-forge/win-64/libzlib-1.3.1-h2466b09_2.conda - - conda: https://prefix.dev/conda-forge/win-64/openssl-3.5.4-h725018a_0.conda - - conda: https://prefix.dev/conda-forge/win-64/python-3.14.0-h6fd79ff_101_cp314.conda + - conda: https://prefix.dev/conda-forge/win-64/openssl-3.6.0-h725018a_0.conda + - conda: https://prefix.dev/conda-forge/win-64/python-3.14.2-h4b44e0e_100_cp314.conda - conda: https://prefix.dev/conda-forge/noarch/python_abi-3.14-8_cp314.conda - - conda: https://prefix.dev/conda-forge/win-64/tk-8.6.13-h2c6b04d_2.conda + - conda: https://prefix.dev/conda-forge/win-64/tk-8.6.13-h2c6b04d_3.conda - conda: https://prefix.dev/conda-forge/noarch/tzdata-2025b-h78e105d_0.conda - conda: https://prefix.dev/conda-forge/win-64/ucrt-10.0.26100.0-h57928b3_0.conda - - conda: https://prefix.dev/conda-forge/win-64/vc-14.3-h2b53caa_32.conda - - conda: https://prefix.dev/conda-forge/win-64/vc14_runtime-14.44.35208-h818238b_32.conda - - conda: https://prefix.dev/conda-forge/win-64/vcomp14-14.44.35208-h818238b_32.conda - - conda: https://prefix.dev/conda-forge/win-64/zstd-1.5.7-hbeecb71_2.conda - - conda: . + - conda: https://prefix.dev/conda-forge/win-64/vc-14.3-h2b53caa_33.conda + - conda: https://prefix.dev/conda-forge/win-64/vc14_runtime-14.44.35208-h818238b_33.conda + - conda: https://prefix.dev/conda-forge/win-64/vcomp14-14.44.35208-h818238b_33.conda + - conda: https://prefix.dev/conda-forge/win-64/zstd-1.5.7-h534d264_6.conda + - conda: recipe.yaml packages: - conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 sha256: fe51de6107f9edc7aa4f786a70f4a883943bc9d39b3bb7307c04c41410990726 @@ -120,21 +125,28 @@ packages: license_family: MIT size: 45821 timestamp: 1747403732947 -- conda: . +- conda: recipe.yaml name: array-api-extra version: 0.8.0 build: pyh4616a5c_0 subdir: noarch + variants: + target_platform: noarch depends: - python >=3.10 - python * - array-api-compat + - boltons license: MIT - input: - hash: 1101422a995a18b9c73ca5617a726f185782e5329c2739d754b921baaf16b7ca - globs: - - recipe.yaml - - variants.yaml +- conda: https://prefix.dev/conda-forge/noarch/boltons-25.0.0-pyhd8ed1ab_0.conda + sha256: ea5f4c876eff2ed469551b57f1cc889a3c01128bf3e2e10b1fea11c3ef39eac2 + md5: c7eb87af73750d6fd97eff8bbee8cb9c + depends: + - python >=3.9 + license: BSD-3-Clause + license_family: BSD + size: 302296 + timestamp: 1749686302834 - conda: https://prefix.dev/conda-forge/linux-64/bzip2-1.0.8-hda65f42_8.conda sha256: c30daba32ddebbb7ded490f0e371eae90f51e72db620554089103b4a6934b0d5 md5: 51a19bba1b8ebfb60df25cde030b7ebc @@ -174,150 +186,151 @@ packages: license_family: BSD size: 55977 timestamp: 1757437738856 -- conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2025.10.5-h4c7d964_0.conda - sha256: bfb7f9f242f441fdcd80f1199edd2ecf09acea0f2bcef6f07d7cbb1a8131a345 - md5: e54200a1cd1fe33d61c9df8d3b00b743 +- conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2025.11.12-h4c7d964_0.conda + sha256: 686a13bd2d4024fc99a22c1e0e68a7356af3ed3304a8d3ff6bb56249ad4e82f0 + md5: f98fb7db808b94bc1ec5b0e62f9f1069 depends: - __win license: ISC - size: 156354 - timestamp: 1759649104842 -- conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2025.10.5-hbd8a1cb_0.conda - sha256: 3b5ad78b8bb61b6cdc0978a6a99f8dfb2cc789a451378d054698441005ecbdb6 - md5: f9e5fbc24009179e8b0409624691758a + size: 152827 + timestamp: 1762967310929 +- conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2025.11.12-hbd8a1cb_0.conda + sha256: b986ba796d42c9d3265602bc038f6f5264095702dd546c14bc684e60c385e773 + md5: f0991f0f84902f6b6009b4d2350a83aa depends: - __unix license: ISC - size: 155907 - timestamp: 1759649036195 -- conda: https://prefix.dev/conda-forge/osx-arm64/icu-75.1-hfee45f7_0.conda - sha256: 9ba12c93406f3df5ab0a43db8a4b4ef67a5871dfd401010fbe29b218b2cbe620 - md5: 5eb22c1d7b3fc4abb50d92d621583137 + size: 152432 + timestamp: 1762967197890 +- conda: https://prefix.dev/conda-forge/osx-64/icu-75.1-h120a0e1_0.conda + sha256: 2e64307532f482a0929412976c8450c719d558ba20c0962832132fd0d07ba7a7 + md5: d68d48a3060eb5abdc1cdc8e2a3a5966 depends: - - __osx >=11.0 + - __osx >=10.13 license: MIT license_family: MIT - size: 11857802 - timestamp: 1720853997952 -- conda: https://prefix.dev/conda-forge/linux-64/ld_impl_linux-64-2.44-ha97dd6f_2.conda - sha256: 707dfb8d55d7a5c6f95c772d778ef07a7ca85417d9971796f7d3daad0b615de8 - md5: 14bae321b8127b63cba276bd53fac237 + size: 11761697 + timestamp: 1720853679409 +- conda: https://prefix.dev/conda-forge/linux-64/ld_impl_linux-64-2.45-default_hbd61a6d_104.conda + sha256: 9e191baf2426a19507f1d0a17be0fdb7aa155cdf0f61d5a09c808e0a69464312 + md5: a6abd2796fc332536735f68ba23f7901 depends: - __glibc >=2.17,<3.0.a0 + - zstd >=1.5.7,<1.6.0a0 constrains: - - binutils_impl_linux-64 2.44 + - binutils_impl_linux-64 2.45 license: GPL-3.0-only license_family: GPL - size: 747158 - timestamp: 1758810907507 -- conda: https://prefix.dev/conda-forge/linux-64/libexpat-2.7.1-hecca717_0.conda - sha256: da2080da8f0288b95dd86765c801c6e166c4619b910b11f9a8446fb852438dc2 - md5: 4211416ecba1866fab0c6470986c22d6 + size: 725545 + timestamp: 1764007826689 +- conda: https://prefix.dev/conda-forge/linux-64/libexpat-2.7.3-hecca717_0.conda + sha256: 1e1b08f6211629cbc2efe7a5bca5953f8f6b3cae0eeb04ca4dacee1bd4e2db2f + md5: 8b09ae86839581147ef2e5c5e229d164 depends: - __glibc >=2.17,<3.0.a0 - libgcc >=14 constrains: - - expat 2.7.1.* + - expat 2.7.3.* license: MIT license_family: MIT - size: 74811 - timestamp: 1752719572741 -- conda: https://prefix.dev/conda-forge/osx-64/libexpat-2.7.1-h21dd04a_0.conda - sha256: 689862313571b62ee77ee01729dc093f2bf25a2f99415fcfe51d3a6cd31cce7b - md5: 9fdeae0b7edda62e989557d645769515 + size: 76643 + timestamp: 1763549731408 +- conda: https://prefix.dev/conda-forge/osx-64/libexpat-2.7.3-heffb93a_0.conda + sha256: d11b3a6ce5b2e832f430fd112084533a01220597221bee16d6c7dc3947dffba6 + md5: 222e0732a1d0780a622926265bee14ef depends: - __osx >=10.13 constrains: - - expat 2.7.1.* + - expat 2.7.3.* license: MIT license_family: MIT - size: 72450 - timestamp: 1752719744781 -- conda: https://prefix.dev/conda-forge/osx-arm64/libexpat-2.7.1-hec049ff_0.conda - sha256: 8fbb17a56f51e7113ed511c5787e0dec0d4b10ef9df921c4fd1cccca0458f648 - md5: b1ca5f21335782f71a8bd69bdc093f67 + size: 74058 + timestamp: 1763549886493 +- conda: https://prefix.dev/conda-forge/osx-arm64/libexpat-2.7.3-haf25636_0.conda + sha256: fce22610ecc95e6d149e42a42fbc3cc9d9179bd4eb6232639a60f06e080eec98 + md5: b79875dbb5b1db9a4a22a4520f918e1a depends: - __osx >=11.0 constrains: - - expat 2.7.1.* + - expat 2.7.3.* license: MIT license_family: MIT - size: 65971 - timestamp: 1752719657566 -- conda: https://prefix.dev/conda-forge/win-64/libexpat-2.7.1-hac47afa_0.conda - sha256: 8432ca842bdf8073ccecf016ccc9140c41c7114dc4ec77ca754551c01f780845 - md5: 3608ffde260281fa641e70d6e34b1b96 + size: 67800 + timestamp: 1763549994166 +- conda: https://prefix.dev/conda-forge/win-64/libexpat-2.7.3-hac47afa_0.conda + sha256: 844ab708594bdfbd7b35e1a67c379861bcd180d6efe57b654f482ae2f7f5c21e + md5: 8c9e4f1a0e688eef2e95711178061a0f depends: - ucrt >=10.0.20348.0 - vc >=14.3,<15 - vc14_runtime >=14.44.35208 constrains: - - expat 2.7.1.* + - expat 2.7.3.* license: MIT license_family: MIT - size: 141322 - timestamp: 1752719767870 -- conda: https://prefix.dev/conda-forge/linux-64/libffi-3.4.6-h2dba641_1.conda - sha256: 764432d32db45466e87f10621db5b74363a9f847d2b8b1f9743746cd160f06ab - md5: ede4673863426c0883c0063d853bbd85 + size: 70137 + timestamp: 1763550049107 +- conda: https://prefix.dev/conda-forge/linux-64/libffi-3.5.2-h9ec8514_0.conda + sha256: 25cbdfa65580cfab1b8d15ee90b4c9f1e0d72128f1661449c9a999d341377d54 + md5: 35f29eec58405aaf55e01cb470d8c26a depends: - __glibc >=2.17,<3.0.a0 - - libgcc >=13 + - libgcc >=14 license: MIT license_family: MIT - size: 57433 - timestamp: 1743434498161 -- conda: https://prefix.dev/conda-forge/osx-64/libffi-3.4.6-h281671d_1.conda - sha256: 6394b1bc67c64a21a5cc73d1736d1d4193a64515152e861785c44d2cfc49edf3 - md5: 4ca9ea59839a9ca8df84170fab4ceb41 + size: 57821 + timestamp: 1760295480630 +- conda: https://prefix.dev/conda-forge/osx-64/libffi-3.5.2-h750e83c_0.conda + sha256: 277dc89950f5d97f1683f26e362d6dca3c2efa16cb2f6fdb73d109effa1cd3d0 + md5: d214916b24c625bcc459b245d509f22e depends: - __osx >=10.13 license: MIT license_family: MIT - size: 51216 - timestamp: 1743434595269 -- conda: https://prefix.dev/conda-forge/osx-arm64/libffi-3.4.6-h1da3d7d_1.conda - sha256: c6a530924a9b14e193ea9adfe92843de2a806d1b7dbfd341546ece9653129e60 - md5: c215a60c2935b517dcda8cad4705734d + size: 52573 + timestamp: 1760295626449 +- conda: https://prefix.dev/conda-forge/osx-arm64/libffi-3.5.2-he5f378a_0.conda + sha256: 9b8acdf42df61b7bfe8bdc545c016c29e61985e79748c64ad66df47dbc2e295f + md5: 411ff7cd5d1472bba0f55c0faf04453b depends: - __osx >=11.0 license: MIT license_family: MIT - size: 39839 - timestamp: 1743434670405 -- conda: https://prefix.dev/conda-forge/win-64/libffi-3.4.6-h537db12_1.conda - sha256: d3b0b8812eab553d3464bbd68204f007f1ebadf96ce30eb0cbc5159f72e353f5 - md5: 85d8fa5e55ed8f93f874b3b23ed54ec6 + size: 40251 + timestamp: 1760295839166 +- conda: https://prefix.dev/conda-forge/win-64/libffi-3.5.2-h52bdfb6_0.conda + sha256: ddff25aaa4f0aa535413f5d831b04073789522890a4d8626366e43ecde1534a3 + md5: ba4ad812d2afc22b9a34ce8327a0930f depends: - ucrt >=10.0.20348.0 - - vc >=14.2,<15 - - vc14_runtime >=14.29.30139 + - vc >=14.3,<15 + - vc14_runtime >=14.44.35208 license: MIT license_family: MIT - size: 44978 - timestamp: 1743435053850 -- conda: https://prefix.dev/conda-forge/linux-64/libgcc-15.2.0-h767d61c_7.conda - sha256: 08f9b87578ab981c7713e4e6a7d935e40766e10691732bba376d4964562bcb45 - md5: c0374badb3a5d4b1372db28d19462c53 + size: 44866 + timestamp: 1760295760649 +- conda: https://prefix.dev/conda-forge/linux-64/libgcc-15.2.0-he0feb66_16.conda + sha256: 6eed58051c2e12b804d53ceff5994a350c61baf117ec83f5f10c953a3f311451 + md5: 6d0363467e6ed84f11435eb309f2ff06 depends: - __glibc >=2.17,<3.0.a0 - _openmp_mutex >=4.5 constrains: - - libgomp 15.2.0 h767d61c_7 - - libgcc-ng ==15.2.0=*_7 + - libgcc-ng ==15.2.0=*_16 + - libgomp 15.2.0 he0feb66_16 license: GPL-3.0-only WITH GCC-exception-3.1 license_family: GPL - size: 822552 - timestamp: 1759968052178 -- conda: https://prefix.dev/conda-forge/linux-64/libgomp-15.2.0-h767d61c_7.conda - sha256: e9fb1c258c8e66ee278397b5822692527c5f5786d372fe7a869b900853f3f5ca - md5: f7b4d76975aac7e5d9e6ad13845f92fe + size: 1042798 + timestamp: 1765256792743 +- conda: https://prefix.dev/conda-forge/linux-64/libgomp-15.2.0-he0feb66_16.conda + sha256: 5b3e5e4e9270ecfcd48f47e3a68f037f5ab0f529ccb223e8e5d5ac75a58fc687 + md5: 26c46f90d0e727e95c6c9498a33a09f3 depends: - __glibc >=2.17,<3.0.a0 license: GPL-3.0-only WITH GCC-exception-3.1 license_family: GPL - size: 447919 - timestamp: 1759967942498 + size: 603284 + timestamp: 1765256703881 - conda: https://prefix.dev/conda-forge/linux-64/liblzma-5.8.1-hb9d3cd8_2.conda sha256: f2591c0069447bbe28d4d696b7fcb0c5bd0b4ac582769b89addbcf26fb3430d8 md5: 1a580f7796c7bf6393fddb8bbbde58dc @@ -400,67 +413,55 @@ packages: license_family: BSD size: 88657 timestamp: 1723861474602 -- conda: https://prefix.dev/conda-forge/linux-64/libsqlite-3.50.4-h0c1763c_0.conda - sha256: 6d9c32fc369af5a84875725f7ddfbfc2ace795c28f246dc70055a79f9b2003da - md5: 0b367fad34931cb79e0d6b7e5c06bb1c +- conda: https://prefix.dev/conda-forge/linux-64/libsqlite-3.51.1-h0c1763c_0.conda + sha256: 6f0e8a812e8e33a4d8b7a0e595efe28373080d27b78ee4828aa4f6649a088454 + md5: 2e1b84d273b01835256e53fd938de355 depends: - __glibc >=2.17,<3.0.a0 - libgcc >=14 - libzlib >=1.3.1,<2.0a0 license: blessing - size: 932581 - timestamp: 1753948484112 -- conda: https://prefix.dev/conda-forge/osx-64/libsqlite-3.50.4-h39a8b3b_0.conda - sha256: 466366b094c3eb4b1d77320530cbf5400e7a10ab33e4824c200147488eebf7a6 - md5: 156bfb239b6a67ab4a01110e6718cbc4 + size: 938979 + timestamp: 1764359444435 +- conda: https://prefix.dev/conda-forge/osx-64/libsqlite-3.51.1-h6cc646a_0.conda + sha256: 8460901daff15749354f0de143e766febf0682fe9201bf307ea84837707644d1 + md5: f71213ed0c51030cb17a77fc60a757f1 depends: - __osx >=10.13 + - icu >=75.1,<76.0a0 - libzlib >=1.3.1,<2.0a0 license: blessing - size: 980121 - timestamp: 1753948554003 -- conda: https://prefix.dev/conda-forge/osx-arm64/libsqlite-3.50.4-h4237e3c_0.conda - sha256: 802ebe62e6bc59fc26b26276b793e0542cfff2d03c086440aeaf72fb8bbcec44 - md5: 1dcb0468f5146e38fae99aef9656034b + size: 991350 + timestamp: 1764359781222 +- conda: https://prefix.dev/conda-forge/osx-arm64/libsqlite-3.51.1-h9a5124b_0.conda + sha256: a46b167447e2a9e38586320c30b29e3b68b6f7e6b873c18d6b1aa2efd2626917 + md5: 67e50e5bd4e5e2310d66b88c4da50096 depends: - __osx >=11.0 - - icu >=75.1,<76.0a0 - libzlib >=1.3.1,<2.0a0 license: blessing - size: 902645 - timestamp: 1753948599139 -- conda: https://prefix.dev/conda-forge/win-64/libsqlite-3.50.4-hf5d6505_0.conda - sha256: 5dc4f07b2d6270ac0c874caec53c6984caaaa84bc0d3eb593b0edf3dc8492efa - md5: ccb20d946040f86f0c05b644d5eadeca + size: 906292 + timestamp: 1764359907797 +- conda: https://prefix.dev/conda-forge/win-64/libsqlite-3.51.1-hf5d6505_0.conda + sha256: a976c8b455d9023b83878609bd68c3b035b9839d592bd6c7be7552c523773b62 + md5: f92bef2f8e523bb0eabe60099683617a depends: - ucrt >=10.0.20348.0 - vc >=14.3,<15 - vc14_runtime >=14.44.35208 license: blessing - size: 1288499 - timestamp: 1753948889360 -- conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-15.2.0-h8f9b012_7.conda - sha256: 1b981647d9775e1cdeb2fab0a4dd9cd75a6b0de2963f6c3953dbd712f78334b3 - md5: 5b767048b1b3ee9a954b06f4084f93dc - depends: - - __glibc >=2.17,<3.0.a0 - - libgcc 15.2.0 h767d61c_7 - constrains: - - libstdcxx-ng ==15.2.0=*_7 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL - size: 3898269 - timestamp: 1759968103436 -- conda: https://prefix.dev/conda-forge/linux-64/libuuid-2.41.2-he9a06e4_0.conda - sha256: e5ec6d2ad7eef538ddcb9ea62ad4346fde70a4736342c4ad87bd713641eb9808 - md5: 80c07c68d2f6870250959dcc95b209d1 + size: 1291059 + timestamp: 1764359545703 +- conda: https://prefix.dev/conda-forge/linux-64/libuuid-2.41.2-h5347b49_1.conda + sha256: 030447cf827c471abd37092ab9714fde82b8222106f22fde94bc7a64e2704c40 + md5: 41f5c09a211985c3ce642d60721e7c3e depends: - __glibc >=2.17,<3.0.a0 - libgcc >=14 license: BSD-3-Clause license_family: BSD - size: 37135 - timestamp: 1758626800002 + size: 40235 + timestamp: 1764790744114 - conda: https://prefix.dev/conda-forge/linux-64/libzlib-1.3.1-hb9d3cd8_2.conda sha256: d4bfe88d7cb447768e31650f06257995601f89076080e76df55e3112d4e47dc4 md5: edb0dca6bc32e4f4789199455a1dbeb8 @@ -533,40 +534,40 @@ packages: license: X11 AND BSD-3-Clause size: 797030 timestamp: 1738196177597 -- conda: https://prefix.dev/conda-forge/linux-64/openssl-3.5.4-h26f9b46_0.conda - sha256: e807f3bad09bdf4075dbb4168619e14b0c0360bacb2e12ef18641a834c8c5549 - md5: 14edad12b59ccbfa3910d42c72adc2a0 +- conda: https://prefix.dev/conda-forge/linux-64/openssl-3.6.0-h26f9b46_0.conda + sha256: a47271202f4518a484956968335b2521409c8173e123ab381e775c358c67fe6d + md5: 9ee58d5c534af06558933af3c845a780 depends: - __glibc >=2.17,<3.0.a0 - ca-certificates - libgcc >=14 license: Apache-2.0 license_family: Apache - size: 3119624 - timestamp: 1759324353651 -- conda: https://prefix.dev/conda-forge/osx-64/openssl-3.5.4-h230baf5_0.conda - sha256: 3ce8467773b2472b2919412fd936413f05a9b10c42e52c27bbddc923ef5da78a - md5: 075eaad78f96bbf5835952afbe44466e + size: 3165399 + timestamp: 1762839186699 +- conda: https://prefix.dev/conda-forge/osx-64/openssl-3.6.0-h230baf5_0.conda + sha256: 36fe9fb316be22fcfb46d5fa3e2e85eec5ef84f908b7745f68f768917235b2d5 + md5: 3f50cdf9a97d0280655758b735781096 depends: - __osx >=10.13 - ca-certificates license: Apache-2.0 license_family: Apache - size: 2747108 - timestamp: 1759326402264 -- conda: https://prefix.dev/conda-forge/osx-arm64/openssl-3.5.4-h5503f6c_0.conda - sha256: f0512629f9589392c2fb9733d11e753d0eab8fc7602f96e4d7f3bd95c783eb07 - md5: 71118318f37f717eefe55841adb172fd + size: 2778996 + timestamp: 1762840724922 +- conda: https://prefix.dev/conda-forge/osx-arm64/openssl-3.6.0-h5503f6c_0.conda + sha256: ebe93dafcc09e099782fe3907485d4e1671296bc14f8c383cb6f3dfebb773988 + md5: b34dc4172653c13dcf453862f251af2b depends: - __osx >=11.0 - ca-certificates license: Apache-2.0 license_family: Apache - size: 3067808 - timestamp: 1759324763146 -- conda: https://prefix.dev/conda-forge/win-64/openssl-3.5.4-h725018a_0.conda - sha256: 5ddc1e39e2a8b72db2431620ad1124016f3df135f87ebde450d235c212a61994 - md5: f28ffa510fe055ab518cbd9d6ddfea23 + size: 3108371 + timestamp: 1762839712322 +- conda: https://prefix.dev/conda-forge/win-64/openssl-3.6.0-h725018a_0.conda + sha256: 6d72d6f766293d4f2aa60c28c244c8efed6946c430814175f959ffe8cab899b3 + md5: 84f8fb4afd1157f59098f618cd2437e4 depends: - ca-certificates - ucrt >=10.0.20348.0 @@ -574,22 +575,22 @@ packages: - vc14_runtime >=14.44.35208 license: Apache-2.0 license_family: Apache - size: 9218823 - timestamp: 1759326176247 -- conda: https://prefix.dev/conda-forge/linux-64/python-3.14.0-h5989046_101_cp314.conda - build_number: 101 - sha256: 61ae2c29b1097c12161a09a4061be8f909bc1387d8388e875d8ed5e357ef0824 - md5: b2ad21488149ec2c4d83640619de2430 + size: 9440812 + timestamp: 1762841722179 +- conda: https://prefix.dev/conda-forge/linux-64/python-3.14.2-h32b2ec7_100_cp314.conda + build_number: 100 + sha256: a120fb2da4e4d51dd32918c149b04a08815fd2bd52099dad1334647984bb07f1 + md5: 1cef1236a05c3a98f68c33ae9425f656 depends: - __glibc >=2.17,<3.0.a0 - bzip2 >=1.0.8,<2.0a0 - ld_impl_linux-64 >=2.36.1 - - libexpat >=2.7.1,<3.0a0 - - libffi >=3.4.6,<3.5.0a0 + - libexpat >=2.7.3,<3.0a0 + - libffi >=3.5.2,<3.6.0a0 - libgcc >=14 - liblzma >=5.8.1,<6.0a0 - libmpdec >=4.0.0,<5.0a0 - - libsqlite >=3.50.4,<4.0a0 + - libsqlite >=3.51.1,<4.0a0 - libuuid >=2.41.2,<3.0a0 - libzlib >=1.3.1,<2.0a0 - ncurses >=6.5,<7.0a0 @@ -600,21 +601,21 @@ packages: - tzdata - zstd >=1.5.7,<1.6.0a0 license: Python-2.0 - size: 36692257 - timestamp: 1760299587505 + size: 36790521 + timestamp: 1765021515427 python_site_packages_path: lib/python3.14/site-packages -- conda: https://prefix.dev/conda-forge/osx-64/python-3.14.0-h759804c_101_cp314.conda - build_number: 101 - sha256: a93cf6bbd5bf2fe0ddab09f5dadad49b41bc13eb85c35d8ae84d3989624fca2f - md5: 9eca06d9b62b949495b072df4ac1d2a2 +- conda: https://prefix.dev/conda-forge/osx-64/python-3.14.2-hf88997e_100_cp314.conda + build_number: 100 + sha256: cd9d41368cb7c531e82fbfdb01e274efbb176c464b59ec619538dd2580602191 + md5: 48921d5efb314c3e628089fc6e27e54a depends: - __osx >=10.13 - bzip2 >=1.0.8,<2.0a0 - - libexpat >=2.7.1,<3.0a0 - - libffi >=3.4.6,<3.5.0a0 + - libexpat >=2.7.3,<3.0a0 + - libffi >=3.5.2,<3.6.0a0 - liblzma >=5.8.1,<6.0a0 - libmpdec >=4.0.0,<5.0a0 - - libsqlite >=3.50.4,<4.0a0 + - libsqlite >=3.51.1,<4.0a0 - libzlib >=1.3.1,<2.0a0 - ncurses >=6.5,<7.0a0 - openssl >=3.5.4,<4.0a0 @@ -624,21 +625,21 @@ packages: - tzdata - zstd >=1.5.7,<1.6.0a0 license: Python-2.0 - size: 14431661 - timestamp: 1760300228434 + size: 14323056 + timestamp: 1765026108189 python_site_packages_path: lib/python3.14/site-packages -- conda: https://prefix.dev/conda-forge/osx-arm64/python-3.14.0-h8929636_101_cp314.conda - build_number: 101 - sha256: 0b821bbff81b0735d94aca62958b152ad9565773f99760fe0dd59db8e7154245 - md5: 01a476ede0de7e71c2e9b178315cc7f1 +- conda: https://prefix.dev/conda-forge/osx-arm64/python-3.14.2-h40d2674_100_cp314.conda + build_number: 100 + sha256: 1a93782e90b53e04c2b1a50a0f8bf0887936649d19dba6a05b05c4b44dae96b7 + md5: 14f15ab0d31a2ee5635aa56e77132594 depends: - __osx >=11.0 - bzip2 >=1.0.8,<2.0a0 - - libexpat >=2.7.1,<3.0a0 - - libffi >=3.4.6,<3.5.0a0 + - libexpat >=2.7.3,<3.0a0 + - libffi >=3.5.2,<3.6.0a0 - liblzma >=5.8.1,<6.0a0 - libmpdec >=4.0.0,<5.0a0 - - libsqlite >=3.50.4,<4.0a0 + - libsqlite >=3.51.1,<4.0a0 - libzlib >=1.3.1,<2.0a0 - ncurses >=6.5,<7.0a0 - openssl >=3.5.4,<4.0a0 @@ -648,20 +649,20 @@ packages: - tzdata - zstd >=1.5.7,<1.6.0a0 license: Python-2.0 - size: 13530883 - timestamp: 1760298885457 + size: 13575758 + timestamp: 1765021280625 python_site_packages_path: lib/python3.14/site-packages -- conda: https://prefix.dev/conda-forge/win-64/python-3.14.0-h6fd79ff_101_cp314.conda - build_number: 101 - sha256: 469a62c550143b30f26bdbb445d2596c7299ad8e278763388793ed106773a1ee - md5: 834cb790da2cbee272bf888e4558c92a +- conda: https://prefix.dev/conda-forge/win-64/python-3.14.2-h4b44e0e_100_cp314.conda + build_number: 100 + sha256: 6857d7c97cc71fe9ba298dcb1d3b66cc7df425132ab801babd655faa3df48f32 + md5: c3c73414d5ae3f543c531c978d9cc8b8 depends: - bzip2 >=1.0.8,<2.0a0 - - libexpat >=2.7.1,<3.0a0 - - libffi >=3.4.6,<3.5.0a0 + - libexpat >=2.7.3,<3.0a0 + - libffi >=3.5.2,<3.6.0a0 - liblzma >=5.8.1,<6.0a0 - libmpdec >=4.0.0,<5.0a0 - - libsqlite >=3.50.4,<4.0a0 + - libsqlite >=3.51.1,<4.0a0 - libzlib >=1.3.1,<2.0a0 - openssl >=3.5.4,<4.0a0 - python_abi 3.14.* *_cp314 @@ -672,8 +673,8 @@ packages: - vc14_runtime >=14.44.35208 - zstd >=1.5.7,<1.6.0a0 license: Python-2.0 - size: 16903251 - timestamp: 1760298231628 + size: 16833248 + timestamp: 1765020224759 python_site_packages_path: Lib/site-packages - conda: https://prefix.dev/conda-forge/noarch/python_abi-3.14-8_cp314.conda build_number: 8 @@ -713,48 +714,50 @@ packages: license_family: GPL size: 252359 timestamp: 1740379663071 -- conda: https://prefix.dev/conda-forge/linux-64/tk-8.6.13-noxft_hd72426e_102.conda - sha256: a84ff687119e6d8752346d1d408d5cf360dee0badd487a472aa8ddedfdc219e1 - md5: a0116df4f4ed05c303811a837d5b39d8 +- conda: https://prefix.dev/conda-forge/linux-64/tk-8.6.13-noxft_ha0e22de_103.conda + sha256: 1544760538a40bcd8ace2b1d8ebe3eb5807ac268641f8acdc18c69c5ebfeaf64 + md5: 86bc20552bf46075e3d92b67f089172d depends: - __glibc >=2.17,<3.0.a0 - libgcc >=13 - libzlib >=1.3.1,<2.0a0 + constrains: + - xorg-libx11 >=1.8.12,<2.0a0 license: TCL license_family: BSD - size: 3285204 - timestamp: 1748387766691 -- conda: https://prefix.dev/conda-forge/osx-64/tk-8.6.13-hf689a15_2.conda - sha256: b24468006a96b71a5f4372205ea7ec4b399b0f2a543541e86f883de54cd623fc - md5: 9864891a6946c2fe037c02fca7392ab4 + size: 3284905 + timestamp: 1763054914403 +- conda: https://prefix.dev/conda-forge/osx-64/tk-8.6.13-hf689a15_3.conda + sha256: 0d0b6cef83fec41bc0eb4f3b761c4621b7adfb14378051a8177bd9bb73d26779 + md5: bd9f1de651dbd80b51281c694827f78f depends: - __osx >=10.13 - libzlib >=1.3.1,<2.0a0 license: TCL license_family: BSD - size: 3259809 - timestamp: 1748387843735 -- conda: https://prefix.dev/conda-forge/osx-arm64/tk-8.6.13-h892fb3f_2.conda - sha256: cb86c522576fa95c6db4c878849af0bccfd3264daf0cc40dd18e7f4a7bfced0e - md5: 7362396c170252e7b7b0c8fb37fe9c78 + size: 3262702 + timestamp: 1763055085507 +- conda: https://prefix.dev/conda-forge/osx-arm64/tk-8.6.13-h892fb3f_3.conda + sha256: ad0c67cb03c163a109820dc9ecf77faf6ec7150e942d1e8bb13e5d39dc058ab7 + md5: a73d54a5abba6543cb2f0af1bfbd6851 depends: - __osx >=11.0 - libzlib >=1.3.1,<2.0a0 license: TCL license_family: BSD - size: 3125538 - timestamp: 1748388189063 -- conda: https://prefix.dev/conda-forge/win-64/tk-8.6.13-h2c6b04d_2.conda - sha256: e3614b0eb4abcc70d98eae159db59d9b4059ed743ef402081151a948dce95896 - md5: ebd0e761de9aa879a51d22cc721bd095 + size: 3125484 + timestamp: 1763055028377 +- conda: https://prefix.dev/conda-forge/win-64/tk-8.6.13-h2c6b04d_3.conda + sha256: 4581f4ffb432fefa1ac4f85c5682cc27014bcd66e7beaa0ee330e927a7858790 + md5: 7cb36e506a7dba4817970f8adb6396f9 depends: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 license: TCL license_family: BSD - size: 3466348 - timestamp: 1748388121356 + size: 3472313 + timestamp: 1763055164278 - conda: https://prefix.dev/conda-forge/noarch/tzdata-2025b-h78e105d_0.conda sha256: 5aaa366385d716557e365f0a4e9c3fca43ba196872abbbe3d56bb610d131e192 md5: 4222072737ccff51314b5ece9c7d6f5a @@ -770,81 +773,79 @@ packages: license: LicenseRef-MicrosoftWindowsSDK10 size: 694692 timestamp: 1756385147981 -- conda: https://prefix.dev/conda-forge/win-64/vc-14.3-h2b53caa_32.conda - sha256: 82250af59af9ff3c6a635dd4c4764c631d854feb334d6747d356d949af44d7cf - md5: ef02bbe151253a72b8eda264a935db66 +- conda: https://prefix.dev/conda-forge/win-64/vc-14.3-h2b53caa_33.conda + sha256: 7036945b5fff304064108c22cbc1bb30e7536363782b0456681ee6cf209138bd + md5: 2d1c042360c09498891809a3765261be depends: - vc14_runtime >=14.42.34433 track_features: - vc14 license: BSD-3-Clause license_family: BSD - size: 18861 - timestamp: 1760418772353 -- conda: https://prefix.dev/conda-forge/win-64/vc14_runtime-14.44.35208-h818238b_32.conda - sha256: e3a3656b70d1202e0d042811ceb743bd0d9f7e00e2acdf824d231b044ef6c0fd - md5: 378d5dcec45eaea8d303da6f00447ac0 + size: 19070 + timestamp: 1765216452130 +- conda: https://prefix.dev/conda-forge/win-64/vc14_runtime-14.44.35208-h818238b_33.conda + sha256: 7e8f7da25d7ce975bbe7d7e6d6e899bf1f253e524a3427cc135a79f3a79c457c + md5: fb8e4914c5ad1c71b3c519621e1df7b8 depends: - ucrt >=10.0.20348.0 - - vcomp14 14.44.35208 h818238b_32 + - vcomp14 14.44.35208 h818238b_33 constrains: - - vs2015_runtime 14.44.35208.* *_32 + - vs2015_runtime 14.44.35208.* *_33 license: LicenseRef-MicrosoftVisualCpp2015-2022Runtime license_family: Proprietary - size: 682706 - timestamp: 1760418629729 -- conda: https://prefix.dev/conda-forge/win-64/vcomp14-14.44.35208-h818238b_32.conda - sha256: f3790c88fbbdc55874f41de81a4237b1b91eab75e05d0e58661518ff04d2a8a1 - md5: 58f67b437acbf2764317ba273d731f1d + size: 684323 + timestamp: 1765216366832 +- conda: https://prefix.dev/conda-forge/win-64/vcomp14-14.44.35208-h818238b_33.conda + sha256: f79edd878094e86af2b2bc1455b0a81e02839a784fb093d5996ad4cf7b810101 + md5: 4cb6942b4bd846e51b4849f4a93c7e6d depends: - ucrt >=10.0.20348.0 constrains: - - vs2015_runtime 14.44.35208.* *_32 + - vs2015_runtime 14.44.35208.* *_33 license: LicenseRef-MicrosoftVisualCpp2015-2022Runtime license_family: Proprietary - size: 114846 - timestamp: 1760418593847 -- conda: https://prefix.dev/conda-forge/linux-64/zstd-1.5.7-hb8e6e7a_2.conda - sha256: a4166e3d8ff4e35932510aaff7aa90772f84b4d07e9f6f83c614cba7ceefe0eb - md5: 6432cb5d4ac0046c3ac0a8a0f95842f9 + size: 115073 + timestamp: 1765216325898 +- conda: https://prefix.dev/conda-forge/linux-64/zstd-1.5.7-hb78ec9c_6.conda + sha256: 68f0206ca6e98fea941e5717cec780ed2873ffabc0e1ed34428c061e2c6268c7 + md5: 4a13eeac0b5c8e5b8ab496e6c4ddd829 depends: - __glibc >=2.17,<3.0.a0 - - libgcc >=13 - - libstdcxx >=13 - libzlib >=1.3.1,<2.0a0 license: BSD-3-Clause license_family: BSD - size: 567578 - timestamp: 1742433379869 -- conda: https://prefix.dev/conda-forge/osx-64/zstd-1.5.7-h8210216_2.conda - sha256: c171c43d0c47eed45085112cb00c8c7d4f0caa5a32d47f2daca727e45fb98dca - md5: cd60a4a5a8d6a476b30d8aa4bb49251a + size: 601375 + timestamp: 1764777111296 +- conda: https://prefix.dev/conda-forge/osx-64/zstd-1.5.7-h3eecb57_6.conda + sha256: 47101a4055a70a4876ffc87b750ab2287b67eca793f21c8224be5e1ee6394d3f + md5: 727109b184d680772e3122f40136d5ca depends: - __osx >=10.13 - libzlib >=1.3.1,<2.0a0 license: BSD-3-Clause license_family: BSD - size: 485754 - timestamp: 1742433356230 -- conda: https://prefix.dev/conda-forge/osx-arm64/zstd-1.5.7-h6491c7d_2.conda - sha256: 0d02046f57f7a1a3feae3e9d1aa2113788311f3cf37a3244c71e61a93177ba67 - md5: e6f69c7bcccdefa417f056fa593b40f0 + size: 528148 + timestamp: 1764777156963 +- conda: https://prefix.dev/conda-forge/osx-arm64/zstd-1.5.7-hbf9d68e_6.conda + sha256: 9485ba49e8f47d2b597dd399e88f4802e100851b27c21d7525625b0b4025a5d9 + md5: ab136e4c34e97f34fb621d2592a393d8 depends: - __osx >=11.0 - libzlib >=1.3.1,<2.0a0 license: BSD-3-Clause license_family: BSD - size: 399979 - timestamp: 1742433432699 -- conda: https://prefix.dev/conda-forge/win-64/zstd-1.5.7-hbeecb71_2.conda - sha256: bc64864377d809b904e877a98d0584f43836c9f2ef27d3d2a1421fa6eae7ca04 - md5: 21f56217d6125fb30c3c3f10c786d751 + size: 433413 + timestamp: 1764777166076 +- conda: https://prefix.dev/conda-forge/win-64/zstd-1.5.7-h534d264_6.conda + sha256: 368d8628424966fd8f9c8018326a9c779e06913dd39e646cf331226acc90e5b2 + md5: 053b84beec00b71ea8ff7a4f84b55207 depends: - - libzlib >=1.3.1,<2.0a0 + - vc >=14.3,<15 + - vc14_runtime >=14.44.35208 - ucrt >=10.0.20348.0 - - vc >=14.2,<15 - - vc14_runtime >=14.29.30139 + - libzlib >=1.3.1,<2.0a0 license: BSD-3-Clause license_family: BSD - size: 354697 - timestamp: 1742433568506 + size: 388453 + timestamp: 1764777142545 diff --git a/examples/pixi-build/array-api-extra/pixi.toml b/examples/pixi-build/array-api-extra/pixi.toml index 7183afe563..348a7de02f 100644 --- a/examples/pixi-build/array-api-extra/pixi.toml +++ b/examples/pixi-build/array-api-extra/pixi.toml @@ -6,7 +6,7 @@ preview = ["pixi-build"] version = "0.1.0" [dependencies] -array-api-extra = { path = "." } +array-api-extra = { path = "recipe.yaml" } [tasks] test = "python -c 'import array_api_extra'" diff --git a/tests/data/non-satisfiability/binary-spec-source-record/pixi.lock b/tests/data/non-satisfiability/binary-spec-source-record/pixi.lock index 1bb64999a1..1aa15cfcdf 100644 --- a/tests/data/non-satisfiability/binary-spec-source-record/pixi.lock +++ b/tests/data/non-satisfiability/binary-spec-source-record/pixi.lock @@ -2,59 +2,15 @@ version: 6 environments: default: channels: - - url: https://conda.anaconda.org/conda-forge/ + - url: https://conda.anaconda.org/conda-forge/ packages: win-64: - - conda: https://conda.anaconda.org/conda-forge/win-64/ucrt-10.0.22621.0-h57928b3_1.conda - - conda: https://conda.anaconda.org/conda-forge/win-64/vc-14.3-ha32ba9b_22.conda - - conda: https://conda.anaconda.org/conda-forge/win-64/vc14_runtime-14.40.33810-hcc2c482_22.conda - - conda: source + - conda: source packages: -- conda: source - name: source - version: 0.1.0 - build: hbf21a9e_0 - subdir: win-64 - depends: - - vc >=14.1,<15 - - vc14_runtime >=14.16.27033 - input: - hash: a3c04eab345d02c20c544f694526f0ed92e07d7b0ebfe0f55ad5e6b752259223 - globs: - - pixi.toml -- conda: https://conda.anaconda.org/conda-forge/win-64/ucrt-10.0.22621.0-h57928b3_1.conda - sha256: db8dead3dd30fb1a032737554ce91e2819b43496a0db09927edf01c32b577450 - md5: 6797b005cd0f439c4c5c9ac565783700 - constrains: - - vs2015_runtime >=14.29.30037 - arch: x86_64 - platform: win - license: LicenseRef-MicrosoftWindowsSDK10 - size: 559710 - timestamp: 1728377334097 -- conda: https://conda.anaconda.org/conda-forge/win-64/vc-14.3-ha32ba9b_22.conda - sha256: 2a47c5bd8bec045959afada7063feacd074ad66b170c1ea92dd139b389fcf8fd - md5: 311c9ba1dfdd2895a8cb08346ff26259 - depends: - - vc14_runtime >=14.38.33135 - arch: x86_64 - platform: win - track_features: - - vc14 - license: BSD-3-Clause - license_family: BSD - size: 17447 - timestamp: 1728400826998 -- conda: https://conda.anaconda.org/conda-forge/win-64/vc14_runtime-14.40.33810-hcc2c482_22.conda - sha256: 4c669c65007f88a7cdd560192f7e6d5679d191ac71610db724e18b2410964d64 - md5: ce23a4b980ee0556a118ed96550ff3f3 - depends: - - ucrt >=10.0.20348.0 - constrains: - - vs2015_runtime 14.40.33810.* *_22 - arch: x86_64 - platform: win - license: LicenseRef-MicrosoftVisualCpp2015-2022Runtime - license_family: Proprietary - size: 750719 - timestamp: 1728401055788 + - conda: source + name: source + version: 0.0.1 + build: "" + subdir: noarch + variants: + target_platform: noarch diff --git a/tests/data/non-satisfiability/binary-spec-source-record/pixi.toml b/tests/data/non-satisfiability/binary-spec-source-record/pixi.toml index 619e04bf9a..cd13dd0d3c 100644 --- a/tests/data/non-satisfiability/binary-spec-source-record/pixi.toml +++ b/tests/data/non-satisfiability/binary-spec-source-record/pixi.toml @@ -1,6 +1,6 @@ [project] channels = ["conda-forge"] -name = "binary-spec-source-record" +name = "source" platforms = ["win-64"] preview = ["pixi-build"] diff --git a/tests/data/non-satisfiability/binary-spec-source-record/source/pixi.toml b/tests/data/non-satisfiability/binary-spec-source-record/source/pixi.toml new file mode 100644 index 0000000000..14b1be994f --- /dev/null +++ b/tests/data/non-satisfiability/binary-spec-source-record/source/pixi.toml @@ -0,0 +1,6 @@ +[package] +name = "source" + +[package.build.backend] +name = "in-memory" +version = "*" diff --git a/tests/data/non-satisfiability/mismatched-source-spec/child-package/pixi.toml b/tests/data/non-satisfiability/mismatched-source-spec/child-package/pixi.toml new file mode 100644 index 0000000000..83d5fa673d --- /dev/null +++ b/tests/data/non-satisfiability/mismatched-source-spec/child-package/pixi.toml @@ -0,0 +1,9 @@ +[package] +name = "child-package" +version = "0.0.1" + +[package.build] +backend = { name = "in-memory", version = "*" } + +[package.run-dependencies] +foobar = { path = "../foobar" } diff --git a/tests/data/non-satisfiability/mismatched-source-spec/pixi.lock b/tests/data/non-satisfiability/mismatched-source-spec/pixi.lock index b3e659526f..96c32a44e5 100644 --- a/tests/data/non-satisfiability/mismatched-source-spec/pixi.lock +++ b/tests/data/non-satisfiability/mismatched-source-spec/pixi.lock @@ -2,15 +2,17 @@ version: 6 environments: default: channels: - - url: https://conda.anaconda.org/conda-forge/ + - url: https://conda.anaconda.org/conda-forge/ packages: win-64: - - conda: child-package + - conda: child-package packages: -# This should invalidate the lock-file because the package `child-package` is -# requested as a git package in the pixi.toml. -- conda: child-package - name: child-package - version: 0.1.0 - build: pyhbf21a9e_0 - subdir: noarch + # This should invalidate the lock-file because the package `child-package` is + # requested as a git package in the pixi.toml. + - conda: child-package + name: child-package + version: 0.0.1 + build: "" + subdir: noarch + variant: + target_platform: noarch diff --git a/tests/data/non-satisfiability/source-dependency-changed-project-model/child-package/pixi.toml b/tests/data/non-satisfiability/source-dependency-changed-project-model/child-package/pixi.toml deleted file mode 100644 index edf61a2282..0000000000 --- a/tests/data/non-satisfiability/source-dependency-changed-project-model/child-package/pixi.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "child-package" -# The version in the lock file is 0.1.0 -# That is included in project model, and therefore the hash -version = "0.2.0" - -[package.build] -backend = { name = "pixi-build-cmake", version = "0.3.*" } diff --git a/tests/data/non-satisfiability/source-dependency-changed-project-model/pixi.lock b/tests/data/non-satisfiability/source-dependency-changed-project-model/pixi.lock deleted file mode 100644 index 5450d956b2..0000000000 --- a/tests/data/non-satisfiability/source-dependency-changed-project-model/pixi.lock +++ /dev/null @@ -1,77 +0,0 @@ -version: 6 -environments: - default: - channels: - - url: https://prefix.dev/pixi-build-backends/ - - url: https://prefix.dev/conda-forge/ - packages: - linux-64: - - conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 - - conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 - - conda: https://prefix.dev/conda-forge/linux-64/libgcc-15.1.0-h767d61c_2.conda - - conda: https://prefix.dev/conda-forge/linux-64/libgomp-15.1.0-h767d61c_2.conda - - conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-15.1.0-h8f9b012_2.conda - - conda: child-package -packages: -- conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 - sha256: fe51de6107f9edc7aa4f786a70f4a883943bc9d39b3bb7307c04c41410990726 - md5: d7c89558ba9fa0495403155b64376d81 - license: None - size: 2562 - timestamp: 1578324546067 -- conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 - build_number: 16 - sha256: fbe2c5e56a653bebb982eda4876a9178aedfc2b545f25d0ce9c4c0b508253d22 - md5: 73aaf86a425cc6e73fcf236a5a46396d - depends: - - _libgcc_mutex 0.1 conda_forge - - libgomp >=7.5.0 - constrains: - - openmp_impl 9999 - license: BSD-3-Clause - license_family: BSD - size: 23621 - timestamp: 1650670423406 -- conda: child-package - name: child-package - version: 0.1.0 - build: hbf21a9e_0 - subdir: linux-64 - depends: - - libstdcxx >=15 - - libgcc >=15 - input: - hash: 64a8e9eb88c4f6e944a37279a38a47fe7872454fb62bcafad63d200aef4b4a05 - globs: [] -- conda: https://prefix.dev/conda-forge/linux-64/libgcc-15.1.0-h767d61c_2.conda - sha256: 0024f9ab34c09629621aefd8603ef77bf9d708129b0dd79029e502c39ffc2195 - md5: ea8ac52380885ed41c1baa8f1d6d2b93 - depends: - - __glibc >=2.17,<3.0.a0 - - _openmp_mutex >=4.5 - constrains: - - libgcc-ng ==15.1.0=*_2 - - libgomp 15.1.0 h767d61c_2 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL - size: 829108 - timestamp: 1746642191935 -- conda: https://prefix.dev/conda-forge/linux-64/libgomp-15.1.0-h767d61c_2.conda - sha256: 05fff3dc7e80579bc28de13b511baec281c4343d703c406aefd54389959154fb - md5: fbe7d535ff9d3a168c148e07358cd5b1 - depends: - - __glibc >=2.17,<3.0.a0 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL - size: 452635 - timestamp: 1746642113092 -- conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-15.1.0-h8f9b012_2.conda - sha256: 6ae3d153e78f6069d503d9309f2cac6de5b93d067fc6433160a4c05226a5dad4 - md5: 1cb1c67961f6dd257eae9e9691b341aa - depends: - - __glibc >=2.17,<3.0.a0 - - libgcc 15.1.0 h767d61c_2 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL - size: 3902355 - timestamp: 1746642227493 diff --git a/tests/data/non-satisfiability/source-dependency-changed-project-model/pixi.toml b/tests/data/non-satisfiability/source-dependency-changed-project-model/pixi.toml deleted file mode 100644 index afba276d91..0000000000 --- a/tests/data/non-satisfiability/source-dependency-changed-project-model/pixi.toml +++ /dev/null @@ -1,10 +0,0 @@ -[workspace] -channels = [ - "https://prefix.dev/pixi-build-backends", - "https://prefix.dev/conda-forge", -] -platforms = ["linux-64"] -preview = ["pixi-build"] - -[dependencies] -child-package = { path = "child-package" } diff --git a/tests/data/non-satisfiability/source-recursive-dependency-changed-dir/child-package/pixi.toml b/tests/data/non-satisfiability/source-recursive-dependency-changed-dir/child-package/pixi.toml new file mode 100644 index 0000000000..83d5fa673d --- /dev/null +++ b/tests/data/non-satisfiability/source-recursive-dependency-changed-dir/child-package/pixi.toml @@ -0,0 +1,9 @@ +[package] +name = "child-package" +version = "0.0.1" + +[package.build] +backend = { name = "in-memory", version = "*" } + +[package.run-dependencies] +foobar = { path = "../foobar" } diff --git a/tests/data/non-satisfiability/source-recursive-dependency-changed-dir/foobar/pixi.toml b/tests/data/non-satisfiability/source-recursive-dependency-changed-dir/foobar/pixi.toml new file mode 100644 index 0000000000..9f995d26ff --- /dev/null +++ b/tests/data/non-satisfiability/source-recursive-dependency-changed-dir/foobar/pixi.toml @@ -0,0 +1,6 @@ +[package] +name = "foobar" +version = "0.0.1" + +[package.build] +backend = { name = "in-memory", version = "*" } diff --git a/tests/data/non-satisfiability/source-recursive-dependency-changed-dir/pixi.lock b/tests/data/non-satisfiability/source-recursive-dependency-changed-dir/pixi.lock index aa79d3266f..85719c052c 100644 --- a/tests/data/non-satisfiability/source-recursive-dependency-changed-dir/pixi.lock +++ b/tests/data/non-satisfiability/source-recursive-dependency-changed-dir/pixi.lock @@ -2,26 +2,30 @@ version: 6 environments: default: channels: - - url: https://conda.anaconda.org/conda-forge/ + - url: https://conda.anaconda.org/conda-forge/ packages: win-64: - - conda: foobar - - conda: child-package + - conda: foobar + - conda: child-package packages: -- conda: child-package - name: child-package - version: 0.1.0 - build: pyhbf21a9e_0 - subdir: noarch - depends: - - foobar 0.1.0 baz - # This should cause the lock-file to be invalid because the package `foobar` - # does not come from the directory `not-foobar`. - sources: - foobar: - path: "../not-foobar" -- conda: foobar - name: foobar - version: 0.1.0 - build: baz - subdir: noarch + - conda: child-package + name: child-package + version: 0.0.1 + build: "" + subdir: noarch + depends: + - foobar 0.1.0 baz + # This should cause the lock-file to be invalid because the package `foobar` + # does not come from the directory `not-foobar`. + sources: + foobar: + path: "../not-foobar" + variants: + target_platform: noarch + - conda: foobar + name: foobar + version: 0.0.1 + build: + subdir: noarch + variants: + target_platform: noarch diff --git a/tests/data/non-satisfiability/source-recursive-dependency-mismatch/child-package/pixi.toml b/tests/data/non-satisfiability/source-recursive-dependency-mismatch/child-package/pixi.toml new file mode 100644 index 0000000000..c14ddb71f4 --- /dev/null +++ b/tests/data/non-satisfiability/source-recursive-dependency-mismatch/child-package/pixi.toml @@ -0,0 +1,8 @@ +[package] +name = "child-package" + +[package.build] +backend = { name = "in-memory", version = "*" } + +[package.run-dependencies] +foobar = { path = "../foobar" } diff --git a/tests/data/non-satisfiability/source-recursive-dependency-mismatch/foobar/pixi.toml b/tests/data/non-satisfiability/source-recursive-dependency-mismatch/foobar/pixi.toml new file mode 100644 index 0000000000..9f995d26ff --- /dev/null +++ b/tests/data/non-satisfiability/source-recursive-dependency-mismatch/foobar/pixi.toml @@ -0,0 +1,6 @@ +[package] +name = "foobar" +version = "0.0.1" + +[package.build] +backend = { name = "in-memory", version = "*" } diff --git a/tests/data/non-satisfiability/source-recursive-dependency-mismatch/pixi.lock b/tests/data/non-satisfiability/source-recursive-dependency-mismatch/pixi.lock index 774e3106b1..d730c52af9 100644 --- a/tests/data/non-satisfiability/source-recursive-dependency-mismatch/pixi.lock +++ b/tests/data/non-satisfiability/source-recursive-dependency-mismatch/pixi.lock @@ -2,26 +2,30 @@ version: 6 environments: default: channels: - - url: https://conda.anaconda.org/conda-forge/ + - url: https://conda.anaconda.org/conda-forge/ packages: win-64: - - conda: foobar - - conda: child-package + - conda: foobar + - conda: child-package packages: -- conda: child-package - name: child-package - version: 0.1.0 - build: pyhbf21a9e_0 - subdir: noarch - depends: - - foobar 0.2.0 baz - # This should cause the lock-file to be invalid because the package `foobar` - # has a different version. - sources: - foobar: - path: "../foobar" -- conda: foobar - name: foobar - version: 0.1.0 - build: baz - subdir: noarch + - conda: child-package + name: child-package + version: 0.0.1 + build: "" + subdir: noarch + depends: + - foobar 0.2.0 baz + # This should cause the lock-file to be invalid because the package `foobar` + # has a different version. + variants: + target_platform: noarch + sources: + foobar: + path: "../foobar" + - conda: foobar + name: foobar + version: 0.0.1 + build: baz + subdir: noarch + variants: + target_platform: noarch diff --git a/tests/data/non-satisfiability/source-recursive-dependency/child-package/pixi.toml b/tests/data/non-satisfiability/source-recursive-dependency/child-package/pixi.toml new file mode 100644 index 0000000000..c14ddb71f4 --- /dev/null +++ b/tests/data/non-satisfiability/source-recursive-dependency/child-package/pixi.toml @@ -0,0 +1,8 @@ +[package] +name = "child-package" + +[package.build] +backend = { name = "in-memory", version = "*" } + +[package.run-dependencies] +foobar = { path = "../foobar" } diff --git a/tests/data/non-satisfiability/source-recursive-dependency/pixi.lock b/tests/data/non-satisfiability/source-recursive-dependency/pixi.lock index 29e020a9ea..bac32b953c 100644 --- a/tests/data/non-satisfiability/source-recursive-dependency/pixi.lock +++ b/tests/data/non-satisfiability/source-recursive-dependency/pixi.lock @@ -2,27 +2,29 @@ version: 6 environments: default: channels: - - url: https://conda.anaconda.org/conda-forge/ + - url: https://conda.anaconda.org/conda-forge/ packages: win-64: - - conda: https://conda.anaconda.org/conda-forge/win-64/foobar-0.1.0-baz.conda - - conda: child-package + - conda: https://conda.anaconda.org/conda-forge/win-64/foobar-0.1.0-baz.conda + - conda: child-package packages: -- conda: child-package - name: child-package - version: 0.1.0 - build: pyhbf21a9e_0 - subdir: noarch - depends: - - foobar 0.1.0 baz - # This should cause the lock-file to be invalid because `foobar` should be a source package, - # but it is installed in the environment as a binary package. - sources: - foobar: - path: "foobar" -- conda: https://conda.anaconda.org/conda-forge/win-64/foobar-0.1.0-baz.conda - sha256: 90553586879bf328f2f9efb8d8faa958ecba822faf379f0a20c3461467b9b955 - md5: defd5d375853a2caff36a19d2d81a28e - license: Python-2.0 - size: 16140836 - timestamp: 1696321871976 + - conda: child-package + name: child-package + version: 0.0.1 + build: "" + subdir: noarch + depends: + - foobar 0.1.0 baz + # This should cause the lock-file to be invalid because `foobar` should be a source package, + # but it is installed in the environment as a binary package. + variants: + target_platform: noarch + sources: + foobar: + path: "foobar" + - conda: https://conda.anaconda.org/conda-forge/win-64/foobar-0.1.0-baz.conda + sha256: 90553586879bf328f2f9efb8d8faa958ecba822faf379f0a20c3461467b9b955 + md5: defd5d375853a2caff36a19d2d81a28e + license: Python-2.0 + size: 16140836 + timestamp: 1696321871976 diff --git a/tests/data/satisfiability/out-of-tree-source-parent/package/pixi.toml b/tests/data/satisfiability/out-of-tree-source-parent/package/pixi.toml index d75fbd81c9..d912e9a792 100644 --- a/tests/data/satisfiability/out-of-tree-source-parent/package/pixi.toml +++ b/tests/data/satisfiability/out-of-tree-source-parent/package/pixi.toml @@ -3,6 +3,6 @@ name = "out-of-tree-package" version = "0.1.0" [package.build] -backend = { name = "pixi-build-cmake", version = "0.3.*" } +backend = { name = "in-memory", version = "*" } # Point to source files in a different directory (out-of-tree build) source = { path = "../" } diff --git a/tests/data/satisfiability/out-of-tree-source-parent/pixi.lock b/tests/data/satisfiability/out-of-tree-source-parent/pixi.lock index 0e42219605..cfe86f5f90 100644 --- a/tests/data/satisfiability/out-of-tree-source-parent/pixi.lock +++ b/tests/data/satisfiability/out-of-tree-source-parent/pixi.lock @@ -2,80 +2,18 @@ version: 6 environments: default: channels: - - url: https://prefix.dev/pixi-build-backends/ - - url: https://prefix.dev/conda-forge/ + - url: https://prefix.dev/pixi-build-backends/ + - url: https://prefix.dev/conda-forge/ packages: linux-64: - - conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 - - conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 - - conda: https://prefix.dev/conda-forge/linux-64/libgcc-15.2.0-h767d61c_7.conda - - conda: https://prefix.dev/conda-forge/linux-64/libgomp-15.2.0-h767d61c_7.conda - - conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-15.2.0-h8f9b012_7.conda - - conda: ./package + - conda: ./package packages: -- conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 - sha256: fe51de6107f9edc7aa4f786a70f4a883943bc9d39b3bb7307c04c41410990726 - md5: d7c89558ba9fa0495403155b64376d81 - license: None - size: 2562 - timestamp: 1578324546067 -- conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 - build_number: 16 - sha256: fbe2c5e56a653bebb982eda4876a9178aedfc2b545f25d0ce9c4c0b508253d22 - md5: 73aaf86a425cc6e73fcf236a5a46396d - depends: - - _libgcc_mutex 0.1 conda_forge - - libgomp >=7.5.0 - constrains: - - openmp_impl 9999 - license: BSD-3-Clause - license_family: BSD - size: 23621 - timestamp: 1650670423406 -- conda: https://prefix.dev/conda-forge/linux-64/libgcc-15.2.0-h767d61c_7.conda - sha256: 08f9b87578ab981c7713e4e6a7d935e40766e10691732bba376d4964562bcb45 - md5: c0374badb3a5d4b1372db28d19462c53 - depends: - - __glibc >=2.17,<3.0.a0 - - _openmp_mutex >=4.5 - constrains: - - libgomp 15.2.0 h767d61c_7 - - libgcc-ng ==15.2.0=*_7 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL - size: 822552 - timestamp: 1759968052178 -- conda: https://prefix.dev/conda-forge/linux-64/libgomp-15.2.0-h767d61c_7.conda - sha256: e9fb1c258c8e66ee278397b5822692527c5f5786d372fe7a869b900853f3f5ca - md5: f7b4d76975aac7e5d9e6ad13845f92fe - depends: - - __glibc >=2.17,<3.0.a0 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL - size: 447919 - timestamp: 1759967942498 -- conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-15.2.0-h8f9b012_7.conda - sha256: 1b981647d9775e1cdeb2fab0a4dd9cd75a6b0de2963f6c3953dbd712f78334b3 - md5: 5b767048b1b3ee9a954b06f4084f93dc - depends: - - __glibc >=2.17,<3.0.a0 - - libgcc 15.2.0 h767d61c_7 - constrains: - - libstdcxx-ng ==15.2.0=*_7 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL - size: 3898269 - timestamp: 1759968103436 -- conda: ./package - name: out-of-tree-package - version: 0.1.0 - build: hb0f4dca_0 - subdir: linux-64 - depends: - - libstdcxx >=15 - - libgcc >=15 - input: - hash: 616e7d8611fa803e6655c354f183d6f4b405e94adcabc83c260d8b9da5e3c9d8 - globs: [] - package_build_source: - path: .. + - conda: ./package + name: out-of-tree-package + version: 0.1.0 + build: hb0f4dca_0 + subdir: noarch + variants: + target_platform: noarch + package_build_source: + path: .. diff --git a/tests/data/satisfiability/out-of-tree-source/build-config/pixi.toml b/tests/data/satisfiability/out-of-tree-source/build-config/pixi.toml index 19ccf5377c..bf4319ccea 100644 --- a/tests/data/satisfiability/out-of-tree-source/build-config/pixi.toml +++ b/tests/data/satisfiability/out-of-tree-source/build-config/pixi.toml @@ -3,6 +3,6 @@ name = "out-of-tree-package" version = "0.1.0" [package.build] -backend = { name = "pixi-build-cmake", version = "0.3.*" } +backend = { name = "in-memory", version = "*" } # Point to source files in a different directory (out-of-tree build) source = { path = "../source-files" } diff --git a/tests/data/satisfiability/out-of-tree-source/pixi.lock b/tests/data/satisfiability/out-of-tree-source/pixi.lock index 473a6559f3..af8324cf72 100644 --- a/tests/data/satisfiability/out-of-tree-source/pixi.lock +++ b/tests/data/satisfiability/out-of-tree-source/pixi.lock @@ -2,80 +2,18 @@ version: 6 environments: default: channels: - - url: https://prefix.dev/pixi-build-backends/ - - url: https://prefix.dev/conda-forge/ + - url: https://prefix.dev/pixi-build-backends/ + - url: https://prefix.dev/conda-forge/ packages: linux-64: - - conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 - - conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 - - conda: https://prefix.dev/conda-forge/linux-64/libgcc-15.2.0-h767d61c_7.conda - - conda: https://prefix.dev/conda-forge/linux-64/libgomp-15.2.0-h767d61c_7.conda - - conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-15.2.0-h8f9b012_7.conda - - conda: build-config + - conda: build-config packages: -- conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 - sha256: fe51de6107f9edc7aa4f786a70f4a883943bc9d39b3bb7307c04c41410990726 - md5: d7c89558ba9fa0495403155b64376d81 - license: None - size: 2562 - timestamp: 1578324546067 -- conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 - build_number: 16 - sha256: fbe2c5e56a653bebb982eda4876a9178aedfc2b545f25d0ce9c4c0b508253d22 - md5: 73aaf86a425cc6e73fcf236a5a46396d - depends: - - _libgcc_mutex 0.1 conda_forge - - libgomp >=7.5.0 - constrains: - - openmp_impl 9999 - license: BSD-3-Clause - license_family: BSD - size: 23621 - timestamp: 1650670423406 -- conda: https://prefix.dev/conda-forge/linux-64/libgcc-15.2.0-h767d61c_7.conda - sha256: 08f9b87578ab981c7713e4e6a7d935e40766e10691732bba376d4964562bcb45 - md5: c0374badb3a5d4b1372db28d19462c53 - depends: - - __glibc >=2.17,<3.0.a0 - - _openmp_mutex >=4.5 - constrains: - - libgomp 15.2.0 h767d61c_7 - - libgcc-ng ==15.2.0=*_7 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL - size: 822552 - timestamp: 1759968052178 -- conda: https://prefix.dev/conda-forge/linux-64/libgomp-15.2.0-h767d61c_7.conda - sha256: e9fb1c258c8e66ee278397b5822692527c5f5786d372fe7a869b900853f3f5ca - md5: f7b4d76975aac7e5d9e6ad13845f92fe - depends: - - __glibc >=2.17,<3.0.a0 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL - size: 447919 - timestamp: 1759967942498 -- conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-15.2.0-h8f9b012_7.conda - sha256: 1b981647d9775e1cdeb2fab0a4dd9cd75a6b0de2963f6c3953dbd712f78334b3 - md5: 5b767048b1b3ee9a954b06f4084f93dc - depends: - - __glibc >=2.17,<3.0.a0 - - libgcc 15.2.0 h767d61c_7 - constrains: - - libstdcxx-ng ==15.2.0=*_7 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL - size: 3898269 - timestamp: 1759968103436 -- conda: build-config - name: out-of-tree-package - version: 0.1.0 - build: hb0f4dca_0 - subdir: linux-64 - depends: - - libstdcxx >=15 - - libgcc >=15 - input: - hash: 616e7d8611fa803e6655c354f183d6f4b405e94adcabc83c260d8b9da5e3c9d8 - globs: [] - package_build_source: - path: ../source-files + - conda: build-config + name: out-of-tree-package + version: 0.0.1 + build: "" + subdir: noarch + variants: + target_platform: noarch + package_build_source: + path: ../source-files diff --git a/tests/data/satisfiability/source-dependency/child-package/pixi.toml b/tests/data/satisfiability/source-dependency/child-package/pixi.toml index a5ebda34b5..0eaf71cf50 100644 --- a/tests/data/satisfiability/source-dependency/child-package/pixi.toml +++ b/tests/data/satisfiability/source-dependency/child-package/pixi.toml @@ -3,6 +3,6 @@ name = "child-package" version = "0.1.0" [package.build] -backend = { name = "pixi-build-cmake", version = "0.3.*" } +backend = { name = "in-memory", version = "*" } # A comment shouldn't change the project model and therefore, shouldn't change the hash diff --git a/tests/data/satisfiability/source-dependency/pixi.lock b/tests/data/satisfiability/source-dependency/pixi.lock index 1d6a13065a..79c7de0433 100644 --- a/tests/data/satisfiability/source-dependency/pixi.lock +++ b/tests/data/satisfiability/source-dependency/pixi.lock @@ -2,76 +2,18 @@ version: 6 environments: default: channels: - - url: https://prefix.dev/pixi-build-backends/ - - url: https://prefix.dev/conda-forge/ + - url: https://prefix.dev/pixi-build-backends/ + - url: https://prefix.dev/conda-forge/ + options: + pypi-prerelease-mode: if-necessary-or-explicit packages: linux-64: - - conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 - - conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 - - conda: https://prefix.dev/conda-forge/linux-64/libgcc-15.1.0-h767d61c_2.conda - - conda: https://prefix.dev/conda-forge/linux-64/libgomp-15.1.0-h767d61c_2.conda - - conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-15.1.0-h8f9b012_2.conda - - conda: child-package + - conda: child-package packages: -- conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 - sha256: fe51de6107f9edc7aa4f786a70f4a883943bc9d39b3bb7307c04c41410990726 - md5: d7c89558ba9fa0495403155b64376d81 - license: None - size: 2562 - timestamp: 1578324546067 -- conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 - build_number: 16 - sha256: fbe2c5e56a653bebb982eda4876a9178aedfc2b545f25d0ce9c4c0b508253d22 - md5: 73aaf86a425cc6e73fcf236a5a46396d - depends: - - _libgcc_mutex 0.1 conda_forge - - libgomp >=7.5.0 - constrains: - - openmp_impl 9999 - license: BSD-3-Clause - license_family: BSD - size: 23621 - timestamp: 1650670423406 -- conda: child-package - name: child-package - version: 0.1.0 - build: hbf21a9e_0 - subdir: linux-64 - depends: - - libstdcxx >=15 - - libgcc >=15 - input: - hash: 25e63e74a216901367b58ef438098792c9516ebd940e2f07d870b38ac24d470e - globs: [] -- conda: https://prefix.dev/conda-forge/linux-64/libgcc-15.1.0-h767d61c_2.conda - sha256: 0024f9ab34c09629621aefd8603ef77bf9d708129b0dd79029e502c39ffc2195 - md5: ea8ac52380885ed41c1baa8f1d6d2b93 - depends: - - __glibc >=2.17,<3.0.a0 - - _openmp_mutex >=4.5 - constrains: - - libgcc-ng ==15.1.0=*_2 - - libgomp 15.1.0 h767d61c_2 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL - size: 829108 - timestamp: 1746642191935 -- conda: https://prefix.dev/conda-forge/linux-64/libgomp-15.1.0-h767d61c_2.conda - sha256: 05fff3dc7e80579bc28de13b511baec281c4343d703c406aefd54389959154fb - md5: fbe7d535ff9d3a168c148e07358cd5b1 - depends: - - __glibc >=2.17,<3.0.a0 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL - size: 452635 - timestamp: 1746642113092 -- conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-15.1.0-h8f9b012_2.conda - sha256: 6ae3d153e78f6069d503d9309f2cac6de5b93d067fc6433160a4c05226a5dad4 - md5: 1cb1c67961f6dd257eae9e9691b341aa - depends: - - __glibc >=2.17,<3.0.a0 - - libgcc 15.1.0 h767d61c_2 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL - size: 3902355 - timestamp: 1746642227493 + - conda: child-package + name: child-package + version: 0.0.1 + build: "" + subdir: noarch + variants: + target_platform: noarch