when: deal with % vs. ^ correctly#51259
Merged
haampie merged 6 commits intospack:developfrom Sep 2, 2025
Merged
Conversation
fixes spack#51248 The value of the "direct" attribute of dependencies is currently lost in "when" context managers. This PR fixes the issue and adds unit tests to prevent regressions Signed-off-by: Massimiliano Culpo <[email protected]>
This commit adds an argument to: * Spec.constrain * Spec.satisfies * Spec.intersects to avoid solving virtuals when performing those operations. This is useful in contexts where a repository is not available. Signed-off-by: Massimiliano Culpo <[email protected]>
Member
|
I think this is more complete than the other, but this cannot be backported because it extends the package api. So, |
Signed-off-by: Massimiliano Culpo <[email protected]>
Signed-off-by: Massimiliano Culpo <[email protected]>
haampie
reviewed
Sep 2, 2025
alalazo
commented
Sep 2, 2025
var/spack/test_repos/spack_repo/builtin_mock/packages/with_constraint_met/package.py
Outdated
Show resolved
Hide resolved
Signed-off-by: Massimiliano Culpo <[email protected]>
Signed-off-by: Massimiliano Culpo <[email protected]>
haampie
approved these changes
Sep 2, 2025
alalazo
added a commit
that referenced
this pull request
Sep 8, 2025
Fixes a bug where `with when("..."):` incorrectly relaxed `%dep` to `^dep`.
Removes the custom and faulty logic in `merge_abstract_anonymous_specs`, in favor of the existing and better tested `Spec.constrain` function, with the subtle different that virtuals are not resolved from configured package repositories. The constrain operation is entirely symbolic.
Signed-off-by: Massimiliano Culpo <[email protected]>
haampie
pushed a commit
that referenced
this pull request
Sep 12, 2025
Fixes a bug where `with when("..."):` incorrectly relaxed `%dep` to `^dep`.
Removes the custom and faulty logic in `merge_abstract_anonymous_specs`, in favor of the existing and better tested `Spec.constrain` function, with the subtle different that virtuals are not resolved from configured package repositories. The constrain operation is entirely symbolic.
Signed-off-by: Massimiliano Culpo <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
builds on #51256
#51256 solves the most common bug in the
whencontext manager, i.e. the case of a single%used in a constraint spec, but doesn't do anything for other, less common, cases where%is treated incorrectly.Here we fix those cases too, by removing the ad-hoc
merge_abstract_anonymous_specsfunction, and usingSpec.constraininstead. To do so we had to:Spec.satisfies,Spec.constrain, andSpec.intersectsin terms a private function with an additional argument, i.e.resolve_virtuals.Spec._constrainwithresolve_virtuals=Falsein the context of evaluating directivesThe PR is separate from #51256 because it involves code changes that touch functions that are widely use, which may be a source of bugs, so we may want to avoid backporting this.
Other changes:
Spec.common_dependencies,Spec.direct_dep_differencehave been removed since they are unused, and are pretty much internal API. They can be deprecated, if that seems better.