Skip to content

Get the Kmett-verse off custom setups #3788

Closed

Description

@ezyang

@ekmett has many packages, even "low level" ones, which use custom setup scripts. Examples:

Grepping for generateBuildModule on Hackage will give you quite a parcel.

The boilerplate for these setup scripts is quite similar. This function is copy pasted quite a bit:

generateBuildModule :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
generateBuildModule verbosity pkg lbi = do
  let dir = autogenModulesDir lbi
  createDirectoryIfMissingVerbose verbosity True dir
  withLibLBI pkg lbi $ \_ libcfg -> do
    withTestLBI pkg lbi $ \suite suitecfg -> do
      rewriteFile (dir </> "Build_" ++ testName suite ++ ".hs") $ unlines
        [ "module Build_" ++ testName suite ++ " where"
        , "deps :: [String]"
        , "deps = " ++ (show $ formatdeps (testDeps libcfg suitecfg))
        ]
  where
    formatdeps = map (formatone . snd)
    formatone p = case packageName p of
      PackageName n -> n ++ "-" ++ showVersion (packageVersion p)

testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]
testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys

Any reason why Paths can't support this?

I've also seen it used for Haddock:

haddockOutputDir :: Package p => HaddockFlags -> p -> FilePath
haddockOutputDir flags pkg = destDir where
  baseDir = case haddockDistPref flags of
    NoFlag -> "."
    Flag x -> x
  destDir = baseDir </> "doc" </> "html" </> display (packageName pkg)

I don't know what kind of bug this is working around. Eek!

It would be great if the Kmett-verse could get off Custom scripts. It will take time, because they have big Cabal support windows. But the change starts here.

Activity

  1. ekmett commented on Sep 6, 2016

    @ekmett
    Member

    I also have a few scripts that copy an extra image or something into the haddock directory.

    I think the lens script does so.

  2. 23Skidoo commented on Sep 6, 2016

    @23Skidoo
    Member

    I also have a few scripts that copy an extra image or something into the haddock directory.

    Don't we have extra-doc-files for that?

  3. ekmett commented on Sep 6, 2016

    @ekmett
    Member

    Since around 1.18 right? I've yet to be able to make the switch.

  4. phadej commented on Sep 6, 2016

    @phadej
    Collaborator
  5. 23Skidoo commented on Sep 6, 2016

    @23Skidoo
    Member

    @ekmett Yes, since 1.18: 49a2be9, 4502e90. Though it looks like we don't have a version check for it in D.PD.Check.

  6. added this to the 2.0 milestone on Sep 8, 2016
  7. self-assigned this
    on Sep 8, 2016
  8. 23Skidoo commented on Sep 11, 2016

    @23Skidoo
    Member

    Though it looks like we don't have a version check for it in D.PD.Check.

    Fixed in #3825.

  9. RyanGlScott commented on Jan 11, 2017

    @RyanGlScott
    Member

    @phadej: Re the declarative way to run doctests: would #2327 give us this ability?

  10. phadej commented on Jan 11, 2017

    @phadej
    Collaborator

    @RyanGlScott, yes, AFAICS the doctests are the only reason Edward's packages use Custom setup.

  11. modified the milestones: 2.2, 2.0 on Feb 17, 2017
  12. removed this from the 2.2 milestone on Jan 14, 2018
  13. 5 remaining items

  14. hvr commented on Aug 31, 2018

    @hvr
    Member

    @ekmett well, do your users actually need to be able to invoke the doctest-testsuite with legacy cabal versions? It's quite possible that we can implement this in a similar way to the custom-setup which is ignored by cabal versions not gnostic to it.

  15. ekmett commented on Sep 4, 2018

    @ekmett
    Member

    @hvr That might work.

  16. modified the milestones: 3.0, 3.0.1.0 on Oct 16, 2019
  17. modified the milestones: 3.0.1.0, 3.2, 3.4 on Nov 27, 2019
  18. removed this from the Considered for 3.4 milestone on May 14, 2020
  19. RyanGlScott commented on Jan 10, 2021

    @RyanGlScott
    Member

    Using cabal-docspec, we've managed to remove the use of custom Setup scripts for most repos in the Kmettiverse. I'm not sure if that's enough to warrant closing this issue—your call.

  20. ekmett commented on Feb 21, 2021

    @ekmett
    Member

    I'm willing to declare intent to move the rest to cabal-docspec.

  21. ulysses4ever commented on Jul 10, 2022

    @ulysses4ever
    Collaborator

    I built an intersection of two lists

    1. Hackage grep result for generateBuildModule (as suggested above, this is a good evidence of a Edward's work)

    2. List of packages where Edward is listed as a maintainer

    Here's the result with comments:

    • hash (last uploaded 2013)
    • parsec-parsers (last uploaded 2013)
    • sparse (last uploaded 2015)
    • structures (last uploaded 2014)
    • tables (last uploaded 2015)

    So, these all look kinda dated. I propose we close this issue as completed (thanks to maintainers of respective packages, mostly Ryan).

  22. Mikolaj commented on Jul 11, 2022

    @Mikolaj
    Member

    Well done. Thank you. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions