@@ -184,18 +184,19 @@ configureSetupScript packageDBs
184184 index
185185 mpkg
186186 = SetupScriptOptions {
187- useCabalVersion = cabalVersion
188- , useCabalSpecVersion = Nothing
189- , useCompiler = Just comp
190- , usePlatform = Just platform
191- , usePackageDB = packageDBs'
192- , usePackageIndex = index'
193- , useProgramConfig = conf
194- , useDistPref = distPref
195- , useLoggingHandle = Nothing
196- , useWorkingDir = Nothing
197- , setupCacheLock = lock
198- , useWin32CleanHack = False
187+ useCabalVersion = cabalVersion
188+ , noDefaultCabalDep = defaultSetupDeps
189+ , useCabalSpecVersion = Nothing
190+ , useCompiler = Just comp
191+ , usePlatform = Just platform
192+ , usePackageDB = packageDBs'
193+ , usePackageIndex = index'
194+ , useProgramConfig = conf
195+ , useDistPref = distPref
196+ , useLoggingHandle = Nothing
197+ , useWorkingDir = Nothing
198+ , setupCacheLock = lock
199+ , useWin32CleanHack = False
199200 , forceExternalSetupMethod = forceExternal
200201 -- If we have explicit setup dependencies, list them; otherwise, we give
201202 -- the empty list of dependencies; ideally, we would fix the version of
@@ -204,8 +205,8 @@ configureSetupScript packageDBs
204205 -- know the version of Cabal at this point, but only find this there.
205206 -- Therefore, for now, we just leave this blank.
206207 , useDependencies = fromMaybe [] explicitSetupDeps
207- , useDependenciesExclusive = isJust explicitSetupDeps
208- , useVersionMacros = isJust explicitSetupDeps
208+ , useDependenciesExclusive = not defaultSetupDeps && isJust explicitSetupDeps
209+ , useVersionMacros = not defaultSetupDeps && isJust explicitSetupDeps
209210 }
210211 where
211212 -- When we are compiling a legacy setup script without an explicit
@@ -223,13 +224,24 @@ configureSetupScript packageDBs
223224 -- but if the user is using an odd db stack, don't touch it
224225 _otherwise -> (packageDBs, Just index)
225226
227+ maybeSetupBuildInfo :: Maybe PkgDesc. SetupBuildInfo
228+ maybeSetupBuildInfo = do
229+ ReadyPackage (ConfiguredPackage (SourcePackage _ gpkg _ _) _ _ _) _
230+ <- mpkg
231+ PkgDesc. setupBuildInfo (PkgDesc. packageDescription gpkg)
232+
233+ -- Was a default 'custom-setup' stanza added by 'cabal-install' itself? If
234+ -- so, 'setup-depends' must not be exclusive. See #3199.
235+ defaultSetupDeps :: Bool
236+ defaultSetupDeps = maybe False PkgDesc. defaultSetupDepends
237+ maybeSetupBuildInfo
238+
226239 explicitSetupDeps :: Maybe [(UnitId , PackageId )]
227240 explicitSetupDeps = do
228- ReadyPackage (ConfiguredPackage (SourcePackage _ gpkg _ _) _ _ _) deps
229- <- mpkg
230- -- Check if there is an explicit setup stanza
231- _buildInfo <- PkgDesc. setupBuildInfo (PkgDesc. packageDescription gpkg)
241+ -- Check if there is an explicit setup stanza.
242+ _buildInfo <- maybeSetupBuildInfo
232243 -- Return the setup dependencies computed by the solver
244+ ReadyPackage _ deps <- mpkg
233245 return [ ( Installed. installedUnitId deppkg
234246 , Installed. sourcePackageId deppkg
235247 )
0 commit comments