pyfluidsynth icon indicating copy to clipboard operation
pyfluidsynth copied to clipboard

Add fix to locate Homebrew-installed libfluidsynth on Apple silicon

Open ideoforms opened this issue 1 year ago • 2 comments

On macOS on Apple silicon, non-Homebrew Python distributions fail to locate homebrew-installed instances of FluidSynth and raise an ImportError("Couldn't find the FluidSynth library."). This workaround addresses this.

Thanks for the great library!

ideoforms avatar Jul 02 '24 14:07 ideoforms

https://github.com/nwhitehead/pyfluidsynth/blob/master/.github/workflows/ci.yml#L30-L33

cclauss avatar Jul 02 '24 16:07 cclauss

Thanks for the reply. Setting DYLD_LIBRARY_PATH before running the script is the alternative workaround, and what I was using previously. However, this imposes an additional requirement that would need to be set up by the user in each different environment they're using pyfluidsynth in, and I think it's helpful to let the library handle this for the user.

Let me know if you're happy to potentially merge this, and I will address the codespell_and_ruff issues.

ideoforms avatar Jul 02 '24 17:07 ideoforms

Thanks @cclauss! Just tested and unfortunately the revised version does not work; the HOMEBREW_PREFIX environmental variable isn't always set unless your terminal is set up to explicitly evaluate brew shellenv, which mine isn't. So brew --prefix is the canonical way to achieve this.

ideoforms avatar Aug 08 '24 11:08 ideoforms

You can either evaluate https://docs.brew.sh/Manpage#shellenv-shell- or export HOMEBREW_PREFIX=$(brew --prefix)

Improperly installing homebrew seems suboptimal in any case.

cclauss avatar Aug 08 '24 15:08 cclauss

Configuring shellenv isn't part of the installation process, though; I have installed Homebrew on dozens of macOS systems over the years, and this isn't something that is required for any other package I've encountered.

I'd see the additional step of setting HOMEBREW_PREFIX as similar to the earlier workaround with DYLD_LIBRARY_PATH: a user absolutely could do this, but it's not easily discoverable and would require some extra research/documentation at setup time, which many users just won't get past. I think these small quality of life features make a package much more frictionless and attractive in general.

pyfluidsynth is a great package, and it would be nice if installing and using it was as simple as a one-liner pip install for all users.

ideoforms avatar Aug 08 '24 15:08 ideoforms