-
Notifications
You must be signed in to change notification settings - Fork 697
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
default-package-bounds
(RFC #9569) implementation
#9570
base: master
Are you sure you want to change the base?
default-package-bounds
(RFC #9569) implementation
#9570
Conversation
af6272b
to
f201573
Compare
|
EDIT: 2 works out of the box. Constraining either |
For 1. it would be unclear what we would be parsing in the |
f201573
to
4472cac
Compare
I don't know, it just seems like I would expect this to work:
From a user perspective it looks just the same as |
just to reiterate that I continue to be excited about this feature :) |
Sounds reasonable but how do I disambiguate when parsing? I could create a new |
I don't actually know enough about cabal to say anything useful 😅 |
I have a proposal, what about default-package-bounds:
foo >2
, bar:exebar >3
library ...
build-depends:
foo:sublib -- will get >2 from `foo >2` in package bounds The concept of |
I could parse the following bounds: data DefaultBounds = DefaultBound ShortText VersionRange
| DefaultExeBound PackageName UnqualComponentName VersionRange -- same as ExeDependency And then apply the |
c79b2b7
to
7a8433e
Compare
How does this look @michaelpj: cabal-version: 3.12
name: foo
version: 0.1.0.0
default-package-bounds:
, time <0
, libpkgconf <0
, bar:bar <0
flag build-depends-conflict
manual: True
default: False
description: cause conflict
flag pkg-config-conflict
manual: True
default: False
description: cause conflict
flag build-tool-conflict
manual: True
default: False
description: cause conflict
library
default-language: Haskell2010
if flag(build-depends-conflict)
build-depends: time
else
build-depends: time >0
if flag(pkg-config-conflict)
pkgconfig-depends: libpkgconf
else
pkgconfig-depends: libpkgconf >0
if flag(build-tool-conflict)
build-tool-depends: bar:bar
else
build-tool-depends: bar:bar >0 Note that the bounds are used here to make the compilation fail, to easily see that they are applied. And they only come to play if the specific cabal flag is enabled for the conflict. This is the test-case from the test I added. So now it would apply to all |
That looks nice to me! I didn't know that |
No, constraints hold these:
So it is only for Haskell package constraints |
However I just realized that you never asked for a way to provide default bounds for the pkgconfig libraries 😅 Maybe this should only apply to |
I guess the intuition I want users to have is "this is a bit like what goes in |
Ok I removed the pkgconfig-depends altering via default-package-bounds |
Following up on the discussion on the Cabal meeting. @gbaz: In this comment you seem to agree to doing this on the solver (or at least say that it seems maybe reasonable) and @andreabedini's concern about being faithful to what is written there sounds reasonable. Anyways, lets revisit whether the way this is implemented looks right or not. @gbaz raised the point that any cabal-file-consumer that used to parse the dependency bounds from the files no longer would be able to do so. |
Hrm. The trick I suppose is that we can't resolve the conditionals prior to the solver, because it will use them in backtracking. But we do need these bounds handled in the solver. So the solution seems to be that at the same step we "unpack" the conditionals into a flat list of possible dependencies, we also resolve this. And that's sensical. However, we have the issue that end-users still won't see the fully resolved deplist with bounds. What I would suggest is then that just as the solver was modified to handle this sugar at the same time as the conditionals, we also modify our standard conditional resolving things the same way. In particular, we change the finalizePD and flatten functions to also apply the default-package-bounds? |
This PR currently applies the default bounds during the conversion to the solver's index format at the start of solving, in Another part of the ordering to consider is |
As I said in the meeting, @andreabedini mentioned in ZuriHac that "this will not work with Setup.hs". What did you mean exactly with that Andrea? I have never had to use Also @grayjay mentioned (unless I misunderstood) in the meeting that this should probably be moved to Cabal-the-library. If you point me to a specific place I will be happy to explore it and try to move it there. |
@jasagredo I think @andreabedini raises a good point. By
then will the default bounds apply? It sounded like in our conversation yesterday that the default bounds are only applied in the solver which is too late for this to work. Given they are working locally to a package it seems that modifying the bounds in Does that make sense? |
Where can I read how |
You still use this interface when installing system-wide or for a system package manager, as opposed to cabal-install or stack or some other build tool that manages its own package store. Additionally, |
So where's the point where this comes apart from normal |
These bounds are applied in the solver. However I don't seem to understand why |
The solver is part of |
See functions like |
Is there a separate source tree used for Setup or is it intertwined with cabal code? Or does Setup only use Cabal and not cabal, and therefore I should find somewhere in Cabal to put this? |
|
@jasagredo I need to keep my promise! I'll reach out to you in private. |
15970d8
to
ab1c14a
Compare
ab1c14a
to
8633f93
Compare
I have revamped this PR after talking to @andreabedini (thanks!!) this morning. It is now a section. See the updated documentation. https://cabal--9570.org.readthedocs.build/en/9570/cabal-package-description-file.html#default-package-bounds It now works also for |
ef0e28a
to
d1fb218
Compare
d1fb218
to
0f17eff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also @grayjay mentioned (unless I misunderstood) in the meeting that this should probably be moved to Cabal-the-library. If you point me to a specific place I will be happy to explore it and try to move it there.
I meant that the functionality to apply default bounds should be in Cabal (or Cabal-syntax) so that it can be used by Setup.hs, but it looks like the latest version of the code does that.
I didn't review the whole PR, but I have a few more comments from the code that I read while checking that.
Cabal-syntax/src/Distribution/Types/GenericPackageDescription.hs
Outdated
Show resolved
Hide resolved
Cabal-syntax/src/Distribution/PackageDescription/Configuration.hs
Outdated
Show resolved
Hide resolved
Co-authored-by: Kristen Kozak <[email protected]>
d9a7ad6
to
12b23db
Compare
12b23db
to
d1d698a
Compare
Solves #8912 #9569
Docs: https://cabal--9570.org.readthedocs.build/en/9570/cabal-package-description-file.html#default-package-bounds
Manual QA
By adding a field
default-package-bounds
in a cabal file and a list of dependencies with version ranges, for each of those dependencies, any dependency declaration that was unbounded will be set to the one ondefault-package-bounds
:Should be understood as:
If the stanza is omitted, then nothing changes wrt previous version.
Notice this should not influence:
pkgconfig-depends