Skip to content
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

Add fix to locate Homebrew-installed libfluidsynth #69

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

ideoforms
Copy link
Contributor

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!

@cclauss
Copy link
Collaborator

cclauss commented Jul 2, 2024

@ideoforms
Copy link
Contributor Author

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.

fluidsynth.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please retest this solution on your Mac and let us know if it works or not.

@cclauss cclauss merged commit 4779dca into nwhitehead:master Aug 7, 2024
5 checks passed
@cclauss cclauss changed the title Add fix to locate Homebrew-installed libfluidsynth on Apple silicon Add fix to locate Homebrew-installed libfluidsynth Aug 7, 2024
@ideoforms
Copy link
Contributor Author

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.

@cclauss
Copy link
Collaborator

cclauss commented Aug 8, 2024

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.

@ideoforms
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants