fastjet icon indicating copy to clipboard operation
fastjet copied to clipboard

build: try adding libtool to brew install

Open lgray opened this issue 1 year ago • 5 comments

It's not default with build tools in OS14.

lgray avatar Jun 25 '24 16:06 lgray

ah, yeah super gross indeed. I think the time has come to CMake fastjet and submit a PR.

lgray avatar Jun 25 '24 17:06 lgray

So what's confusing to me is that if you check the macos-13 and macos-14/macos-latest environments for HOMEBREW environment variables you get

  • macos-13
HOMEBREW_NO_AUTO_UPDATE=1
HOMEBREW_NO_INSTALL_CLEANUP=1
HOMEBREW_CASK_OPTS=--no-quarantine
  • macos-14
HOMEBREW_REPOSITORY=/opt/homebrew
HOMEBREW_NO_AUTO_UPDATE=1
HOMEBREW_PREFIX=/opt/homebrew
HOMEBREW_NO_INSTALL_CLEANUP=1
HOMEBREW_CASK_OPTS=--no-quarantine
HOMEBREW_CELLAR=/opt/homebrew/Cellar

and in the macos-14 environment none of the brew installed tools are found at configure or compile time. Everything "just works" in the macos-13 runner image.

In macos-13 the homebrew cellar is under /usr/local/Cellar/ while in macos-14 it is under /opt/homebrew/Cellar but that doesn't feel like something that should need to be manually configured to work on the runner. :?

matthewfeickert avatar Sep 15 '24 01:09 matthewfeickert

@henryiii Have you run into stuff like this before?

matthewfeickert avatar Sep 15 '24 01:09 matthewfeickert

This is one of two things: everything is now inside /opt/homebrew and GitHub ships a slimmed down image for 14+ that has some homebrew binaries manually removed.

henryiii avatar Sep 15 '24 01:09 henryiii

Hm. If I rebase on top of all the other PRs I have open at the moment (#313, #315, #316), I'm able to get things working if before installing in the CI

https://github.com/scikit-hep/fastjet/blob/8798649c795a7dc108899d857b5f0839a5cdca76/.github/workflows/ci.yml#L61

I manually set the include paths and lib paths for the headers (cgal, gmp, boost) and libraries (gmp) that

https://github.com/scikit-hep/fastjet/blob/8798649c795a7dc108899d857b5f0839a5cdca76/setup.py#L102-L107

complains about

export CPPFLAGS="-I$(brew --prefix cgal)/include -I$(brew --prefix gmp)/include -I$(brew --prefix boost)/include"
export LDFLAGS="-L$(brew --prefix gmp)/lib"
python -m pip install '.[test]' -v

and then additionally editing setup.py to (do terrible things and) inject LDFLAGS values into the CXXLFAGS argument to extern/fastjet-contrib's .configure options

@@ -96,7 +96,7 @@ class FastJetBuild(setuptools.command.build_ext.build_ext):
 
             env = os.environ.copy()
             env["CXX"] = env.get("CXX", "g++")
-            env["LDFLAGS"] = env.get("LDFLAGS", "") + f" -Wl,-rpath,{_rpath}"
+            env["LDFLAGS"] = env.get("LDFLAGS", "")
             env["ORIGIN"] = "$ORIGIN"  # if evaluated, it will still be '$ORIGIN'
             subprocess.run(["make", "-j"], cwd=FASTJET, env=env, check=True)
             subprocess.run(["make", "install"], cwd=FASTJET, env=env, check=True)
@@ -106,8 +106,7 @@ class FastJetBuild(setuptools.command.build_ext.build_ext):
                     "./configure",
                     f"--fastjet-config={FASTJET}/fastjet-config",
                     f'CXX={env["CXX"]}',
-                    "CXXFLAGS=-O3 -Bstatic -Bdynamic -std=c++17",
-                    f'LDFLAGS={env["LDFLAGS"]}',
+                    f'CXXFLAGS=-O3 -Bstatic -Bdynamic -std=c++17 {env["LDFLAGS"]}',
                 ],
                 cwd=FASTJET_CONTRIB,
                 env=env,

given that for fastjet-contrib

$ ./configure --help

This is a FastJet-contrib tool to configure the behaviour of
the build and installation.

Usage:
  configure [--help] [--list] [--fastjet-config=FILE] [--prefix=PREFIX] [CXX=...] [CXXFLAGS=...]

The arguments can be the following [default in square brackets]:

  --help            prints this message and exits
  --list            prints the list of existing contribs and exits
  --fastjet-config=FILE  
                    sets the 'fastjet-config' file to use [fastjet-config]
  --prefix=PREFIX   sets the installation directory [prefix returned by fastjet-config]
  --only=Contrib1,Contrib2,... 
                    only configures for compilation selected contribs 
  --exclude=Contrib1,Contrib2,...
                    excludes selected contribs from configuration

But manually setting these flags for compilation in CI jobs seems very bad, so there has to be some centralized way of informing the OS where to look for Homebrew installed headers and libraries. (Though I don't know how development on macOS works in general. :shrug:)

edit: TIL that Homebrew has include and lib dirs under $(brew --prefix) :+1: so

export CPPFLAGS="-I$(brew --prefix)/include"
export LDFLAGS="-L$(brew --prefix)/lib"
python -m pip install '.[test]' -v

works. I should have guessed that pattern. Though it would still be good to update this globally for the macos-14 runners.

matthewfeickert avatar Sep 15 '24 07:09 matthewfeickert