-
Notifications
You must be signed in to change notification settings - Fork 710
Consistently use the Cabal version picked by the dependency solver. #3723
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
77fb0b9
Consistently use the Cabal version picked by the dependency solver.
grayjay 9ec4028
Test for issue #3436.
grayjay 4eb8e4f
Test configuring a package with a custom-setup that doesn't include C…
grayjay a94764e
Document choosing the Cabal version for a setup script.
grayjay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
8 changes: 8 additions & 0 deletions
8
cabal-install/tests/IntegrationTests/custom-setup/Cabal-99998/Cabal.cabal
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: Cabal | ||
version: 99998 | ||
build-type: Simple | ||
cabal-version: >= 1.2 | ||
|
||
library | ||
build-depends: base | ||
exposed-modules: CabalMessage |
3 changes: 3 additions & 0 deletions
3
cabal-install/tests/IntegrationTests/custom-setup/Cabal-99998/CabalMessage.hs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module CabalMessage where | ||
|
||
message = "This is Cabal-99998" |
8 changes: 8 additions & 0 deletions
8
cabal-install/tests/IntegrationTests/custom-setup/Cabal-99999/Cabal.cabal
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: Cabal | ||
version: 99999 | ||
build-type: Simple | ||
cabal-version: >= 1.2 | ||
|
||
library | ||
build-depends: base | ||
exposed-modules: CabalMessage |
3 changes: 3 additions & 0 deletions
3
cabal-install/tests/IntegrationTests/custom-setup/Cabal-99999/CabalMessage.hs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module CabalMessage where | ||
|
||
message = "This is Cabal-99999" |
3 changes: 3 additions & 0 deletions
3
...stall/tests/IntegrationTests/custom-setup/custom-setup-without-cabal-defaultMain/Setup.hs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Distribution.Simple | ||
|
||
main = defaultMain |
9 changes: 9 additions & 0 deletions
9
...setup/custom-setup-without-cabal-defaultMain/custom-setup-without-cabal-defaultMain.cabal
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: custom-setup-without-cabal-defaultMain | ||
version: 1.0 | ||
build-type: Custom | ||
cabal-version: >= 1.2 | ||
|
||
custom-setup | ||
setup-depends: base | ||
|
||
library |
4 changes: 4 additions & 0 deletions
4
cabal-install/tests/IntegrationTests/custom-setup/custom-setup-without-cabal/Setup.hs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import System.Exit | ||
import System.IO | ||
|
||
main = hPutStrLn stderr "My custom Setup" >> exitFailure |
9 changes: 9 additions & 0 deletions
9
...IntegrationTests/custom-setup/custom-setup-without-cabal/custom-setup-without-cabal.cabal
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: custom-setup-without-cabal | ||
version: 1.0 | ||
build-type: Custom | ||
cabal-version: >= 99999 | ||
|
||
custom-setup | ||
setup-depends: base | ||
|
||
library |
5 changes: 5 additions & 0 deletions
5
cabal-install/tests/IntegrationTests/custom-setup/custom-setup/Setup.hs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import CabalMessage (message) | ||
import System.Exit | ||
import System.IO | ||
|
||
main = hPutStrLn stderr message >> exitFailure |
9 changes: 9 additions & 0 deletions
9
cabal-install/tests/IntegrationTests/custom-setup/custom-setup/custom-setup.cabal
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: custom-setup | ||
version: 1.0 | ||
build-type: Custom | ||
cabal-version: >= 99999 | ||
|
||
custom-setup | ||
setup-depends: base, Cabal >= 99999 | ||
|
||
library |
12 changes: 12 additions & 0 deletions
12
...sts/IntegrationTests/custom-setup/custom_setup_without_Cabal_doesnt_allow_Cabal_import.sh
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
. ./common.sh | ||
cd custom-setup-without-cabal-defaultMain | ||
|
||
# This package has explicit setup dependencies that do not include Cabal. | ||
# Compilation should fail because Setup.hs imports Distribution.Simple. | ||
! cabal new-build custom-setup-without-cabal-defaultMain > output 2>&1 | ||
cat output | ||
grep -q "\(Could not find module\|Failed to load interface for\).*Distribution\\.Simple" output \ | ||
|| die "Should not have been able to import Cabal" | ||
|
||
grep -q "It is a member of the hidden package .*Cabal-" output \ | ||
|| die "Cabal should be available" |
11 changes: 11 additions & 0 deletions
11
...ll/tests/IntegrationTests/custom-setup/custom_setup_without_Cabal_doesnt_require_Cabal.sh
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
. ./common.sh | ||
cd custom-setup-without-cabal | ||
|
||
# This package has explicit setup dependencies that do not include Cabal. | ||
# new-build should try to build it, even though the cabal-version cannot be | ||
# satisfied by an installed version of Cabal (cabal-version: >= 99999). However, | ||
# configure should fail because Setup.hs just prints an error message and exits. | ||
! cabal new-build custom-setup-without-cabal > output 2>&1 | ||
cat output | ||
grep -q "My custom Setup" output \ | ||
|| die "Expected output from custom Setup" |
15 changes: 15 additions & 0 deletions
15
cabal-install/tests/IntegrationTests/custom-setup/installs_Cabal_as_setup_dep.sh
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Regression test for issue #3436 | ||
|
||
. ./common.sh | ||
cabal sandbox init | ||
cabal install ./Cabal-99998 | ||
cabal sandbox add-source Cabal-99999 | ||
|
||
# Install custom-setup, which has a setup dependency on Cabal-99999. | ||
# cabal should build the setup script with Cabal-99999, but then | ||
# configure should fail because Setup just prints an error message | ||
# imported from Cabal and exits. | ||
! cabal install custom-setup/ > output 2>&1 | ||
|
||
cat output | ||
grep -q "This is Cabal-99999" output || die "Expected output from Cabal-99999" |
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.
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.
I'd appreciate a comment laying out the logic here, and a reference to the issues that arise when you don't do it correctly. (Yes you can blame, but right now it's not even obvious something nontrivial is going on here.)
Uh oh!
There was an error while loading. Please reload this page.
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.
Doesn't the solver pass the Cabal version to us as
useCabalVersion
? Can we just use that instead?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.
@23Skidoo The comment over the
useCabalVersion
field says that it should be used whenuseDependenciesExclusive
is not set, so it isn't always set by the dependency solver. I useduseDependencies
because SetupWrapper already uses it to check whether the solver has picked a Cabal version:cabal/cabal-install/Distribution/Client/SetupWrapper.hs
Line 629 in c4fc3bd
Uh oh!
There was an error while loading. Please reload this page.
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.
@grayjay I think the comment refers to the fact that if
useDependenciesExclusive
is set, then we should just use those dependencies exclusively, including the dependency on Cabal. If you look at the code, in both places we setuseDependencies
, we also setuseCabalVersion
.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.
I'm just a bit worried that the already complicated logic in this file is becoming more complicated, so I'm thinking about how we can make it simpler.
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.
The code still needs to determine whether the solver chose the Cabal version, though, which would be hard to determine from
useCabalVersion
. If the solver chose a Cabal version then we could useuseCabalVersion
. But I didn't want to change the behavior in the case that the solver didn't choose any setup dependencies or chose setup dependencies that didn't include Cabal.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.
OK, let's merge your patch as-is and refactor the logic some other time.
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.
@ezyang I pushed a new commit with comments.
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.
@23Skidoo I agree that the logic is becoming complicated. We could separate out the old and new code paths, as suggested here #3094 (comment). Then it would be easier to see which
SetupScriptOptions
apply in each case.