@@ -15,99 +15,99 @@ module Distribution.Client.GenBounds
1515import Distribution.Client.Compat.Prelude
1616import Prelude ()
1717
18- import Distribution.Client.Freeze
19- ( getFreezePkgs
20- )
18+ -- import Distribution.Client.Freeze
19+ -- ( getFreezePkgs
20+ -- )
2121import Distribution.Client.Setup
2222 ( FreezeFlags (.. )
2323 , GlobalFlags (.. )
2424 , RepoContext
2525 )
26- import Distribution.Client.Utils
27- ( hasElem
28- , incVersion
29- )
30- import Distribution.Package
31- ( Package (.. )
32- , packageName
33- , packageVersion
34- , unPackageName
35- )
36- import Distribution.PackageDescription
37- ( enabledBuildDepends
38- )
39- import Distribution.PackageDescription.Configuration
40- ( finalizePD
41- )
26+ -- import Distribution.Client.Utils
27+ -- ( hasElem
28+ -- , incVersion
29+ -- )
30+ -- import Distribution.Package
31+ -- ( Package (..)
32+ -- , packageName
33+ -- , packageVersion
34+ -- , unPackageName
35+ -- )
36+ -- import Distribution.PackageDescription
37+ -- ( enabledBuildDepends
38+ -- )
39+ -- import Distribution.PackageDescription.Configuration
40+ -- ( finalizePD
41+ -- )
4242import Distribution.Simple.Compiler
43- import Distribution.Simple.PackageDescription
44- ( readGenericPackageDescription
45- )
43+ -- import Distribution.Simple.PackageDescription
44+ -- ( readGenericPackageDescription
45+ -- )
4646import Distribution.Simple.Program
4747 ( ProgramDb
4848 )
49- import Distribution.Simple.Utils
50- ( notice
51- , tryFindPackageDesc
52- )
49+ -- import Distribution.Simple.Utils
50+ -- ( notice
51+ -- , tryFindPackageDesc
52+ -- )
5353import Distribution.System
5454 ( Platform
5555 )
56- import Distribution.Types.ComponentRequestedSpec
57- ( defaultComponentRequestedSpec
58- )
59- import Distribution.Types.Dependency
60- import Distribution.Types.DependencySatisfaction
61- ( DependencySatisfaction (.. )
62- )
63- import Distribution.Utils.Path (relativeSymbolicPath )
64- import Distribution.Version
65- ( LowerBound (.. )
66- , UpperBound (.. )
67- , Version
68- , VersionInterval (.. )
69- , VersionRange
70- , alterVersion
71- , asVersionIntervals
72- , earlierVersion
73- , hasUpperBound
74- , intersectVersionRanges
75- , orLaterVersion
76- )
56+ -- import Distribution.Types.ComponentRequestedSpec
57+ -- ( defaultComponentRequestedSpec
58+ -- )
59+ -- import Distribution.Types.Dependency
60+ -- import Distribution.Types.DependencySatisfaction
61+ -- ( DependencySatisfaction (..)
62+ -- )
63+ -- import Distribution.Utils.Path (relativeSymbolicPath)
64+ -- import Distribution.Version
65+ -- ( LowerBound (..)
66+ -- , UpperBound (..)
67+ -- , Version
68+ -- , VersionInterval (..)
69+ -- , VersionRange
70+ -- , alterVersion
71+ -- , asVersionIntervals
72+ -- , earlierVersion
73+ -- , hasUpperBound
74+ -- , intersectVersionRanges
75+ -- , orLaterVersion
76+ -- )
7777
78- -- | Given a version, return an API-compatible (according to PVP) version range.
79- --
80- -- Example: @0.4.1.2@ produces the version range @>= 0.4.1 && < 0.5@.
81- --
82- -- This version is slightly different than the one in
83- -- 'Distribution.Client.Init'. This one uses a.b.c as the lower bound because
84- -- the user could be using a new function introduced in a.b.c which would make
85- -- ">= a.b" incorrect.
86- pvpize :: Version -> VersionRange
87- pvpize v =
88- orLaterVersion (vn 3 )
89- `intersectVersionRanges` earlierVersion (incVersion 1 (vn 2 ))
90- where
91- vn n = alterVersion (take n) v
92-
93- -- | Show the PVP-mandated version range for this package. The @padTo@ parameter
94- -- specifies the width of the package name column.
95- showBounds :: Package pkg => Int -> pkg -> String
96- showBounds padTo p =
97- unwords $
98- padAfter padTo (unPackageName $ packageName p)
99- :
100- -- TODO: use normaliseVersionRange
101- map showInterval (asVersionIntervals $ pvpize $ packageVersion p)
102- where
103- padAfter :: Int -> String -> String
104- padAfter n str = str ++ replicate (n - length str) ' '
105-
106- showInterval :: VersionInterval -> String
107- showInterval (VersionInterval (LowerBound _ _) NoUpperBound ) =
108- error " Error: expected upper bound...this should never happen!"
109- showInterval (VersionInterval (LowerBound l _) (UpperBound u _)) =
110- unwords [" >=" , prettyShow l, " && <" , prettyShow u]
78+ -- -- | Given a version, return an API-compatible (according to PVP) version range.
79+ -- --
80+ -- -- Example: @0.4.1.2@ produces the version range @>= 0.4.1 && < 0.5@.
81+ -- --
82+ -- -- This version is slightly different than the one in
83+ -- -- 'Distribution.Client.Init'. This one uses a.b.c as the lower bound because
84+ -- -- the user could be using a new function introduced in a.b.c which would make
85+ -- -- ">= a.b" incorrect.
86+ -- pvpize :: Version -> VersionRange
87+ -- pvpize v =
88+ -- orLaterVersion (vn 3)
89+ -- `intersectVersionRanges` earlierVersion (incVersion 1 (vn 2))
90+ -- where
91+ -- vn n = alterVersion (take n) v
92+
93+ -- -- | Show the PVP-mandated version range for this package. The @padTo@ parameter
94+ -- -- specifies the width of the package name column.
95+ -- showBounds :: Package pkg => Int -> pkg -> String
96+ -- showBounds padTo p =
97+ -- unwords $
98+ -- padAfter padTo (unPackageName $ packageName p)
99+ -- :
100+ -- -- TODO: use normaliseVersionRange
101+ -- map showInterval (asVersionIntervals $ pvpize $ packageVersion p)
102+ -- where
103+ -- padAfter :: Int -> String -> String
104+ -- padAfter n str = str ++ replicate (n - length str) ' '
105+
106+ -- showInterval :: VersionInterval -> String
107+ -- showInterval (VersionInterval (LowerBound _ _) NoUpperBound) =
108+ -- error "Error: expected upper bound...this should never happen!"
109+ -- showInterval (VersionInterval (LowerBound l _) (UpperBound u _)) =
110+ -- unwords [">=", prettyShow l, "&& <", prettyShow u]
111111
112112-- | Entry point for the @gen-bounds@ command.
113113genBounds
@@ -120,77 +120,81 @@ genBounds
120120 -> GlobalFlags
121121 -> FreezeFlags
122122 -> IO ()
123- genBounds verbosity packageDBs repoCtxt comp platform progdb globalFlags freezeFlags = do
124- let cinfo = compilerInfo comp
125-
126- path <- relativeSymbolicPath <$> tryFindPackageDesc verbosity Nothing
127- gpd <- readGenericPackageDescription verbosity Nothing path
128- -- NB: We don't enable tests or benchmarks, since often they
129- -- don't really have useful bounds.
130- let epd =
131- finalizePD
132- mempty
133- defaultComponentRequestedSpec
134- (const Satisfied )
135- platform
136- cinfo
137- []
138- gpd
139- case epd of
140- Left _ -> putStrLn " finalizePD failed"
141- Right (pd, _) -> do
142- let needBounds =
143- map depName $
144- filter (not . hasUpperBound . depVersion) $
145- enabledBuildDepends pd defaultComponentRequestedSpec
146-
147- pkgs <-
148- getFreezePkgs
149- verbosity
150- packageDBs
151- repoCtxt
152- comp
153- platform
154- progdb
155- globalFlags
156- freezeFlags
157-
158- let isNeeded = hasElem needBounds . unPackageName . packageName
159- let thePkgs = filter isNeeded pkgs
160-
161- let padTo = maximum $ map (length . unPackageName . packageName) pkgs
162-
163- if null thePkgs
164- then
165- notice
166- verbosity
167- " Congratulations, all your dependencies have upper bounds!"
168- else do
169- notice verbosity boundsNeededMsg
170- traverse_ (notice verbosity . (++ " ," ) . showBounds padTo) thePkgs
171-
172- depName :: Dependency -> String
173- depName (Dependency pn _ _) = unPackageName pn
174-
175- depVersion :: Dependency -> VersionRange
176- depVersion (Dependency _ vr _) = vr
177-
178- -- | The message printed when some dependencies are found to be lacking proper
179- -- PVP-mandated bounds.
180- boundsNeededMsg :: String
181- boundsNeededMsg =
182- unlines
183- [ " "
184- , " The following packages need bounds and here is a suggested starting point."
185- , " You can copy and paste this into the build-depends section in your .cabal"
186- , " file and it should work (with the appropriate removal of commas)."
187- , " "
188- , " Note that version bounds are a statement that you've successfully built and"
189- , " tested your package and expect it to work with any of the specified package"
190- , " versions (PROVIDED that those packages continue to conform with the PVP)."
191- , " Therefore, the version bounds generated here are the most conservative"
192- , " based on the versions that you are currently building with. If you know"
193- , " your package will work with versions outside the ranges generated here,"
194- , " feel free to widen them."
195- , " "
196- ]
123+ genBounds _verbosity _packageDBs _repoCtxt _comp _platform _progdb _globalFlags _freezeFlags =
124+ putStrLn " not implemented"
125+
126+
127+ -- genBounds verbosity packageDBs repoCtxt comp platform progdb globalFlags freezeFlags = do
128+ -- let cinfo = compilerInfo comp
129+
130+ -- path <- relativeSymbolicPath <$> tryFindPackageDesc verbosity Nothing
131+ -- gpd <- readGenericPackageDescription verbosity Nothing path
132+ -- -- NB: We don't enable tests or benchmarks, since often they
133+ -- -- don't really have useful bounds.
134+ -- let epd =
135+ -- finalizePD
136+ -- mempty
137+ -- defaultComponentRequestedSpec
138+ -- (const Satisfied)
139+ -- platform
140+ -- cinfo
141+ -- []
142+ -- gpd
143+ -- case epd of
144+ -- Left _ -> putStrLn "finalizePD failed"
145+ -- Right (pd, _) -> do
146+ -- let needBounds =
147+ -- map depName $
148+ -- filter (not . hasUpperBound . depVersion) $
149+ -- enabledBuildDepends pd defaultComponentRequestedSpec
150+
151+ -- pkgs <-
152+ -- getFreezePkgs
153+ -- verbosity
154+ -- packageDBs
155+ -- repoCtxt
156+ -- comp
157+ -- platform
158+ -- progdb
159+ -- globalFlags
160+ -- freezeFlags
161+
162+ -- let isNeeded = hasElem needBounds . unPackageName . packageName
163+ -- let thePkgs = filter isNeeded pkgs
164+
165+ -- let padTo = maximum $ map (length . unPackageName . packageName) pkgs
166+
167+ -- if null thePkgs
168+ -- then
169+ -- notice
170+ -- verbosity
171+ -- "Congratulations, all your dependencies have upper bounds!"
172+ -- else do
173+ -- notice verbosity boundsNeededMsg
174+ -- traverse_ (notice verbosity . (++ ",") . showBounds padTo) thePkgs
175+
176+ -- depName :: Dependency -> String
177+ -- depName (Dependency pn _ _) = unPackageName pn
178+
179+ -- depVersion :: Dependency -> VersionRange
180+ -- depVersion (Dependency _ vr _) = vr
181+
182+ -- -- | The message printed when some dependencies are found to be lacking proper
183+ -- -- PVP-mandated bounds.
184+ -- boundsNeededMsg :: String
185+ -- boundsNeededMsg =
186+ -- unlines
187+ -- [ ""
188+ -- , "The following packages need bounds and here is a suggested starting point."
189+ -- , "You can copy and paste this into the build-depends section in your .cabal"
190+ -- , "file and it should work (with the appropriate removal of commas)."
191+ -- , ""
192+ -- , "Note that version bounds are a statement that you've successfully built and"
193+ -- , "tested your package and expect it to work with any of the specified package"
194+ -- , "versions (PROVIDED that those packages continue to conform with the PVP)."
195+ -- , "Therefore, the version bounds generated here are the most conservative"
196+ -- , "based on the versions that you are currently building with. If you know"
197+ -- , "your package will work with versions outside the ranges generated here,"
198+ -- , "feel free to widen them."
199+ -- , ""
200+ -- ]
0 commit comments