Skip to content

Consider Installed packages when pruning the install plan #6972

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

Closed
Closed
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
26 changes: 16 additions & 10 deletions cabal-install/src/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2680,16 +2680,22 @@ pruneInstallPlanPass1 pkgs =
setDocumentation
$ addOptionalStanzas elab

find_root (InstallPlan.Configured (PrunedPackage elab _)) =
if not $ and [ null (elabConfigureTargets elab)
, null (elabBuildTargets elab)
, null (elabTestTargets elab)
, null (elabBenchTargets elab)
, isNothing (elabReplTarget elab)
, null (elabHaddockTargets elab)
]
then Just (installedUnitId elab)
else Nothing
is_root :: PrunedPackage -> Maybe UnitId
is_root (PrunedPackage elab _) =
if not $ and [ null (elabConfigureTargets elab)
, null (elabBuildTargets elab)
, null (elabTestTargets elab)
, null (elabBenchTargets elab)
, isNothing (elabReplTarget elab)
, null (elabHaddockTargets elab)
]
then Just (installedUnitId elab)
else Nothing

find_root (InstallPlan.Configured pkg) = is_root pkg
-- When using the extra-packages stanza we need to
-- look at installed packages as well.
find_root (InstallPlan.Installed pkg) = is_root pkg
find_root _ = Nothing

-- Note [Sticky enabled testsuites]
Expand Down
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/ExtraPackages/Foo.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module Foo where
12 changes: 12 additions & 0 deletions cabal-testsuite/PackageTests/ExtraPackages/cabal.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# cabal v2-update
Downloading the latest package list from test-local-repo
# cabal v2-run
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- some-exe-0.0.1.0 (exe:some-exe) (requires build)
Configuring some-exe-0.0.1.0...
Preprocessing executable 'some-exe' for some-exe-0.0.1.0..
Building executable 'some-exe' for some-exe-0.0.1.0..
Installing executable some-exe in <PATH>
Warning: The directory <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>/incoming/<PACKAGE>-<HASH><ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>/<PACKAGE>-<HASH>/bin is not in the system search path.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argl it escapes too mucho :(

2 changes: 2 additions & 0 deletions cabal-testsuite/PackageTests/ExtraPackages/cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages: .
extra-packages: some-exe
3 changes: 3 additions & 0 deletions cabal-testsuite/PackageTests/ExtraPackages/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Test.Cabal.Prelude
main = cabalTest $ withRepo "repo" $ do
cabal "v2-run" [ "some-exe" ]
9 changes: 9 additions & 0 deletions cabal-testsuite/PackageTests/ExtraPackages/my.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: my
version: 0.1
license: BSD3
cabal-version: >= 1.2
build-type: Simple

library
exposed-modules: Foo
build-depends: base
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Main where

main :: IO ()
main = putStrLn "hello world"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: some-exe
version: 0.0.1.0
license: BSD3
cabal-version: >= 1.2
build-type: Simple

Executable some-exe
main-is: Main.hs
build-depends: base
8 changes: 7 additions & 1 deletion cabal-testsuite/src/Test/Cabal/OutputNormalizer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ normalizeOutput nenv =
-- This is dumb but I don't feel like pulling in another dep for
-- string search-replace. Make sure we do this before backslash
-- normalization!
. resub (posixRegexEscape (normalizerGblTmpDir nenv) ++ "[a-z0-9.-]+") "<GBLTMPDIR>" -- note, after TMPDIR
. resub (posixRegexEscape (normalizerGblTmpDir nenv) ++ "[a-z0-9\\.-]+") "<GBLTMPDIR>" -- note, after TMPDIR
. resub (posixRegexEscape (normalizerRoot nenv)) "<ROOT>/"
. resub (posixRegexEscape (normalizerTmpDir nenv)) "<TMPDIR>/"
. appEndo (F.fold (map (Endo . packageIdRegex) (normalizerKnownPackages nenv)))
Expand All @@ -39,6 +39,12 @@ normalizeOutput nenv =
-- Apply this before packageIdRegex, otherwise this regex doesn't match.
. resub "[0-9]+(\\.[0-9]+)*/installed-[A-Za-z0-9.+]+"
"<VERSION>/installed-<HASH>"
-- incoming directories in the store
. resub "/incoming/new-[0-9]+"
"/incoming/new-<RAND>"
-- look for PackageHash directories
. resub "/(([A-Za-z0-9_]+)(-[A-Za-z0-9\\._]+)*)-[0-9a-f]{4,64}/"
"/<PACKAGE>-<HASH>/"
-- Normalize architecture
. resub (posixRegexEscape (display (normalizerPlatform nenv))) "<ARCH>"
-- Some GHC versions are chattier than others
Expand Down
3 changes: 3 additions & 0 deletions changelog.d/pr-6972
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
synopsis: Make extra-packages work properly
packages: cabal-install
prs: #6972