Skip to content
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

Cabal should define HASKELL_DIST_DIR #3483

Closed
nomeata opened this issue Jun 6, 2016 · 10 comments
Closed

Cabal should define HASKELL_DIST_DIR #3483

nomeata opened this issue Jun 6, 2016 · 10 comments

Comments

@nomeata
Copy link
Contributor

nomeata commented Jun 6, 2016

Test suites often want to run executable from dist/. Now dist/ is not always dist/, so an environment variable to indicate the position of dist would be nice.

stack sets HASKELL_DIST_DIR to this value. It would be nice if this were done by Cabal, so that other modes of building Haskell packages benefit from this convenience.

@dcoutts
Copy link
Contributor

dcoutts commented Jun 6, 2016

And/or adjusting the $PATH so that the other exes are just directly available.

nomeata added a commit to nomeata/arbtt that referenced this issue Jun 6, 2016
to unbreak running the tests under stack and, once
haskell/cabal#3483 is implemented, most other
configurations.
@23Skidoo
Copy link
Member

23Skidoo commented Jun 6, 2016

Good idea.

@dcoutts
Copy link
Contributor

dcoutts commented Jun 7, 2016

Actually given that the layout of the dist dir is not fixed (and we really should rationalise it at some point), it'd be better for the longer term to put the exes on the $PATH. But compatibility with whatever stack picked is also useful.

@Blaisorblade
Copy link
Collaborator

Actually given that the layout of the dist dir is not fixed (and we really should rationalise it at some point), it'd be better for the longer term to put the exes on the $PATH.

Note that's not the only usecase, there's also doctests grabbing the generated files:
sol/doctest#127

And I'd guess people will find more uses for this.

I think the doctests's thing is somewhat hacky, whence the custom Setup.hs used by ekmett and copy-pasted around Hackage, but this is what we have today.
ekmett/distributive#17 (comment)

@ezyang
Copy link
Contributor

ezyang commented Aug 16, 2016

If you apply this patch set #3662 then all internal build-tools will be put in your PATH. Not exactly what is asked for here, but should solve certain use-cases.

@ezyang
Copy link
Contributor

ezyang commented Aug 16, 2016

Given that Stack sets the env var before calling Setup, I guess cabal-install should be the one responsible for setting it here?

@Blaisorblade
Copy link
Collaborator

Given that Stack sets the env var before calling Setup, I guess cabal-install should be the one responsible for setting it here?

I think yes.

If you apply this patch set #3662 then all internal build-tools will be put in your PATH. Not exactly what is asked for here, but should solve certain use-cases.

Thanks. But test suites aren't build tools (and build tools aren't in dist), are they? Maybe they can be added too?

@ezyang
Copy link
Contributor

ezyang commented Aug 16, 2016

Thanks. But test suites aren't build tools (and build tools aren't in dist), are they? Maybe they can be added too?

You won't be able to put a test-suite in build-tools. But I thought the use-case here was calling an executable from a test suite; executables can be put in build-tools

executable bar
   ...
test-suite foo
  build-tools: bar

ezyang added a commit to ezyang/cabal that referenced this issue Aug 16, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
@Blaisorblade
Copy link
Collaborator

@ezyang Ah! I see — it looks like the original use case from @nomeata could work with your suggestion (looking at nomeata/arbtt@a114ff9 which seems the concrete example of the OP). So that's probably good.

But let me remind:

But compatibility with whatever stack picked is also useful.

Also, this isn't enough for other uses.

Ones I'm familiar with, but that might warrant better fixes:

  • doctests (as above), or more in general finding generated headers
  • hacking build introspection for now without the current Setup files. Which could be good for doctests actually — the doctests problem is that it's a library linked in the program, hence it can't easily talk to the Cabal version used by the build process.

TL;DR.: it seems Haskell libraries needing hooks into Setup.hs don't compose just so.

Unless maybe those hooks are rephrased using https://hackage.haskell.org/package/cabal-helper? (Related to #3065 and #2395).
But I suspect cabal-helper should still use HASKELL_DIST_DIR.

@ezyang
Copy link
Contributor

ezyang commented Aug 16, 2016

I don't know what should be done about doctest. Would have to sit down and think about it. Anyway go look at the PR for this bug.

@ezyang ezyang added this to the cabal-install 2.0 milestone Aug 16, 2016
ezyang added a commit to ezyang/cabal that referenced this issue Aug 17, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
@ezyang ezyang closed this as completed in a0efec0 Aug 18, 2016
ezyang added a commit that referenced this issue Aug 18, 2016
@ezyang ezyang modified the milestones: cabal-install 2.0, 2.0 (planned for next feature release) Sep 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants