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

Find libsndfile.dylib on Apple M1 #311

Merged
merged 1 commit into from
Dec 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions soundfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import os as _os
import sys as _sys
from platform import machine as _machine
from os import SEEK_SET, SEEK_CUR, SEEK_END
from ctypes.util import find_library as _find_library
from _soundfile import ffi as _ffi
Expand Down Expand Up @@ -159,8 +160,16 @@
while not _os.path.isdir(_path):
_path = _os.path.abspath(_os.path.join(_path, '..'))

_snd = _ffi.dlopen(_os.path.join(
_path, '_soundfile_data', _libname))
# Homebrew on Apple M1 uses a `/opt/homebrew/lib` instead of
# `/usr/local/lib`. We are making sure we pick that up.
if _sys.platform == 'darwin' and _machine() == 'arm64':
_hbrew_path = '/opt/homebrew/lib/' if _os.path.isdir('/opt/homebrew/lib/') \
else '/usr/local/lib/'
_snd = _ffi.dlopen(_os.path.join(
_hbrew_path, _libname))
else:
_snd = _ffi.dlopen(_os.path.join(
_path, '_soundfile_data', _libname))

__libsndfile_version__ = _ffi.string(_snd.sf_version_string()).decode('utf-8', 'replace')
if __libsndfile_version__.startswith('libsndfile-'):
Expand Down