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
1 change: 1 addition & 0 deletions changelog.d/+solve-versionsuffix.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`package bump` and `package plan` keep a dependency's stated versionsuffix when the robot tree has a build with it that the solve can take: `('HDF5', '1.14.2', '-mpi')` and `('HDF5', '1.14.2', '')` no longer become the `-serial` build because that one ranks higher. The solve takes another suffix only when the target has no build with the stated one, as when `-CUDA-12.9.1` moves to `-CUDA-13.3.0` across a generation.
7 changes: 7 additions & 0 deletions docs/orgmode/howto/bump-recipe.org
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ target toolchain hierarchy from the robot tree, and asks Resolvo for a jointly
feasible dependency selection. Existing robot artifacts keep independent
build-tool scopes, matching EasyBuild's installed-module model.

A dependency's versionsuffix, as in ~('HDF5', '1.14.2', '-mpi')~, holds
wherever the robot tree has a build with that suffix the solve can take,
so the bump does not trade ~-mpi~ for ~-serial~. Only when the target has
no such build does the solve take another suffix: a library's
~-CUDA-12.9.1~ build becomes its ~-CUDA-13.3.0~ build when the target
generation carries only that one.

The output is:

#+begin_src text
Expand Down
7 changes: 7 additions & 0 deletions llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2439,6 +2439,13 @@ target toolchain hierarchy from the robot tree, and asks Resolvo for a jointly
feasible dependency selection. Existing robot artifacts keep independent
build-tool scopes, matching EasyBuild's installed-module model.

A dependency's versionsuffix, as in `('HDF5', '1.14.2', '-mpi')`, holds
wherever the robot tree has a build with that suffix the solve can take,
so the bump does not trade `-mpi` for `-serial`. Only when the target has
no such build does the solve take another suffix: a library's
`-CUDA-12.9.1` build becomes its `-CUDA-13.3.0` build when the target
generation carries only that one.

The output is:

