Updating ROOT formula (a few questions)

I am preparing an update to the ROOT formula, and have a couple of questions. For the first time in ROOT, you are now allowed to use the ROOT bindings from python normally (the linking to Python has been removed in the rewritten bindings). I would like to then install symlinks to site packages so that it can be imported without the path manipulations listed in the caveats. I have tried this before, but the audit system (correctly) detected the linking to Python and refused to allow it; the workaround was to just leave it in the wrong folder so the audit system didn’t catch it. We can finally fix it and pass the audit. I don’t know where my old code is, though, so I’m redoing it. I basically need to finish this (I can convert the system calls into Ruby link methods, but I don’t know how to get the site packages dir - I think I can use lib to get the prefix/lib directory:

# TODO: Symlink Python components into Python directory
# This was not supported until ROOT 6.22.
# Do the equivalent of this:

ln -s "${PREFIX}/lib/JupyROOT/" "${SP_DIR}/"
ln -s "${PREFIX}/lib/ROOT/" "${SP_DIR}/"
ln -s "${PREFIX}/lib/cppyy/" "${SP_DIR}/"
ln -s "${PREFIX}/lib/cppyy_backend/" "${SP_DIR}/"
ln -s "${PREFIX}/lib/JsMVA/" "${SP_DIR}/"
ln -s "${PREFIX}/lib/cmdLineUtils.py" "${SP_DIR}/"
ln -s "${PREFIX}/lib"/libJupyROOT*.so "${SP_DIR}/"
ln -s "${PREFIX}/lib"/libROOTPythonizations*.so "${SP_DIR}/"
ln -s "${PREFIX}/lib"/libcppyy*.so "${SP_DIR}/"

And my second question; when I run brew audit root --online, I get:

root:
  * Files were found with references to the Homebrew shims directory.
    The offending files are:
      include/root/compiledata.h
      lib/root/libProof.so
      lib/root/libCore.so

What’s the standard way to fix something like this? Also, is this a new check in homebrew, or is it likely to be something that ROOT has introduced recently?

The shims check is relatively recent. I’m not sure how to fix references in libraries though. I’ll ask some other people for help.

Here’s the offending header file:

/* This file is automatically generated */
...
#define CXX "clang++"
#define COMPILER "/usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang++"
#define COMPILERVERS "clang1103"
...
#define LINKEDLIBS "-L/usr/local/Cellar/root/6.22.00/lib/root -lCore -lRint "
#define INCLUDEPATH "-I/usr/local/Cellar/root/6.22.00/include/root"
...

It’s saving the compiler location in the shim.

And, here are the lines that save it into the .so’s and .h:

build/unix/compiledata.sh:118:        echo "#define COMPILER \""`type -path $CXX`"\"" >> ${COMPILEDATA}.tmp
cmake/scripts/compiledata.win32.in:5: #define COMPILER "@CMAKE_CXX_COMPILER@"
core/base/src/TSystem.cxx:196:        fBuildCompiler = COMPILER;
proof/proof/src/TProofServ.cxx:2974:  # ifdef COMPILER
proof/proof/src/TProofServ.cxx:2975:  TString compiler = COMPILER;

So we could modify it between configure and build, and that should fix the so’s. I just need to know what it was (shim path) and what it is supposed to be.

Between the configure and build steps, you could try adding something like

inreplace "core/base/src/TSystem.cxx", "COMPILER", "\"#{ENV.cxx}\""
inreplace "proof/proof/src/TProofServ.cxx", "COMPILER", "\"#{ENV.cxx}\""

Alternatively, you could possibly try patching compiledata.sh prior to the configure step and see if that fixes it:

inreplace "build/unix/compiledata.sh", "`type -path $CXX`", ENV.cxx

This latter solution should work assuming that compiledata.sh only produces data that’s embedded into the files but not actually used for compilation purposes.

I’m testing that solution, thanks! Any idea for the correct way to get the site-packages directory, so that the bindings can be symlinked in?

That worked, the shim warning is gone! Thanks! Now I just need to do something like this:

      # TODO: Symlink Python components into Python directory
      # This was not supported until ROOT 6.22.
items = %w(
    JupyROOT/
    ROOT/
    cppyy/
    cppyy_backend/
    JsMVA/
    cmdLineUtils.py
    libJupyROOT*.so
    libROOTPythonizations*.so
    libcppyy*.so
)
items.each do |item|
  # Maybe check for and expand globs, I don't think
  # Ruby does so automatically
  site_packages = ?
  (site_packages / item).make_symlink(lib / item)
end

Final result: https://github.com/Homebrew/homebrew-core/pull/56788