cabal icon indicating copy to clipboard operation
cabal copied to clipboard

Command to build an sdist

Open michaelpj opened this issue 2 years ago • 7 comments

At the moment it's not that easy to build a generated sdist. You can unpack it yourself and build it from there, but it would be nice to have a one-command way to do this.

This is useful to catch issues like missing extra-source-files, which seems to be quite common (and just bit me!).

I would be happy with:

  • cabal build <sdist path>, ideally working for any such cabal command, including haddock
  • cabal sdist --build

Related:

  • Stack has an option: https://docs.haskellstack.org/en/stable/sdist_command/#-no-test-tarball-flag
  • A request to also run tests: https://github.com/haskell/cabal/issues/1141
  • https://github.com/haskell/cabal/issues/5064

michaelpj avatar Jun 16 '23 12:06 michaelpj

iirc you can install tarballs with cabal install path/to/package.tar.gz, is it not suitable for your workflow?

jneira avatar Jun 16 '23 20:06 jneira

Discussed a bit on IRC, but I interpret cabal install as very side-effect-y, which is very much not what I want. I want to build it! And I might want to test it or haddock it also.

michaelpj avatar Jun 16 '23 21:06 michaelpj

Note that the command line help says that you can do cabal build ./sdist.tgz but IIRC it does not work.

I'd also stay clear of cabal install.

Question: how do would you expect it to work? Should it be build like a local parkage? (Where is the build directory then?) or like a configured package (like extra-packages in cabal.project)?

andreabedini avatar Jun 17 '23 06:06 andreabedini

I remembered but not quite correctly. https://github.com/haskell/cabal/issues/7328 talks about specifying a source directory not a source tarball.

andreabedini avatar Jun 17 '23 06:06 andreabedini

Question: how do would you expect it to work? Should it be build like a local parkage? (Where is the build directory then?) or like a configured package (like extra-packages in cabal.project)?

IIRC, the idea would be to do what cabal install does, namely pretend it's a non-local package just like all the others involved in the build. No idea about ' configured package (like extra-packages in cabal.project)' vs what cabal install does.

Mikolaj avatar Jun 17 '23 12:06 Mikolaj

I mean like a named package can be listed in extra-packages in cabal.project, this makes it a non-local package. Notice you can use package: ../path/to/sdist but that becomes a local package. TBH I haven't looked into CmdInstall.hs enough to know what it does :)

andreabedini avatar Jun 20 '23 09:06 andreabedini

@jneira wrote:

iirc you can install tarballs with cabal install path/to/package.tar.gz, is it not suitable for your workflow?

You cannot with v2-install, at least in 2025.

andreasabel avatar Oct 11 '25 18:10 andreasabel