Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 96 additions & 85 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ zstd = { version = "0.14.0", default-features = false }
file_url = "0.3.0"
rattler = { version = "0.54", default-features = false }
rattler_cache = { version = "0.10", default-features = false }
rattler_conda_types = { version = "0.56", default-features = false, features = [
rattler_conda_types = { version = "0.57", default-features = false, features = [
"rayon",
] }
rattler_config = { version = "0.9", default-features = false }
Expand All @@ -260,23 +260,23 @@ rattler_redaction = { version = "0.2.2", default-features = false }
rattler_repodata_gateway = { version = "0.36", default-features = false }
rattler_s3 = { version = "0.3", default-features = false }
rattler_shell = { version = "0.29", default-features = false }
rattler_solve = { version = "11.2", default-features = false }
rattler_solve = { version = "11.2.2", default-features = false }
rattler_upload = { version = "0.13", default-features = false, features = [
"s3",
"sigstore-sign",
] }
rattler_virtual_package_detectors = { version = "=0.2.1", default-features = false }
rattler_virtual_package_detectors = { version = "=0.2.3", default-features = false }
rattler_virtual_packages = { version = "8.1", default-features = false }
simple_spawn_blocking = { version = "1.1.0", default-features = false }

# Rattler build crates
rattler_build_core = { version = "0.2.18", default-features = false, features = [
rattler_build_core = { version = "0.2.19", default-features = false, features = [
"s3",
] }
rattler_build_jinja = { version = "0.1.19" }
rattler_build_recipe = { version = "0.1.19" }
rattler_build_types = { version = "0.1.17" }
rattler_build_variant_config = { version = "0.1.19" }
rattler_build_jinja = { version = "0.1.20" }
rattler_build_recipe = { version = "0.1.20" }
rattler_build_types = { version = "0.1.18" }
rattler_build_variant_config = { version = "0.1.20" }

[patch.crates-io]
version-ranges = { git = "https://github.com/astral-sh/pubgrub", rev = "d8efd77673c9a90792da9da31b6c0da7ea8a324b" }
Expand Down
4 changes: 2 additions & 2 deletions crates/pixi/tests/integration_rust/install_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2380,7 +2380,7 @@ cuda-arch = "*"
.map(|record| record.build.clone())
.unwrap_or_else(|| panic!("cuda-arch should be locked for {platform_name}"));
assert!(
build.starts_with(expected_build),
build.as_str().starts_with(expected_build),
"{platform_name} resolved cuda-arch build {build}, expected {expected_build}"
);
}
Expand Down Expand Up @@ -2434,7 +2434,7 @@ amdgpu-arch = "*"
.map(|record| record.build.clone())
.unwrap_or_else(|| panic!("amdgpu-arch should be locked for {platform_name}"));
assert!(
build.starts_with(expected_build),
build.as_str().starts_with(expected_build),
"{platform_name} resolved amdgpu-arch build {build}, expected {expected_build}"
);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/pixi/tests/integration_rust/source_package_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4334,7 +4334,7 @@ host-lib = "*"
insta::assert_yaml_snapshot!(index_json, {
".subdir" => "[SUBDIR]",
}, @r###"
build: ""
build: "0"
build_number: 0
depends:
- "host-lib >=2.5,<3.0a0"
Expand Down
2 changes: 1 addition & 1 deletion crates/pixi_api/src/workspace/list/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl Package {
let kind = PackageKind::from(package);

let build = match package {
PackageExt::Conda(pkg) => pkg.record().map(|r| r.build.clone()),
PackageExt::Conda(pkg) => pkg.record().map(|r| r.build.to_string()),
PackageExt::PyPI(_, _) => None,
};

Expand Down
2 changes: 1 addition & 1 deletion crates/pixi_build_backend/src/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ pub fn apply_variant(

let pinned = pin
.pin_compatible
.apply(&pin_package.version, &pin_package.build)?;
.apply(&pin_package.version, pin_package.build.as_str())?;
Ok(PinCompatibleDependency {
spec: pinned,
name: name.as_normalized().to_string(),
Expand Down
18 changes: 16 additions & 2 deletions crates/pixi_build_backend/src/intermediate_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ use rattler_build_types::NormalizedKey;
use rattler_build_variant_config::VariantConfig;
use rattler_conda_types::NoArchType;
use rattler_conda_types::{
RepodataRevision, Subdir, compression_level::CompressionLevel, package::CondaArchiveType,
RepodataRevision, Subdir,
compression_level::CompressionLevel,
package::{BuildString, CondaArchiveType},
};

use serde::Deserialize;
Expand Down Expand Up @@ -479,11 +481,23 @@ where

let noarch = recipe.build().noarch.unwrap_or(NoArchType::none());

let build_string = discovered_output
.build_string
.parse::<BuildString>()
.into_diagnostic()
.with_context(|| {
format!(
"invalid build string '{}' for output '{}'",
discovered_output.build_string,
recipe.package().name().as_source()
)
})?;

outputs.push(CondaOutput {
metadata: CondaOutputMetadata {
name: recipe.package().name().clone(),
version: recipe.package().version().clone(),
build: discovered_output.build_string.clone(),
build: build_string,
build_number,
subdir: discovered_output.target_platform,
license: recipe.about.license.clone().map(|l| l.to_string()),
Expand Down
2 changes: 1 addition & 1 deletion crates/pixi_build_backend/tests/integration/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ async fn test_conda_outputs_build_string_prefix() {
);
// Default build string should contain a hash (starts with 'h')
assert!(
default_build.contains('h'),
default_build.as_str().contains('h'),
"default build string should contain a hash, got: {default_build}"
);

Expand Down
36 changes: 22 additions & 14 deletions crates/pixi_build_backend_passthrough/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use pixi_build_types::{
};
use rattler_conda_types::{
PackageName, Subdir, Version, VersionSpec,
package::{IndexJson, PathType, PathsEntry, PathsJson, RunExportsJson},
package::{BuildString, IndexJson, PathType, PathsEntry, PathsJson, RunExportsJson},
};
use serde::Deserialize;

Expand Down Expand Up @@ -226,7 +226,7 @@ impl InMemoryBackend for PassthroughBackend {
input_glob_sets: None,
name: self.index_json.name.as_normalized().to_owned(),
version: self.index_json.version.clone(),
build: build_string,
build: build_string.to_string(),
subdir,
})
}
Expand Down Expand Up @@ -492,19 +492,24 @@ fn generate_variant_combinations(
/// the build string is augmented with a hash of the variant to ensure unique
/// package identities.
fn compute_build_string(
base_build: &str,
base_build: &BuildString,
variant: &BTreeMap<String, VariantValue>,
has_real_variants: bool,
) -> String {
) -> BuildString {
if !has_real_variants {
base_build.to_string()
return base_build.clone();
}
let variant_hash = compute_variant_hash(variant);
if base_build.is_empty() {
variant_hash
.parse()
.expect("a hex hash is a valid build string")
} else {
let variant_hash = compute_variant_hash(variant);
if base_build.is_empty() {
variant_hash
} else {
format!("{base_build}_{variant_hash}")
}
let mut build = base_build.clone();
build
.append(format!("_{variant_hash}"))
.expect("index.json build string with variant hash is a valid build string");
build
}
}

Expand Down Expand Up @@ -639,8 +644,11 @@ fn create_output(
// source dependencies are emitted as source specs, mirroring real
// backends' `local_source_packages` mapping.
run_exports: {
let mut run_exports =
model_run_exports(&project_model.targets, &output_version, &output_build);
let mut run_exports = model_run_exports(
&project_model.targets,
&output_version,
output_build.as_str(),
);
if let Some(extra) = package_run_exports
.or_else(|| run_exports_config.get(name.as_source()))
.map(|re| convert_run_exports_json(re, &model_source_specs(&project_model.targets)))
Expand Down Expand Up @@ -1102,7 +1110,7 @@ impl InMemoryBackendInstantiator for PassthroughBackendInstantiator {
// Create IndexJson from project model for on-the-fly package generation
let index_json = IndexJson {
arch: None,
build: String::new(),
build: BuildString::new_unchecked("0"),
build_number: 0,
constrains: vec![],
depends: vec![],
Expand Down
18 changes: 16 additions & 2 deletions crates/pixi_build_rattler_build/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ use rattler_build_recipe::{stage1::Source as RecipeSource, variant_render::Rende
use rattler_build_variant_config::VariantConfig;
use rattler_conda_types::NoArchType;
use rattler_conda_types::{
RepodataRevision, Subdir, compression_level::CompressionLevel, package::CondaArchiveType,
RepodataRevision, Subdir,
compression_level::CompressionLevel,
package::{BuildString, CondaArchiveType},
};
use tracing::warn;
pub struct RattlerBuildBackendInstantiator {
Expand Down Expand Up @@ -189,11 +191,23 @@ impl Protocol for RattlerBuildBackend {
let noarch = build.noarch.unwrap_or(NoArchType::none());
let python_site_packages_path = build.python.site_packages_path.clone();

let build_string = discovered_output
.build_string
.parse::<BuildString>()
.into_diagnostic()
.with_context(|| {
format!(
"invalid build string '{}' for output '{}'",
discovered_output.build_string,
recipe.package().name().as_source()
)
})?;

outputs.push(CondaOutput {
metadata: CondaOutputMetadata {
name: recipe.package().name().clone(),
version: recipe.package().version().clone(),
build: discovered_output.build_string.clone(),
build: build_string,
build_number,
subdir: discovered_output.target_platform,
license: recipe.about.license.clone().map(|l| l.to_string()),
Expand Down
11 changes: 8 additions & 3 deletions crates/pixi_build_types/src/procedures/conda_outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
use std::{collections::BTreeMap, path::PathBuf};

use ordermap::OrderSet;
use rattler_conda_types::{ChannelUrl, Flag, NoArchType, PackageName, Subdir, VersionWithSource};
use rattler_conda_types::{
ChannelUrl, Flag, NoArchType, PackageName, Subdir, VersionWithSource, package::BuildString,
};
use serde::{Deserialize, Serialize};
use serde_with::serde_as;

Expand Down Expand Up @@ -153,8 +155,11 @@ pub struct CondaOutputMetadata {
/// The version of the package.
pub version: VersionWithSource,

/// The build hash of the package.
pub build: String,
/// The build string of the package.
///
/// Like rattler's own records, deserializing does not validate the value
/// against CEP26; pixi validates it when the backend reply comes in.
pub build: BuildString,
Comment thread
lucascolley marked this conversation as resolved.
Resolved

/// The build number of the package.
pub build_number: u64,
Expand Down
6 changes: 2 additions & 4 deletions crates/pixi_cli/src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,8 @@ fn parse_specs(
{
// If the build contains a wildcard, keep it
nameless_match_spec.build = match nameless_match_spec.build {
Some(build @ StringMatcher::Glob(_) | build @ StringMatcher::Regex(_)) => {
Some(build)
}
_ => None,
Some(StringMatcher::Exact(_)) | None => None,
build => build,
};
nameless_match_spec.build_number = None;
nameless_match_spec.md5 = None;
Expand Down
28 changes: 18 additions & 10 deletions crates/pixi_cli/src/workspace/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use pixi_manifest::{
},
};
use rattler_conda_types::{
GenericVirtualPackage, PackageName, Subdir, Version,
GenericVirtualPackage, PackageName, Subdir, Version, package::BuildString,
virtual_package_detector::VirtualPackageName,
};

Expand Down Expand Up @@ -143,7 +143,7 @@ impl VirtualPackageArgs {
GenericVirtualPackage {
name: virtual_package_name("__amdgpu"),
version: zero_version(),
build_string: String::new(),
build_string: BuildString::new_unchecked("0"),
},
)?;
}
Expand All @@ -156,23 +156,23 @@ impl VirtualPackageArgs {
GenericVirtualPackage {
name: virtual_package_name("__amdgpu_arch"),
version,
build_string: String::new(),
build_string: BuildString::new_unchecked("0"),
},
)?;
}
if let Some(value) = self.archspec {
if value.is_empty() {
miette::bail!("--archspec requires a non-empty microarchitecture string");
}
pixi_manifest::platform::validate_archspec_name(&value)
let build_string = pixi_manifest::platform::parse_archspec_build_string(&value)
.map_err(|message| miette::miette!("{message}"))?;
push_unique(
&mut specs,
&mut seen_names,
GenericVirtualPackage {
name: virtual_package_name("__archspec"),
version: zero_version(),
build_string: value,
build_string,
},
)?;
}
Expand Down Expand Up @@ -1414,7 +1414,10 @@ mod tests {
..Default::default()
};
let specs = args.into_specs(Subdir::Linux64, &[]).unwrap();
let rendered: Vec<String> = specs.iter().map(ToString::to_string).collect();
let rendered: Vec<String> = specs
.iter()
.map(pixi_manifest::platform::format_virtual_package)
.collect();
assert_eq!(rendered, ["__cuda=12.0=h1", "__glibc=2.28"]);

let args = VirtualPackageArgs {
Expand All @@ -1430,17 +1433,22 @@ mod tests {
}

#[test]
fn parse_raw_virtual_package_keeps_trailing_segments_in_build_string() {
let package = parse_raw_virtual_package("__foo=1=special=build").unwrap();
assert_eq!(package.build_string, "special=build");
fn parse_raw_virtual_package_rejects_invalid_build_strings() {
for spec in ["__foo=1=special=build", "__foo=1=a-b", "__foo=1="] {
let error = parse_raw_virtual_package(spec).unwrap_err();
assert!(
error.to_string().contains("build string"),
"{spec}: {error}"
);
}
}

#[test]
fn parse_raw_virtual_package_defaults_omitted_version() {
let package = parse_raw_virtual_package("__site_service").unwrap();
assert_eq!(package.name.as_normalized(), "__site_service");
assert_eq!(package.version.to_string(), "0");
assert!(package.build_string.is_empty());
assert_eq!(package.build_string, "0");
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/pixi_command_dispatcher/src/build/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ mod tests {
let mut pr = PackageRecord::new(
PackageName::from_str(name).unwrap(),
VersionWithSource::from_str(version).unwrap(),
"h0".into(),
"h0".parse().unwrap(),
);
pr.subdir = "linux-64".into();
pr.run_exports = Some(run_exports);
Expand Down
4 changes: 2 additions & 2 deletions crates/pixi_command_dispatcher/src/build/pin_compatible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn resolve_pin_compatible(
let pin = Pin::try_from(spec.clone())?;
Ok(pin.resolve(
&record.package_record().version,
&record.package_record().build,
record.package_record().build.as_str(),
)?)
}

Expand Down Expand Up @@ -92,7 +92,7 @@ mod tests {
let mut pr = PackageRecord::new(
pkg_name,
VersionWithSource::from_str(version).expect("valid version"),
build.to_string(),
build.parse().unwrap(),
);
pr.subdir = "linux-64".into();
let file_name = format!("{name}-{version}-{build}.conda");
Expand Down
Loading
Loading