-
Notifications
You must be signed in to change notification settings - Fork 696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enforce qualified constraints in the dependency solver. #4257
Conversation
93e42ff
to
df67466
Compare
Since the release is coming up, I wanted to figure out what changes relating to qualified constraints we should include. I can see three options that wouldn't take long to implement:
I prefer 1 and 3, because I don't want to take away the ability to constrain any dependency. |
+1 from me. If we can implement 3 in time, then let's go with 3, otherwise we can postpone merging this PR. |
OK, I'm going to mark this as action-required for now. @grayjay, are you on point for (3)? |
Yes, I'll try to implement (3) this weekend. I'll add it to this PR. |
This commit changes the meaning of constraints like 'pkg > 5'. Previously, 'pkg > 5' only applied to the top-level 'pkg' goal without a 'Namespace', but now it applies to any top-level goal for 'pkg'. However, the 'Namespace' field is currently only used by --independent-goals, so this change has no effect on behavior.
I used the new constraint scope to enforce the minimum Cabal version in setup scripts that lack a 'custom-setup' stanza. It isn't exposed to users yet.
…dency graph. For example, --constraint="any.pkg == 5" applies to "pkg" whether it is a top-level dependency, setup dependency, or build tool dependency. I also modified the UserConstraint type so that it is more similar to the PackageConstraint type, now that both types need to express similar "constraint scopes".
For example, "setup.Cabal installed" forces cabal to use the installed Cabal library for all setup scripts.
df67466
to
ff4c548
Compare
I exposed the constraints that apply to all dependencies, as well as constraints that only apply to setup dependencies. The current syntax is:
|
@grayjay this looks great! edit Er nope, because lib dependencies cannot be constrained, unless we get full private lib dependencies. By that point, I think we'll have full component-base solving too. |
@Ericson2314 Thanks for reviewing the syntax. Maybe we should reserve the package names "any" and "setup" to allow more flexibility for future changes to constraint syntax. |
@grayjay well I'm thinking we can use my arrow notation with * and ** wildcards which can express everything, and then we won't need anything behind what we currently have as short-hands. If we can reserve package names at this point, that's cool, though. |
I went ahead and merged this. Hopefully we can reserve any/setup in the near future; I don't actually know how to go about doing this. |
Someone who's familiar with |
Thanks!
I'm not sure I understand. Are you suggesting using asterisks instead? Then we would have something like |
@grayjay err nah I wasn't trying to subtly imply that :). I was thinking if all single constraint path edges can be written
|
Great! |
Thanks! |
This PR is a continuation of #4236. I made two changes to
ConstraintScope
before enforcing the constraints in the solver:Namespace
from theScopeQualified
constructor. This change doesn't affect the behavior of the solver, because we currently don't useNamespace
anywhere.ScopeAnySetupQualifier
constructor to allow constraints to apply to all setup scripts. The new constructor is only used internally in this PR.This PR also adds dependencies with version ranges to the solver DSL. I ended up not needing the version ranges for these unit tests, but I left them because I think they could be useful.
/cc @robjhen @kosmikus
EDIT:
/cc @dcoutts @23Skidoo @ezyang @Ericson2314 @hvr @phadej
Here is a summary of the changes, from the changelog:
--constraint="setup.bar == 1.0" constrains all setup dependencies on
bar, and --constraint="foo:setup.bar == 1.0" constrains foo's setup
dependency on bar (part of Constraint syntax is not expressive enough. #3502).
only apply to top-level dependencies. They don't constrain setup or
build-tool dependencies. The new syntax --constraint="any.bar == 1.0"
constrains all uses of bar.