Skip to content

Fix for issue #3932. #4051

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 4 commits into from
Oct 29, 2016
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
24 changes: 24 additions & 0 deletions cabal-install/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,17 @@ planPackages comp platform solver SolverSettings{..}
| Dependency name ver <- solverSettingPreferences ]

. addConstraints

-- If a package has a custom setup then we need to add a setup-depends
-- on Cabal. For now it's easier to add this unconditionally. Once
-- qualified constraints land we can turn this into a custom setup
-- only constraint.
--
-- TODO: use a qualified constraint
[ LabeledPackageConstraint (PackageConstraintVersion cabalPkgname
(orLaterVersion (mkVersion [1,20])))
ConstraintNewBuildCustomSetupLowerBoundCabal
] . addConstraints
-- version constraints from the config file or command line
[ LabeledPackageConstraint (userToPackageConstraint pc) src
| (pc, src) <- solverSettingConstraints ]
Expand Down Expand Up @@ -2392,6 +2403,17 @@ defaultSetupDeps compiler platform pkg =
-- * We omit the dep for the Cabal lib itself, since it bootstraps.
-- * We constrain it to be >= 1.18 < 2
--
-- Note: cabalCompatMinVer only gets applied WHEN WE ARE ADDING a
-- default setup build info, i.e., when there is no custom-setup
-- stanza. If there is a custom-setup stanza, this codepath never gets
-- invoked (that's why there's an error case for
-- SetupCustomExplicitDeps).
--
-- One way we could solve this problem is by also modifying
-- custom-setup stanzas when they exist, but we're going to take a
-- different approach: add an extra constraint on Cabal globally to
-- make sure the solver respects it regardless of whether or not there
-- is an explicit setup build info or not. See planPackages.
cabalConstraint = orLaterVersion cabalCompatMinVer
`intersectVersionRanges`
orLaterVersion (PD.specVersion pkg)
Expand Down Expand Up @@ -2421,6 +2443,8 @@ defaultSetupDeps compiler platform pkg =
-- The internal setup wrapper method has no deps at all.
SetupNonCustomInternalLib -> Just []

-- This case gets ruled out by the caller, planPackages, see the note
-- above in the SetupCustomIplicitDeps case.
SetupCustomExplicitDeps ->
error $ "defaultSetupDeps: called for a package with explicit "
++ "setup deps: " ++ display (packageId pkg)
Expand Down
4 changes: 4 additions & 0 deletions cabal-install/Distribution/Solver/Types/ConstraintSource.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ data ConstraintSource =

-- | The source of the constraint is not specified.
| ConstraintSourceUnknown

-- | Custom setup requires a minimum lower bound on Cabal
| ConstraintNewBuildCustomSetupLowerBoundCabal
deriving (Eq, Show, Generic)

instance Binary ConstraintSource
Expand All @@ -68,3 +71,4 @@ showConstraintSource ConstraintSourceFreeze = "cabal freeze"
showConstraintSource ConstraintSourceConfigFlagOrTarget =
"config file, command line flag, or user target"
showConstraintSource ConstraintSourceUnknown = "unknown source"
showConstraintSource ConstraintNewBuildCustomSetupLowerBoundCabal = "new-build's support of Custom Setup (issue #3932)"
8 changes: 3 additions & 5 deletions cabal-install/cabal-install.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Extra-Source-Files:
tests/IntegrationTests/custom-setup/Cabal-99998/CabalMessage.hs
tests/IntegrationTests/custom-setup/Cabal-99999/Cabal.cabal
tests/IntegrationTests/custom-setup/Cabal-99999/CabalMessage.hs
tests/IntegrationTests/custom-setup/custom-setup-old-cabal/Setup.hs
tests/IntegrationTests/custom-setup/custom-setup-old-cabal/custom-setup-old-cabal.cabal
tests/IntegrationTests/custom-setup/custom-setup-without-cabal-defaultMain/Setup.hs
tests/IntegrationTests/custom-setup/custom-setup-without-cabal-defaultMain/custom-setup-without-cabal-defaultMain.cabal
tests/IntegrationTests/custom-setup/custom-setup-without-cabal/Setup.hs
Expand All @@ -60,6 +62,7 @@ Extra-Source-Files:
tests/IntegrationTests/custom-setup/custom_setup_without_Cabal_doesnt_allow_Cabal_import.sh
tests/IntegrationTests/custom-setup/custom_setup_without_Cabal_doesnt_require_Cabal.sh
tests/IntegrationTests/custom-setup/installs_Cabal_as_setup_dep.sh
tests/IntegrationTests/custom-setup/new_build_requires_Cabal_1_20.sh
tests/IntegrationTests/custom/custom_dep.sh
tests/IntegrationTests/custom/custom_dep/client/B.hs
tests/IntegrationTests/custom/custom_dep/client/Setup.hs
Expand Down Expand Up @@ -171,11 +174,6 @@ Extra-Source-Files:
tests/IntegrationTests/regression/t3199/Main.hs
tests/IntegrationTests/regression/t3199/Setup.hs
tests/IntegrationTests/regression/t3199/test-3199.cabal
tests/IntegrationTests/regression/t3335.sh
tests/IntegrationTests/regression/t3335/A.hs
tests/IntegrationTests/regression/t3335/Setup.hs
tests/IntegrationTests/regression/t3335/cabal.project
tests/IntegrationTests/regression/t3335/t3335.cabal
tests/IntegrationTests/regression/t3827.sh
tests/IntegrationTests/regression/t3827/cabal.project
tests/IntegrationTests/regression/t3827/p/P.hs
Expand Down
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: custom-setup
version: 1.0
build-type: Custom

custom-setup
setup-depends: base, Cabal < 1.20

library
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Regression test for issue #3932

. ./common.sh

cd custom-setup-old-cabal
! cabal new-build > output 2>&1

cat output
grep -q "(issue #3932) requires >=1.20" output || die "Expect constraint failure"
6 changes: 0 additions & 6 deletions cabal-install/tests/IntegrationTests/regression/t3335.sh

This file was deleted.

1 change: 0 additions & 1 deletion cabal-install/tests/IntegrationTests/regression/t3335/A.hs

This file was deleted.

This file was deleted.

This file was deleted.

16 changes: 0 additions & 16 deletions cabal-install/tests/IntegrationTests/regression/t3335/t3335.cabal

This file was deleted.