-
Notifications
You must be signed in to change notification settings - Fork 42
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
Make homebrew optional #99
Conversation
Force-adding homebrew paths to `text-icu`, causes compilation and link errors on systems that have a mixture of homebrew and other system library providers. There currently is no way to prohibit `text-icu` from _not_ force-injecting homebrew paths. This change adds a flag to allow disabling the forced addition of homebrew paths to the package description. Morally I'd argue that this flag should be off by default, I do however see this as a harder case to argue, and the current on-by-default to be less contentious.
Thank you. It's now on Hackage, version |
@@ -46,6 +46,11 @@ license: BSD3 | |||
license-file: LICENSE | |||
build-type: Simple | |||
|
|||
flag homebrew | |||
Description: Assume homebrew on macOS. Automatically add /usr/local/opt/ and /usr/homebrew/opt/ paths to extra-lib-dirs and include-dirs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/usr/homebrew/opt/
That meant /opt/homebrew/opt/
, I suppose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I fixed it.
flag homebrew | ||
Description: Assume homebrew on macOS. Automatically add /usr/local/opt/ and /usr/homebrew/opt/ paths to extra-lib-dirs and include-dirs. | ||
Default: True | ||
Manual: True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose default: true
is for backward compatibility.
However, in general one would not need any extra-lib-dirs
, because they can be communicated by pkg-config
.
See how CI does it:
text-icu/.github/workflows/cabal-mac-win.yml
Lines 53 to 59 in be8f0e8
# Let `pkg-config` find the ICU libs. | |
# Also test whether it actually works, and print some debug information. | |
- name: Set up pkg-config for the ICU library (macOS) | |
if: ${{ runner.os == 'macOS' }} | |
run: | | |
PKG_CONFIG_PATH=$(brew --prefix)/opt/icu4c/lib/pkgconfig | |
echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" >> "${GITHUB_ENV}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not everyone has pkg-config. In HsOpenSSL for example there are 3 flags: homebrew-openssl
, macports-openssl
, and use-pkg-config
. There's also a non-trivial Setup.hs that tries to auto-detect settings. Probably text-icu
needs the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I wish we could jsut rely on pkg-config, but relying on that is also such a mess, especailly on windows, where you might end up with Strawberry Perls pkg-config mess all of a sudden.
And yes, default: true
feels morally wrong to me, but I didn't want to break anyone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I agree that if one does not have pkg-config
set up, one does not get good errors from cabal why build is failing, and setting it up is a manual process one would not want to have to do...
So, maybe cabal complaining about non-existent library paths is the lesser evil.
@angerman @vshabanov CI failures should be investigated before merging: https://github.com/haskell/text-icu/actions/runs/8563984229/job/23517908260?pr=99 Continuous integration is precisely here to detect problems in PRs. |
Yes, I was thinking that the change is benign enough and didn't wait for CI to end (for some reason CI didn't run automatically and I needed to run it manually), but it turned out that |
This also caught me by surprise. @vshabanov do you consider this a cabal bug? |
I have stumbled more than once over the weird ordering constraints in .cabal files. |
Yes, I've flagged this with @andreabedini to please look at. I find the colon, non-colon distinction in cabal files also fairly annoying, as I get it wrong more often than not (and did not come up with some rationalization like you did @andreasabel 🙄). I consider this "seemingly" arbitrary syntax a fairly annoying UX failure. |
@andreasabel is correct: top-level fields after the first section are ignored. Sections where introduced later so the current parser (one of the many layers) adapts a package description in the legacy format into the new schema. This is done by parsing all the top-lelve fields first and adding the sections later. It is not pretty. The parser outputs a warning though:
Did the warning get lost in the weeds? Edit: it did https://github.com/haskell/text-icu/actions/runs/8563984229/job/23517908260?pr=99#step:18:24 |
I only saw "Ignoring trailing fields after sections:" when I uploaded to Hackage, but I had no idea what it meant (googling didn't give any useful answers), and inferred that Since I mostly just copy cabal fields/sections from other .cabal files, I had no idea that cabal has a field/section distinction and that I think the error message should be improved with a hint "Please, put fields (name: value) before sections (name without colon)". But ideally the parser should work in any order. |
To be clear I didn't imply any judgement
I wholeheartedly agree. |
Force-adding homebrew paths to
text-icu
, causes compilation and link errors on systems that have a mixture of homebrew and other system library providers. There currently is no way to prohibittext-icu
from not force-injecting homebrew paths.This change adds a flag to allow disabling the forced addition of homebrew paths to the package description.
Morally I'd argue that this flag should be off by default, I do however see this as a harder case to argue, and the current on-by-default to be less contentious.