```text
Expand Down
25 changes: 24 additions & 1 deletion src/package_solve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ pub fn solve_package_profile_with_hierarchy(
let requirement = DepReq {
name: name.clone(),
version_req: normalize_requirement(dependency.constraint.as_deref()),
versionsuffix: None,
versionsuffix: dependency.versionsuffix.clone(),
toolchain: dependency.toolchain.clone(),
};
if build_only {
Expand Down Expand Up @@ -338,6 +338,29 @@ pub fn solve_package_profile_with_hierarchy(
}
}
scope_cross_generation_pin_closures(&mut universe, stack_policy, &hierarchy);
// A stated versionsuffix holds wherever a build the solve can take
// carries it: `-mpi` is not traded for `-serial`. Across a generation it
// may name a version that moved instead, and `-CUDA-12.9.1` then takes
// the `-CUDA-13.3.0` build when the target carries only that one.
for requirement in runtime_dependencies
.iter_mut()
.chain(build_dependencies.iter_mut())
{
let carried = requirement.versionsuffix.as_deref().is_some_and(|wanted| {
universe.iter().any(|candidate| {
package_identities_match(&candidate.name, &requirement.name)
&& candidate.versionsuffix.as_deref().unwrap_or("") == wanted
&& candidate_matches_any_spelling(candidate, &requirement.version_req)
&& requirement
.toolchain
.as_ref()
.is_none_or(|toolchain| toolchains_match(&candidate.toolchain, toolchain))
})
});
if !carried {
requirement.versionsuffix = None;
}
}
universe.push(Candidate {
easyblock: None,
name: synthetic_name.clone(),
Expand Down
96 changes: 96 additions & 0 deletions tests/bump_workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,102 @@ fn a_system_dependency_named_by_the_versionsuffix_moves_with_the_generation() {
);
}

/// `-serial` ranks above the plain build and `-mpi`, so a solve that drops
/// the stated suffix takes it.
#[test]
fn a_bump_keeps_the_stated_versionsuffix_variant() {
let temp = tempfile::tempdir().expect("tempdir");
let robot = temp.path().join("robot");
fs::create_dir_all(&robot).expect("robot directory");
fs::write(
robot.join("GCCcore-15.2.0.eb"),
"easyblock = 'Toolchain'\nname = 'GCCcore'\nversion = '15.2.0'\n\
homepage = 'https://example.invalid/'\ndescription = 'compiler'\n\
toolchain = SYSTEM\nsources = []\nchecksums = []\nmoduleclass = 'compiler'\n",
)
.expect("GCCcore candidate");
for suffix in ["", "-mpi", "-serial"] {
fs::write(
robot.join(format!("HDF5-1.14.2-GCCcore-15.2.0{suffix}.eb")),
format!(
"easyblock = 'ConfigureMake'\nname = 'HDF5'\nversion = '1.14.2'\n\
versionsuffix = '{suffix}'\n\
homepage = 'https://example.invalid/'\ndescription = 'HDF5'\n\
toolchain = {{'name': 'GCCcore', 'version': '15.2.0'}}\n\
sources = []\nchecksums = []\nmoduleclass = 'data'\n"
),
)
.expect("HDF5 candidate");
}
let toolchain = Toolchain {
name: "GCCcore".into(),
version: "15.2.0".into(),
};
for (stated, selected) in [("-mpi", "-mpi"), ("", "")] {
let source = temp
.path()
.join(format!("Alpha-1.0-GCCcore-15.2.0{stated}.eb"));
fs::write(
&source,
format!(
"easyblock = 'ConfigureMake'\nname = 'Alpha'\nversion = '1.0'\n\
versionsuffix = '{stated}'\n\
homepage = 'https://example.invalid/'\ndescription = 'Synthetic package'\n\
toolchain = {{'name': 'GCCcore', 'version': '15.2.0'}}\n\
sources = ['alpha-1.0.tar.gz']\n\
checksums = ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']\n\
dependencies = [('HDF5', '1.14.2', '{stated}')]\n\
moduleclass = 'tools'\n"
),
)
.expect("source recipe");
let bundle = plan_package_bump(&BumpPackageRequest {
source,
toolchain: toolchain.clone(),
version: None,
source_checksum: None,
easyconfig_roots: vec![robot.clone()],
hierarchy_fixture: None,
overrides: HashMap::new(),
stack_policy: StackPolicy {
schema_version: STACK_POLICY_SCHEMA_VERSION,
name: "default".into(),
toolchain: toolchain.clone(),
pins: Vec::new(),
exclusions: Vec::new(),
},
strict_patches: false,
package_layers: Vec::new(),
foreign_sources: Vec::new(),
})
.expect("the bump solves");
let hdf5 = bundle.locks[0]
.dependencies
.iter()
.find(|dependency| dependency.name == "HDF5")
.expect("HDF5 is locked");
assert_eq!(
hdf5.easyconfig_path,
robot
.join(format!("HDF5-1.14.2-GCCcore-15.2.0{selected}.eb"))
.display()
.to_string(),
"stated suffix {stated:?}"
);
let recipe =
resolve_easyconfig_str(&bundle.easyconfigs[0].text).expect("parse bumped recipe");
assert_eq!(
recipe.dependencies[0]
.versionsuffix
.as_deref()
.unwrap_or(""),
selected,
"{}",
bundle.easyconfigs[0].text
);
}
}

#[test]
fn a_patch_an_extension_names_travels_with_the_bundle() {
let temp = tempfile::tempdir().expect("tempdir");
Expand Down
43 changes: 43 additions & 0 deletions tests/profile_emission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,49 @@ fn profile_solver_matches_unmapped_foreign_names_to_robot_candidates() {
assert_eq!(lock.dependencies[0].name, "SomeLib");
}

/// The suffix asked for ranks between the other two, so the lock holds it
/// only when the solve requires it.
#[test]
fn a_dependency_versionsuffix_selects_that_variant() {
let recipe = parse_foreign_path(&fixture(), Some(ForeignFormat::Spack)).expect("parse");
let mut plan = package_plan_from_foreign(&recipe, &toolchain());
plan.profiles = qmcpack_profiles();
plan.dependencies
.retain(|dependency| dependency.name == "hdf5");
plan.dependencies[0].versionsuffix = Some("-mpi".into());
let variant = |suffix: &str| Candidate {
versionsuffix: Some(suffix.into()),
easyconfig_path: format!("HDF5-1.14.2-foss-2026.1{suffix}.eb"),
..hdf5_candidate("1.14.2")
};
let stack = StackPolicy {
schema_version: STACK_POLICY_SCHEMA_VERSION,
name: "test".into(),
toolchain: toolchain(),
pins: Vec::new(),
exclusions: Vec::new(),
};

let lock = solve_package_profile(
&plan,
"default",
&ProfileEnvironment::default(),
&[
hdf5_candidate("1.14.2"),
variant("-mpi"),
variant("-serial"),
],
&stack,
)
.expect("profile solve");
assert_eq!(lock.dependencies.len(), 1);
assert_eq!(lock.dependencies[0].versionsuffix.as_deref(), Some("-mpi"));
assert_eq!(
lock.dependencies[0].easyconfig_path,
"HDF5-1.14.2-foss-2026.1-mpi.eb"
);
}

#[test]
fn foreign_build_roles_create_easybuild_builddependencies() {
let recipe = parse_foreign_path(&fixture(), Some(ForeignFormat::Spack)).expect("parse");
Expand Down
Loading