chore: add homebrew recipe
Adds Homebrew recipe for InfluxDB 3 Core.
Due to how Homebrew works, we can't pass in variables for starting info, like node-id. Due to this, the recipe creates a default config with "node0" and outputs this info in the caveats. I don't think we can make it much simpler, akin to the old approach of just running influxd, but this gets pretty close.
@bnpfeife I could use your review given your experience with these recipes.
@jdstrand Also requesting your review given this does some process work similar to the direct install script, and I know we needed some security adjustments there, so being cognizant of that here.
Note: this if for 3.3.0 for testing, but we'll need it for 3.4.0 when we actually publish.
@peterbarnett03 - hey, is there a reason you picked ruby? It isn't used in the codebase (or really at InfluxData any more). Could this be shell (preferable) or maybe python (if shell doesn't work)? If not, we can make it work, but it would be better if it is a language we are already using in the codebase.
@peterbarnett03 - hey, is there a reason you picked ruby? It isn't used in the codebase (or really at InfluxData any more). Could this be shell (preferable) or maybe python (if shell doesn't work)? If not, we can make it work, but it would be better if it is a language we are already using in the codebase.
Homebrew recipes/formulas need to be written in Ruby
FWIW - re: the brew audit failures, they mostly look like formatting issues, and could probably be addressed with a ruby formatter, but I'm not familiar with the tooling for ruby to recommend one.
FWIW - re: the
brew auditfailures, they mostly look like formatting issues, and could probably be addressed with a ruby formatter, but I'm not familiar with the tooling for ruby to recommend one.
Fixed all the warnings except one which continues to complain that:
* Non-executables were installed to "/opt/homebrew/opt/influxdb3-core/bin".
The offending files are:
/opt/homebrew/opt/influxdb3-core/bin/python
Can't find info on it on Google -- Claude says it's fine and "normal" (though my gut tells me that's a hallucination). I've tried other workarounds like symlinking and changing to lib, but that causes other issues.
Can't find info on it on Google -- Claude says it's fine and "normal" (though my gut tells me that's a hallucination)
Ah, interesting, I reckon that is the python that is installed for the processing engine?
That may actually be indicative of a problem. I tried starting the installed server with a --plugin-dir and it crashes with a fatal error:
> influxdb3 serve --node-id test-brew --object-store memory --without-auth --plugin-dir plugins
[...]
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Fatal Python error: Failed to import encodings module
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x0000000201ace0c0 (most recent call first):
<no Python frame>
If I compile the influxdb3 binary and start that with the same arguments it succeeds.
That may actually be indicative of a problem. I tried starting the installed server with a
--plugin-dirand it crashes with a fatal error:
Hmmmm odd. What if you try brew services start influxdb3-core to run as a service? That works for me, and allows me to run plugins I've installed locally. Unsure on the protocol for installing via brew and then running as a non-service what's expected.
What if you try brew services start influxdb3-core to run as a service?
Yeah it works when running as a service. This is probably okay then.
What if you try brew services start influxdb3-core to run as a service?
Yeah it works when running as a service. This is probably okay then.
Recall that the influxdb3 binary needs to find the libpython it was compiled against. With the macOS builds, we tell it to look for libpython in python/lib/lib${PBS_LIBPYTHON}.dylib relative to the influxdb3 binary. When you invoked influxdb3 in your prior comment, I wonder if you didn't have the python directory present and next to influxdb3.
If this location is a problem for brew, we should be able to adjust the build to look for libpython in multiple places, like with Linux RPATH:
$ patchelf --print-rpath /usr/bin/influxdb3
$ORIGIN/python/lib:$ORIGIN/../lib/influxdb3/python/lib
(the $ORIGIN/python/lib is the Linux equivalent of what we have on macOS; the $ORIGIN/../lib/influxdb3/python/lib path is to accomodate deb/rpm installs that install influxdb3 to /usr/bin/influxdb3, so the binary will look for libpython in /usr/lib/influxdb3/python/lib)
If it would help brew installs to have a more conformant location, could insert this before the call to /usr/local/bin/rcodesign (untested):
echo "Running: /osxcross/bin/aarch64-apple-darwin22.2-install_name_tool -add_rpath '@executable_path/../python/lib/lib${PBS_LIBPYTHON}.dylib' '${PWD}/target/<< parameters.target >>/<< parameters.profile >>/influxdb3'"
/osxcross/bin/aarch64-apple-darwin22.2-install_name_tool -add_rpath "@executable_path/../python/lib/lib${PBS_LIBPYTHON}.dylib" "${PWD}/target/<< parameters.target >>/<< parameters.profile >>/influxdb3"
With that, if influxdb3 was installed to /opt/homebrew/opt/influxdb3-core/bin/influxdb3, then you would then put python in /opt/homebrew/opt/influxdb3-core/python (you could also do this within the ruby script, if install_name_tool were available and properly signs binaries (the osxcross one does not, which is why rcodesign is needed)).
@jdstrand Appreciate the notes. I've made updates to how it requires Python to only use the bundled Python. Review requested.
@jdstrand Ok, incorporated your requested changes. Let me know if good for approval (though, I may wind up merging this into our new forked Homebrew repo instead to push from here).